[wdmaudiodev] Re: SetNotificationFreq() has no effect on CopyFrom() ???

  • From: Ken Cooper <Ken.Cooper@xxxxxxxxxxxxx>
  • To: "wdmaudiodev@xxxxxxxxxxxxx" <wdmaudiodev@xxxxxxxxxxxxx>
  • Date: Mon, 4 Jun 2007 14:44:27 -0700

First of all, CopyTo() and CopyFrom() are the same routines.  The differences 
you are seeing are a result of the usage differences in render versus capture.

WaveCyclic was written back in the Win98 days and uses a cyclic DMA buffer that 
the audio DMA reads or writes to transfer data to or from the codec.  IRPs are 
used as the data transport down the audio driver stack and the data is 
transferred between the IRPs and the cyclic DMA buffer using a deferred 
procedure call (DPC).  When run, the DPC looks at the current DMA position and, 
based on knowledge of the previous buffer read/write position, determines how 
many audio frames to transfer between the cyclic DMA buffer and available 
streaming IRPs.  The DPC calls CopyTo or CopyFrom to copy the data and then 
updates its buffer read/write position info.

There are several factors that can contribute to getting multiple CopyTo or 
CopyFrom calls in a single DPC cycle and for the variable transfer sizes.

     *) If the desired transfer wraps around the end of the cyclic DMA buffer 
the transfer will be broken into two transfers, one at the end of the buffer 
and one at the beginning

     *) If the desired transfer spans an IRP boundary the transfer will be 
broken up into two transfers (or more depending on IRP packet sizes)

     *) The DPC is scheduled to run each time the miniport notifies the port 
driver.  So, if you set the notification frequency to 20ms and notify the port 
at that rate, the DPC will run at least every 20ms.  However, the DPC is also 
scheduled to run each time a new streaming IRP arrives (this reduces the chance 
of starvation and glitches).  As a result, you may see variable DPC scheduling 
impacting DMA transfer sizes.

The asymmetry between render and capture are just artifacts of the different 
data flow direction combined with the different timing of the three factors 
above.  I hope that this explanation answers your questions.

Regards,

Ken


-----Original Message-----
From: wdmaudiodev-bounce@xxxxxxxxxxxxx 
[mailto:wdmaudiodev-bounce@xxxxxxxxxxxxx] On Behalf Of Don Bell
Sent: Monday, June 04, 2007 9:55 AM
To: wdmaudiodev@xxxxxxxxxxxxx
Subject: [wdmaudiodev] SetNotificationFreq() has no effect on CopyFrom() ???

In a driver that I have written based on the MSVAD (simple) sample, I
use the inherited IMiniportWaveCyclicStream::SetNotificationFreq() to
set the interval to 20ms.

This indeed sets correctly the interval in which the inherited
IDmaChannel::CopyFrom(), supplying exactly FrameSize bytes to read
every such call.

However, IDmaChannel::CopyFrom() arrives at a higher "rate" (up to 5
such calls every 20ms), with the ByteCount parameter being anywhere
between 16 and FrameSize (15 < ByteCount < FrameSize + 1).

As long as I understand that this behavior is consistent and in line
with Microsoft's design, I can deal with that. However, I was
surprised to discover this lack of symmetry between CopyTo and
CopyFrom (or "render" and "capture").

Could you please confirm that my observation is correct? i.e. there is
no way to set PortCls in such a way that IDmaChannel::CopyFrom()'s
third parameter (IN ULONG  ByteCount) will always be caled with a
fixed value?

Also, some insight as to why this is implemented this way would very
appreciated. I am curious to understand the rational behind this.

Thanks,
Don
******************

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/

******************

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: