[wdmaudiodev] Re: Need help in Passing a test case from KS-Position test

  • From: Matthew van Eerde <Matthew.van.Eerde@xxxxxxxxxxxxx>
  • To: "wdmaudiodev@xxxxxxxxxxxxx" <wdmaudiodev@xxxxxxxxxxxxx>
  • Date: Fri, 2 May 2014 16:44:46 +0000

I dug through the source code history of MSVad and I see that the ::GetPosition 
implementation changed in 2007. For example, the TimeElapsedInMS initialization 
used to look like this:
        ULONG TimeElapsedInMS =
            ( (ULONG) (CurrentTime - m_ullDmaTimeStamp) ) / 10000;

And now it looks like this:
        ULONG TimeElapsedInMS =
            ( (ULONG) (CurrentTime - m_ullDmaTimeStamp + 
m_ullElapsedTimeCarryForward) ) / 10000;

I ran a test locally on the most recent MSVad and I got this as expected; no 
skew, and ~0.29 ms jitter for a 1 ms bursty position.
Calculated sample rate = 176400.001 bytes/sec, 44100.000 samples/sec
STD of position noise = 0.290716 ms

The KS-Position log you sent me shows this: skew is about 0.07% slow, and 
jitter is about half that expected for a 1 ms bursty position.
Calculated sample rate = 176259.494 bytes/sec, 44064.874 samples/sec
STD of position noise = 0.151776 ms

Can you send me the GetPosition code from the MSVad implementation you have?

If I remove the 1ms burstiness from GetPosition, I get almost no skew/jitter:

Calculated sample rate = 176399.173 bytes/sec, 44099.793 samples/sec
STD of position noise = 0.041502 ms

    if (m_fDmaActive)
    {
        ULONGLONG ullNow = KeQueryInterruptTime();

        ULONGLONG ullElapsed = ullNow - m_ullDmaTimeStamp;

        // hns/sec = hns/us * us/ms * ms/s
        ULONGLONG ullHnsPerSec = 10ull * 1000ull * 1000ull;
        ULONGLONG ullHnsInHalfASec = ullHnsPerSec / 2;

        // bytes = bytes/sec * hns / (hns/sec)
        ULONG ulByteDisplacement = (ULONG)((m_ulDmaMovementRate * ullElapsed + 
ullHnsInHalfASec) / ullHnsPerSec);

        m_ulDmaPosition =
            (m_ulDmaPosition + ulByteDisplacement) % m_ulDmaBufferSize;

        *Position = m_ulDmaPosition;

        m_ullDmaTimeStamp = ullNow;
    }
    else
    {
        *Position = m_ulDmaPosition;
    }

From: Matthew van Eerde
Sent: Friday, May 2, 2014 8:48 AM
To: wdmaudiodev@xxxxxxxxxxxxx
Subject: RE: [wdmaudiodev] Re: Need help in Passing a test case from 
KS-Position test

> STD of position noise = 0.151776 ms

Hmm… now I’m confused.

An ideal position counter is sample-accurate and specifies exactly the sample 
that is going through the DAC or ADC at the QueryPerformanceCounter time that 
ends up getting returned up via KSPROPERTY_AUDIO_POSITIONEX.

A less-than-ideal position counter which has a 1 ms granularity will have a 
standard deviation of 1/(2√3) ms, if I do the math correctly. That comes to 
0.29-ish ms.

Somehow MSVad’s position counter is achieving a 0.15 ms standard deviation.

From: wdmaudiodev-bounce@xxxxxxxxxxxxx<mailto:wdmaudiodev-bounce@xxxxxxxxxxxxx> 
[mailto:wdmaudiodev-bounce@xxxxxxxxxxxxx] On Behalf Of Gaurav Khuntale
Sent: Thursday, May 1, 2014 10:13 PM
To: wdmaudiodev@xxxxxxxxxxxxx<mailto:wdmaudiodev@xxxxxxxxxxxxx>
Subject: [wdmaudiodev] Re: Need help in Passing a test case from KS-Position 
test

