Converting AudioTimeStamp between two devices
Converting AudioTimeStamp between two devices
- Subject: Converting AudioTimeStamp between two devices
- From: Andrew Kimpton <email@hidden>
- Date: Thu, 01 Jun 2006 18:00:15 -0700
I need to make sure that my captured audio is in perfect sync with the
played/output audio. In order to correct for system delays I use a
comparison between the 'inInputTime' timestamp and the 'inOutputTime'
timestamp to establish when the output audio could be heard at the
input port.
This works well with a single callback on a single device (and for
aggregate devices), if I loop output to input my recording is in sync.
However when the two devices are different subtracting the sample
times from the two devices would not be valid (correct ?)
So I'm attempting to convert the output timestamp to an input
timestamp using AudioDeviceTranslateTime() as follows :
AudioTimeStamp firstPlayTime = iFirstPlayTimeStamp;
AudioTimeStamp firstPlayTimeForInputDevice;
firstPlayTime.mFlags = kAudioTimeStampSampleHostTimeValid;
memset(&firstPlayTimeForInputDevice,0,sizeof(firstPlayTimeForInputDevice));
firstPlayTimeForInputDevice.mFlags = kAudioTimeStampSampleTimeValid;
OSStatus osStatus =
AudioDeviceTranslateTime(iInputDeviceID,&firstPlayTime,&firstPlayTimeForInputDevice);
This 'works' in that I get no error and my firstPlayTimeForInputDevice
is updated, however the actual value doesn't seem to be converted,
rather it's the same as the firstPlayTime.mSampleTime.
That doesn't seem right to me - I would expect the values to be
different between the two devices, furthermore actual testing this
with a loopback between output and input doesn't give correct results
(the recorded input is out of sync).
Is this the correct way to establish what the sample time on one
device would be on a second device ? Or is there some alternative way
? Should I be specifying more flags ? iFirstPlayTimeStamp is a
straight copy of the HAL callback time stamp from the play/output
callback so it does have a full complement of sample times, host times
and rate scalar info.
Thanks
Andrew 8-)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden