[wdmaudiodev] Re: How to adjust lip-sync for WaveCyclic driver using GetPosition()

  • From: "Bielik, Robert" <Robert.Bielik@xxxxxxxxx>
  • To: "wdmaudiodev@xxxxxxxxxxxxx" <wdmaudiodev@xxxxxxxxxxxxx>
  • Date: Sat, 8 Jun 2013 06:11:19 +0000

Hi Philip,

To my knowledge there is no mechanism today in Windows to accommodate for 
latencies in the HW chain. In WaveRT there is a possibility to query the driver 
for HW latencies, but normally they're so small so it does not matter much for 
lip-sync accuracy anyway.

That's why (almost?) all video players have the possibility to offset the video 
wrt audio position.

Regards,
/Rob

-----Original Message-----
From: wdmaudiodev-bounce@xxxxxxxxxxxxx 
[mailto:wdmaudiodev-bounce@xxxxxxxxxxxxx] On Behalf Of Philip Gruebele
Sent: den 8 juni 2013 00:53
To: wdmaudiodev@xxxxxxxxxxxxx
Subject: [wdmaudiodev] How to adjust lip-sync for WaveCyclic driver using 
GetPosition()

Hi All.

I have a WaveCyclic (msvad based) USB audio driver.  It works perfectly except 
for one issue:  lip-sync is not perfect and I would like to compensate for 
hardware/USB latencies to fix this.

According to MS docs, GetPosition() should start incrementing when in the RUN 
state.  Also, GetPosition() is supposed to return the current sample position 
which is being output by the speakers.  For my driver, there is about 30ms of 
USB buffering and then the USB audio device also buffers about 30ms.  This 
amounts to a total hardware latency of 60ms.  
Since GetPosition() is supposed to return the buffer position currently being 
output by the DAC, this means that after entering KS_RUN state,
GetPosition() should return 0 for about 60ms, and only then start to increment 
(since the hardware is not outputting the sample data for the first 60 ms).

The problem is that when GetPosition() is implemented to stay at position 0 for 
60ms, WaveCyclic stops calling CopyTo() and the render stream stalls.

Does anyone know why this happens?  Is this a bug in Wavecyclic?  It should not 
stall under these conditions, right?  This is how hardware latency should be 
handled no? The buffer size I report back to WaveCyclic is large enough to 
handle 60ms of data, and CopyTo() stalls after just 30ms...  It's a mystery.  
One can repeat this problem by simply modifying MSVAD to return 0 for 60ms 
after entering KS_RUN state.

Any help is much appreciated!

Thanks
******************

WDMAUDIODEV addresses:
Post message: mailto:wdmaudiodev@xxxxxxxxxxxxx
Subscribe:    mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=subscribe
Unsubscribe:  mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=unsubscribe
Moderator:    mailto:wdmaudiodev-moderators@xxxxxxxxxxxxx

URL to WDMAUDIODEV page:
http://www.wdmaudiodev.com/

Other related posts: