RE: Driver seems a little dizzy while running more than onmediaplayer
RE: Driver seems a little dizzy while running more than onmediaplayer
- Subject: RE: Driver seems a little dizzy while running more than onmediaplayer
- From: "David Tan" <email@hidden>
- Date: Fri, 27 Feb 2009 09:49:38 -0800
Hi Jeff,
You're always so lightening for me :)
>> I was referring to how your driver handles dropping time stamps for
>> the HAL. There are multiple real time threads running when there are
>> multiple user clients. If you are not careful with when you take your
>> time stamp, this extra thread activity will introduce errors in your
>> time stamp by causing extra scheduling latency for the thread on which
>> the time stamp is taken. The usual example of this is when a driver
>> takes it's time stamp in a secondary interrupt. The real time thread
>> activity will cause scheduling latency which introduces jitter into
>> such a driver's time stamp.
Sorry, I still have some confusion about the time stamp dropping.
As I understand, every client just transmits its audio data into
IOAudioFamily in an independent thread. Then IOAudioFamily will layout audio
data from different client into the mixbuf of clipOutputSamples(). So every
time I see clipOutputSamples() being called, the data in its arguments
"const void *mixBuf" contains mixed audio.
Please see the algorithm of time stamp in my driver.
As it's a Firewire audio driver, there's an output DCL program which keeps
sending audio data to device.
1. Before start the DCL program, I call clock_get_uptime() to record the
beginning time.
fFirstTimeStamp = true;
clock_get_uptime(&fLastTimeStamp);
2. I maintain a counter (fWriteSamples) of the output buffer read by output
DCL program. Every time DCL program output a sample, "fWriteSamples" will
step by one. If fWriteSamples increases to the sample buffer size which I
set initially (IOAudioEngine::setNumSampleFramesPerBuffer()), I will call
clock_get_uptime() again to get the elapsed time since the last time of
takeTimeStamp(). Then I input the current time to
IOAudioEngine::takeTimeStamp().
if ((fWriteSamples % kNumBufferSize) == 0)
{
IOAudioEngine::takeTimeStamp(!fFirstTimeStamp,
(AbsoluteTime*)&fLastTimeStamp);
clock_get_uptime(&fLastTimeStamp);
if (fFirstTimeStamp)
{
fFirstTimeStamp = false;
}
}
It works fine for only one client. For two clients, sometime it's OK. But it
does get jitter sometimes. So there must be some errors. Could you please
give me some advice or tips? Thanks a lot!
Sincerely yours,
David Tan
Dextrys Co., Ltd.
_______________________________________________
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