In the example decoder it writes data in varying lengths to stdout, is it possible to alter the decoder to write the same length data to stdout every time? Rather, how would you alter the decoder to do that. It seems to be writing everything from 512 to 4096 bytes each time and i cant really see why this is and how to change it. <p><p>--- >8 ---- List archives: http://www.xiph.org/archives/ Ogg project homepage: http://www.xiph.org/ogg/ To unsubscribe from this list, send a message to 'vorbis-request@xiph.org' containing only the word 'unsubscribe' in the body. No subject is needed. Unsubscribe messages sent to the list will be ignored/filtered.
On thursday, march 27, 2003, at 01:35 (Europe/Copenhagen time), Ed Sweetman wrote:> In the example decoder it writes data in varying lengths to stdout, is > it possible to alter the decoder to write the same length data to > stdout every time? Rather, how would you alter the decoder to do > that. It seems to be writing everything from 512 to 4096 bytes each > time and i cant really see why this is and how to change it.This is because the decoder doesn't decode farther than the current frame. Make a small loop, repeatedly calling the decode function until you get the amount you need. I believe it says something about this in the libvorbisfile documentation. Something like this: int left = 4096; while(left > 0) { int data_read = vorbis_read(..., left); // Can't remember the name of the decode function. // Do something with data, e.g. buffer it. left -= data_read; } // Write buffer to stdout or similar. Unless there was an EOF, it should be size 4096. In the above code, special concern needs to be taken with regard to EOF. -- Sune Foldager DIKU - Department of Computer Science, University of Copenhagen. --- >8 ---- List archives: http://www.xiph.org/archives/ Ogg project homepage: http://www.xiph.org/ogg/ To unsubscribe from this list, send a message to 'vorbis-request@xiph.org' containing only the word 'unsubscribe' in the body. No subject is needed. Unsubscribe messages sent to the list will be ignored/filtered.
Ed Sweetman <ed.sweetman@wmich.edu> said:> In the example decoder it writes data in varying lengths to stdout, is > it possible to alter the decoder to write the same length data to stdout > every time? Rather, how would you alter the decoder to do that. It > seems to be writing everything from 512 to 4096 bytes each time and i > cant really see why this is and how to change it. >You can add an additional buffering layer after the decoder if you want, in order to force writes of a specific length each time. The writes depend on the block size of each vorbis audio packet decoded - since vorbis has multiple block sizes, this varies - and the way the example decoder is structured, it simply outputs the decoded audio from a single packet each time. Mike --- >8 ---- List archives: http://www.xiph.org/archives/ Ogg project homepage: http://www.xiph.org/ogg/ To unsubscribe from this list, send a message to 'vorbis-request@xiph.org' containing only the word 'unsubscribe' in the body. No subject is needed. Unsubscribe messages sent to the list will be ignored/filtered.