When is pcmreadcallback called vs dsp read callback


(Angel) #1

HI folks
I have another question…
This is my fmod setup:
I set system.setOutput to FMOD_OUTPUTTYPE_NOSOUND_NRT
2 sound streams, each with their own ring buffers and pcm read callbacks.

I will write data to each of their ring buffers, and they will read it in each of their callbacks.

I have a dsp added to the master channel group because I want the final mix of my 2 sound streams to write to disk. This dsp will write the final mix into its own ring buffer

This is what happens when my program starts, looping from 1-3:
1 - write data to the ring buffers of my 2 sound streams
2 - fmod.update
3 - read out the dsp data from the dsp’s ring buffer

However, it seems that the pcmreadcallback is not called before (3). It is only called around the 4th time fmod.update is called. This is causing my dsp to send back silent data for the first 4 times I call (3), and I think it’s causing some gapping issues too.

When/how does fmod determine when to call pcmreadcallback?


(Brett Paterson) #2

The dsp engine is running at 1024 samples probably, and the stream buffer size has nothing to do with that. it is bigger usually, and controlled with FMOD_CREATESOUNDEXINFO::decodeBufferSize


(Angel) #3

Thanks!
You’re right about the dsp size.
I fixed my decodeBufferSize value and the lag/gap has improved.
However I’m facing another issue, which is random (ugh).

At every frame of my application, I decode mp3 data and ship it off to a ring buffer, which pcmreadcallback is supposed to pick up.
However, at some runs, pcmreadcallback will be called more than expected, so my ring buffer runs out of data, producing a 1 frame gap.

Do you have any advice on how to fix this issue?