CoreAudio callback timeInfo.inputBufferAdcTime is broken for input-only streams
Calculation of inputBufferAdcTime for input-only streams is dependent on output sample rate:
Basically we need to add some code that gets the input sample rate in the same way that we get the output sample rate. That means:
o- add UpdateReciprocalOfActualInputSampleRateFromDeviceProperty, AudioDevicePropertyActualSampleRateListenerProc for input SR
o- register listener in OpenStream call ( if( stream->inputUnit ) branch should look like outputUnit branch.
o- add and use recipricalOfActualInputSampleRate_ioProcCopy at line 1910 in the code above
#!C
timeInfo.inputBufferAdcTime = HOST_TIME_TO_PA_TIME(inTimeStamp->mHostTime) - stream->deviceInputLatencySamples_ioProcCopy * stream->recipricalOfActualOutputSampleRate_ioProcCopy; // FIXME should be using input sample rate here?
Basically we need to add some code that gets the input sample rate in the same way that we get the output sample rate. That means:
o- add UpdateReciprocalOfActualInputSampleRateFromDeviceProperty, AudioDevicePropertyActualSampleRateListenerProc for input SR
o- register listener in OpenStream call ( if( stream->inputUnit ) branch should look like outputUnit branch.
o- add and use recipricalOfActualInputSampleRate_ioProcCopy at line 1910 in the code above
Leave a comment