Hi Matthew,
I have attached a log file which contains logs for Standard Streaming\Rendering 
Performance Tests\Position Drift and Jitter for AEC test case for MASVAD sample 
driver.
Thanks.

On Wed, Apr 30, 2014 at 9:34 PM, Matthew van Eerde 
<Matthew.van.Eerde@xxxxxxxxxxxxx<mailto:Matthew.van.Eerde@xxxxxxxxxxxxx>> wrote:
I looked at MSVad’s GetPosition implementation and it looks like it’s bursty 
with a 1 ms granularity. So I don’t understand how it’s passing. Can you post 
the log?

From: wdmaudiodev-bounce@xxxxxxxxxxxxx<mailto:wdmaudiodev-bounce@xxxxxxxxxxxxx> 
[mailto:wdmaudiodev-bounce@xxxxxxxxxxxxx<mailto:wdmaudiodev-bounce@xxxxxxxxxxxxx>]
 On Behalf Of Gaurav Khuntale
Sent: Wednesday, April 30, 2014 12:19 AM
To: wdmaudiodev@xxxxxxxxxxxxx<mailto:wdmaudiodev@xxxxxxxxxxxxx>
Subject: [wdmaudiodev] Re: Need help in Passing a test case from KS-Position 
test

Hi Matthew,
Thanks for the reply.
Actually i tried the same test with MSVAD sample driver and it is passing it. 
My driver's GetPosition() implementation is exactly same as MSVAD sample driver 
but still it is failing in that test case. Like MSVAD sample driver, i am using 
a unit of milliseconds to calculate byte position in GetPosition() function.
Thanks,
Gaurav

On Tue, Apr 29, 2014 at 10:12 PM, Matthew van Eerde 
<Matthew.van.Eerde@xxxxxxxxxxxxx<mailto:Matthew.van.Eerde@xxxxxxxxxxxxx>> wrote:
A standard deviation of 0.3 milliseconds is consistent with a position counter 
that has a granularity of 1 millisecond, which is too coarse. Your position 
counter should have a granularity of 1 sample.

From: wdmaudiodev-bounce@xxxxxxxxxxxxx<mailto:wdmaudiodev-bounce@xxxxxxxxxxxxx> 
[mailto:wdmaudiodev-bounce@xxxxxxxxxxxxx<mailto:wdmaudiodev-bounce@xxxxxxxxxxxxx>]
 On Behalf Of Gaurav Khuntale
Sent: Tuesday, April 29, 2014 8:59 AM
To: wdmaudiodev@xxxxxxxxxxxxx<mailto:wdmaudiodev@xxxxxxxxxxxxx>
Subject: [wdmaudiodev] Need help in Passing a test case from KS-Position test

Hello,
       I am working on a virtual audio driver which is based on wave cyclic 
port driver. The driver similar to the MSVAD sample driver from the DDK. I am 
facing an issue with understanding a test from KS position test. Following are 
the extracts from the test log:

Collected 6857 good data points which covers 80828.491 ms
Detected 0 glitches in 81 seconds
Specified sample rate  = 176400.000 bytes/sec, 44100.000 samples/sec
Calculated sample rate = 176400.004 bytes/sec, 44100.001 samples/sec
Sample rate drifting ratio = 0.000002 %
Average position noise magnitude = 0.279960 ms
STD of position noise = 0.332027 ms
0.247922% of position noise is larger than 0.8 ms
Largest short term (2 seconds) position noise average is 0.000547ms
FAIL: STD of position noise is 0.332027ms which is larger than 0.3ms
End Case: ID 16.26:1.8 : FAIL : Standard Streaming\Rendering Performance 
Tests\Position Drift and Jitter for AEC : [Mon Apr 28 15:50:02 2014]

The GetPosition() implementation is similar to the one in MSVAD. I am not 
getting what the test wants to say and what it is expecting. So can anyone 
please explain it to me?
Thanks.


Other related posts: