Here is two pieces of my code
the Open decoder function:
int QDecoder::Open(QMediaReader & mediaReader)
{
TtakSSDOptions opt = { tak_Cpu_Any, 0 };
TtakStreamIoInterface sioi = { _CanRead, _CanWrite, _CanSeek, _Read, NULL, NULL, NULL, _Seek, _GetLength };
m_Decoder = tak_SSD_Create_FromStream( &sioi, &mediaReader, &opt, NULL, NULL);
int ret = 0;
_pmr = NULL;
if ( tak_True == tak_SSD_Valid( m_Decoder)) {
// get audio info
if ( tak_res_Ok != tak_SSD_GetStreamInfo( m_Decoder, &m_StreamInfo)) {
tak_SSD_Destroy( m_Decoder);
m_Decoder = NULL;
ret = 0;
} else {
// allocate decoding buffer
m_TAKBuf = new BYTE[m_StreamInfo.Sizes.FrameSizeInSamples * m_StreamInfo.Audio.BlockSize];
// save media reader
_pmr = &mediaReader;
_seekable = mediaReader.CanSeek();
ret = 1;
}
} else {
ret = (tak_res_ssd_Undecodable == tak_SSD_State( m_Decoder)) ? -1 : 0;
}
return ret;
}
and the Seek function
int QDecoder::Seek(int ms)
{
TtakResult ret;
TtakInt64 spos;
if ( tak_True != tak_SSD_Valid( m_Decoder))
return 0;
spos = (TtakInt64)(ms/1000.0 * m_StreamInfo.Audio.SampleRate);
ret = tak_SSD_Seek( m_Decoder, spos);
if ( tak_True != tak_SSD_Valid( m_Decoder))
return 0;
_pos = spos * m_StreamInfo.Audio.SampleRate * 1000.0;
return 1;
}
P.S. My "mediareader" only support read, seek, getlength, getcurpostion routines. I think it is not important for a decoder to support write function.