Re: Stream time when two processes use same device.
Re: Stream time when two processes use same device.
- Subject: Re: Stream time when two processes use same device.
- From: Jeff Moore <email@hidden>
- Date: Thu, 18 Sep 2003 09:50:12 -0700
The absolute sample numbers the HAL vends out are derived from the time
stamps the hardware provides. They start at zero when the device is
first started. Each process running the HAL sees the exact same series
of time stamps from the driver, so they sample number is going to be
the same across them. As you have seen, when another app is using the
device before you do, your process jumps in in the middle.
So what this means, is that the absolute sample numbers are not really
important. Instead, it is the difference between successive readings
that differs. Because of this, you need to establish a zero point for
your process and measure time relative to that.
On Sep 17, 2003, at 10:41 PM, Dominic Mazzoni wrote:
I have a program that plays audio using CoreAudio, and displays the
current position within the audio file using the
"AudioDeviceGetCurrentTime" function.
This works great normally. However, when another program is also
using the same audio device (for example, if I start playing a song
in iTunes), then "AudioDeviceGetCurrentTime" doesn't give me times
relative to the beginning of my stream, but rather relative to the
beginning of when iTunes opened its stream. In other words, if I
start playing a song in iTunes, and 30 seconds later my program
starts playing, then my program shows that 30 seconds have elapsed.
Is there any way around this?
Obviously one solution is to just capture the stream time when I
start playing. However, that isn't a perfect solution, because
when iTunes is not running, the initial stream time I get is not
actually zero, but a little less than zero, because CoreAudio is
taking into account the hardware buffering and the estimated exact
time that the first sample will really play. Empirically, this
value seems to be quite different every time - ranging from 0.02
to 0.09 seconds.
I tested this with two devices: the built-in audio on my Power Mac
G4/733, and with a USB Audio Quattro. Same behavior.
Any suggestions would be greatly appreciated.
- Dominic
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.
--
Jeff Moore
Core Audio
Apple
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.