[wdmaudiodev] Q: SYSVAD Render Exclusive Mode cannot work !?

  • From: "Vincent Burel \(VB-Audio\)" <vincent.burel@xxxxxxxxxxxx>
  • To: <wdmaudiodev@xxxxxxxxxxxxx>
  • Date: Mon, 2 Jul 2018 09:03:57 +0200

I've also posted an issue on GitHub

https://github.com/Microsoft/Windows-driver-samples/issues/255

 

----------- ISSUE in SYSVAD Example Render Exclusive mode -------------

When testing SYSVAD by sending audio to Speaker in WASAPI exclusive mode,
the generated file is not correct (noise is added).

 

If analyzing the method used in minwavertstream.cpp, we see no way to get
something working.

 

When sending audio to SYSVAD Speaker in exclusive mode, the function
CMiniportWaveRTStream::AllocateBufferWithNotification is called 

 

REM: it makes no sense to test if the buffer size is multiple of
NotificationCount_ (2) while the buffer is expected to be multiple of
m_pWfExt->Format.nBlockAlign

`if ((NotificationCount_ == 0) || (RequestedSize_ % NotificationCount_ !=
0))`

buffer size must be converted in sample before... 

 

Anyway, the method is expected to be simple: AllocateBufferWithNotification
is called to allocate a buffer multiple of 2 (NotificationCount_ ) in order
to be able to manage the entire DMA Buffer in 2 egual size buffers to make a
simple double buffering process: while one process is reading a buffer, the
other process is writing in the second buffer... 

 

However this method is not implemented correctly.

First because the buffer timing is wrong per definition
m_ulNotificationIntervalMs introduces a jitter of 0.99 ms in the buffer
duration

 

In this render exclusive mode the function TimerNotifyRT is called every ms
to check if a notification must be sent, that we could call the "buffer
swap". But the condition is wrong by design:

`if (TimeElapsedInMS < _this->m_ulNotificationIntervalMs)`

 

the first buffer is surely not finished at this time, because missing up to
0.99 ms. it means there is no chance to be sure that the HALF DMABuffer is
processed at this time.

 

Secondly because the timer does not survey any position regarding the
DMABuffer management: nor m_ullPlayPosition (managed UpdatePosition()), nor
m_ulCurrentWritePosition (set by SetCurrentWritePosition by the system I
guess).

 

So, how this example of code could work? Did anyone test this mode
successfully yet ? 

Other related posts:

  • » [wdmaudiodev] Q: SYSVAD Render Exclusive Mode cannot work !? - Vincent Burel (VB-Audio)