[Flac-dev] FLAC++ SeekableStream write_callback not being called?

John Steele Scott toojays at toojays.net
Tue Nov 25 02:58:02 PST 2003


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

I am trying to create a FLAC plugin for the K3b CD burning program. To do this 
I have subclassed the FLAC::Decoder::SeekableStream class. I can obtain the 
vorbiscomment data using set_metadata_respond, process_until_end_of_metadata 
and the metadata_callback, however I cannot decode the audio data. It seems 
to me as though the write_callback is never actually being called.

Before I pepper my code with a bazillion trace statements, can anyone tell me 
if there is some obvious "trick-for-new-players" which I might have missed?

My write_callback looks like:

::FLAC__StreamDecoderWriteStatus 
K3bFLACDecoder::Private::write_callback(const ::FLAC__Frame *frame, const 
FLAC__int32 * const buffer[]) {
  int i;
  // Note that in canDecode we made sure that the input is only 16 bit stereo.
  int samples = frame->header.blocksize;

  internalBuffer = new QBuffer();
  internalBuffer->open(IO_ReadWrite);
  for(i=0; i < samples; i++) {
    internalBuffer->putch(buffer[i][0] >> 8); // msb left
    internalBuffer->putch(buffer[i][0] & 0xFF); // lsb left
    internalBuffer->putch(buffer[i][1] >> 8); // msb right
    internalBuffer->putch(buffer[i][1] & 0xFF); // lsb right
  }

  // Rewind the buffer so the decode method will take data from the beginning.
  internalBuffer->at(0);
  
  return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
}

And the code which I expect to have call it is (where "d" is an instance of my 
K3bFLACDecoder::Private class) :

  if(d->internalBuffer == 0) {
    if(d->get_state() == FLAC__SEEKABLE_STREAM_DECODER_END_OF_STREAM) {
      // Nothing left to do.
      return 0;
    } else {
      // Get some more data into our internal buffer.
      d->process_single();
    }
  }

Yet my internalBuffer is never initialised. I have also tried to have:

 while(d->internalBuffer==0)
   d->process_single();

but this only results in an infinite loop. I get similarly depressing results 
from process_until_end_of_stream.

Any suggestions would be appreciated.

cheers,

John
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)
Comment: Messages with missing or bad signatures may have been forged or modified in transit!

iD4DBQE/wzVt0BW7kPcXjRURAnDiAJdiJYF1mt4wN2gmcMb0llxOPswGAKCNgjia
CYbQZiiUZzRPR69XrXMdAQ==
=wufc
-----END PGP SIGNATURE-----





More information about the Flac-dev mailing list