<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hi,<br>
<br>
I've trying to decode a FLAC audio stream. I have a reader which
sends raw byte data to my FLAC wrapper class. Only once the decode
function below returns, the reader will send new data.<br>
Hence I want to decode until the stream is empty, but I will add new
data to the stream once it is empty.<br>
<br>
<b>void </b><b>MyFlacCoder::</b><b>decode(char *data, int bytes)<br>
{<br>
mBuffer = input;<br>
mBufferBytes = bytes;<br>
FLAC__stream_decoder_process_until_end_of_stream(mDecoder);<br>
}<br>
</b><br>
My read callback looks as follows:<br>
<b><br>
FLAC__StreamDecoderReadStatus flacReadDecode(const
FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes,
void *client)<br>
{<br>
MyFlacCoder *coder = (MyFlacCoder*) client;<br>
int size =min(*bytes, coder->mBufferBytes);<br>
if(size <= 0)<br>
{<br>
*bytes = 0;<br>
return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM;<br>
}<br>
memcpy(buffer, coder->mBuffer, size);<br>
*bytes = size;<br>
coder->mBuffer += size;<br>
coder->mBufferBytes -= size;<br>
return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;<br>
}</b><br>
<br>
As far as I understand<b>
FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM</b> notifies FLAC
to stop decoding (no more data will come). However, in my case I
only want FLAC to "pause" and still keep the data that was not
processed yet, until new data is available and I call <b>FLAC__stream_decoder_process_until_end_of_stream</b>
again. So <b>FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM</b> in
my case actually means that the current stream has no more data, but
I will add new data to the stream once it's empty. The problem is
that frames might overlap. Hence I can clear FLAC's buffer, because
there might still be half a frame in the buffer that couldn't be
decoded yet.<br>
<br>
Any suggestions on how I can do this?<br>
<br>
Thank you<br>
Christoph<br>
</body>
</html>