I was successfully able to get a little program working based on the createuserdata example and basically copying the pcmreadcallback function but I don’t think I understand how it works. How often is it called? or What triggers it? What decides the value for the ‘datalen’ parameter?

From the example, it looks like it gets triggered when half of the data has been streamed out, so it’s requesting for the buffer to be filled again so it doesnt starve the soundcard if the other half get’s streamed out.

I am trying to use it as an opportunity to keep the buffer, data, filled with my data, but I am having troubles figuring out if I need to fill half of it every single time or…….?

Any help would be appreciated, thanks:)

  • You must to post comments

I played around with it a bit more and I can probably come up with a more specific question.

this is the code I used to create the stream,
[/code:1uffksrp]and in my pcmreadcallback, I extract the data from whatever source into a vector and fill the buffer with this loop,

short* mydata = (short)data
Vector = getData();
std::vector<short>::iterator itor = Vector->begin();

for( count=0; count < Vector->size(); count++ )
*mydata++ = *itor;

The result I get from all this is an output with breaks in it. Sort of like I’m not filling the data buffer fast enough. For every ‘x’ amount I write to data, I get ‘x’ amount of silence following it. I can change the size of the vectors coming in but all that does is change the value of ‘x’.

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.