[wdmaudiodev] Re: [EXTERNAL] SetWritePacket in a MiniportWaveRTStream DATA_OVERRUN handling

  • From: "Matthew van Eerde" <dmarc-noreply@xxxxxxxxxxxxx> ("Matthew.van.Eerde")
  • To: "wdmaudiodev@xxxxxxxxxxxxx" <wdmaudiodev@xxxxxxxxxxxxx>
  • Date: Fri, 24 Mar 2023 15:27:27 +0000

You need to arrange for the clock in your hardware to drive the audio. The 
sample can’t do this because there is no hardware.

From: wdmaudiodev-bounce@xxxxxxxxxxxxx <wdmaudiodev-bounce@xxxxxxxxxxxxx> On 
Behalf Of K. Weller
Sent: Friday, March 24, 2023 5:14 AM
To: wdmaudiodev@xxxxxxxxxxxxx
Subject: [EXTERNAL] [wdmaudiodev] SetWritePacket in a MiniportWaveRTStream 
DATA_OVERRUN handling


Hi all,
I have implemented the Microsoft SimpleAudioSample from Github.

I have added an SPDIF Pin for rendering  and I have connected everything to my 
hardware and all is fine and works like expected.

But if I start a 5.1 Dolby Digital Video for example with the Microsoft Media 
Player or  the "TV & Video" App which is default on Win 11 for example it 
starts to get distorted.

Right now I still run the MiniportWaveRTSteam with the notification timer like 
it is in the example to focus on this issue and do not add new possible bugs.

If the stream starts in event driven mode like this:

m_ulDmaBufferSize 38400
m_ulDmaMovementRate 192000
ulBufferDurationMs 200
m_ulNotificationIntervalMs 100
NotificationCount_ 2

I get the first call into

CMiniportWaveRTStream::SetWritePacket

PacketNumber = 1
Flags = 0
Eos = 19200

KSSTATE is still KSSTATE_PAUSE

next call will be the same like above but in KSSTATE_RUN.

Now I save the first half of the buffer to the hardware and after the 
m_ulNotificationIntervalMs period  I trigger the event which is actually the 
first call to KSetEvent in the timer callback.

I get another call into:

CMiniportWaveRTStream::SetWritePacket

PacketNumber = 3
Flags = 0
Eos = 19200

A the same time I only have triggered one (1) event in my timer.

In the timer the:

m_llPacketCounter is incremented and should match the PacketNumber from the 
SetWritePacket like this:

(m_llPacketCounter + 1) == PacketNumber

Because there is one package missing in between, I'll run into a data overrun 
and the current sample implementation returns a STATUS_DATA_OVERRUN.

Also my stream is distorted.



Well for me there are several questions:

1. Why is this PackageNumber not continuously?

2. Where is it counted and is the information retrieved somewhere out of my 
driver?

3. How do I handle something like this correctly to get an proper stream after 
the next event?



It seems this only happens if I have a bigger buffer and longer duration like:

ulBufferDurationMs 200
m_ulNotificationIntervalMs 100



A stereo stream for example with

ulBufferDurationMs 20
m_ulNotificationIntervalMs 10

works perfect.

Also:

If I use VLCPlayer for example which will not use event driven mode the movie 
will playback as expected. So I can be sure the issue is not on the hardware 
side of the implementation etc.



Thanks for any help and feedback,

Regards

K. Weller




Other related posts: