<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>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; mBuffer = input;<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; mBufferBytes = bytes;<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
      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>
      &nbsp;&nbsp;&nbsp; MyFlacCoder *coder = (MyFlacCoder*) client;<br>
      &nbsp;&nbsp;&nbsp; int size =min(*bytes, coder-&gt;mBufferBytes);<br>
      &nbsp;&nbsp;&nbsp; if(size &lt;= 0)<br>
      &nbsp;&nbsp;&nbsp; {<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; *bytes = 0;<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM;<br>
      &nbsp;&nbsp;&nbsp; }<br>
      &nbsp;&nbsp;&nbsp; memcpy(buffer, coder-&gt;mBuffer, size);<br>
      &nbsp;&nbsp;&nbsp; *bytes = size;<br>
      &nbsp;&nbsp;&nbsp; coder-&gt;mBuffer += size;<br>
      &nbsp;&nbsp;&nbsp; coder-&gt;mBufferBytes -= size;<br>
      &nbsp;&nbsp;&nbsp; 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>