How to call actual/real device from MSVAD CopyTo method?

I am very new to device driver development and may sound silly at times !!

In my project there is a need to capture all the content which goes through the actual sound device. I am thinking of having a virtual device (taking DDK’s MSVAD as base), making it the default device, capture all the content, process it and then reroute it through actual device. For the starter I have taken up the DDK’s MSVAD example and studied it. I think I have gathered basic understanding of the MSVAD. The questions I have are as follows:

–> Do I have to create an IRP and pass it to actual sound driver?
–> How to find PDEVICE_OBJECT of actual sound device driver ?
–> Is it ok to send the ‘Source’, of the CopyTo routine, to the actual device or do I have to wrap it in another buffer?
–> Is my approach sounds ok or is there any logical flaw which I am not able to see ?

Kindly suggest.

xxxxx@yahoo.com wrote:

In my project there is a need to capture all the content which goes through the actual sound device. I am thinking of having a virtual device (taking DDK’s MSVAD as base), making it the default device, capture all the content, process it and then reroute it through actual device.

That’s not the right approach. The Audio Engine in Vista and beyond
provides a feature called “loopback recording” that lets you grab a copy
of the audio stream being sent to a rendering endpoint. All in user
mode, no driver required:

http://msdn.microsoft.com/en-us/library/windows/desktop/dd316551.aspx

For the starter I have taken up the DDK’s MSVAD example and studied it. I think I have gathered basic understanding of the MSVAD. The questions I have are as follows:

–> Do I have to create an IRP and pass it to actual sound driver?
–> How to find PDEVICE_OBJECT of actual sound device driver ?
–> Is it ok to send the ‘Source’, of the CopyTo routine, to the actual device or do I have to wrap it in another buffer?
–> Is my approach sounds ok or is there any logical flaw which I am not able to see ?

You can’t do this from kernel mode. The Audio Engine is a user-mode
service, and audio drivers are just helpers dedicated to that service.
You will need to have your driver send the audio packets to an
application, and have that application forward them to the real audio
endpoint. That’s represents some very tricky buffering issues.

You might also want to check the “Virtual Audio Cable” product, which
can do exactly what you ask.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Thanks for the answer Tim. Actually we want to introduce some global DSP effects to the played audio. I have checked the APO and sAPO but they are hard to install, specially if we are not the actual device vendor (I got this from one your post :slight_smile: ).

–> I have checked the loopback recording earlier but was not sure whether I can introduce the DSP effects. Is it possible to do so in loopback mode?

–> You mentioned “That’s represents some very tricky buffering issues.” could you please mention some?

Thanks.

xxxxx@yahoo.com wrote:

Thanks for the answer Tim. Actually we want to introduce some global DSP effects to the played audio. I have checked the APO and sAPO but they are hard to install, specially if we are not the actual device vendor (I got this from one your post :slight_smile: ).

Correct. The short answer is that Microsoft simply does not want you to
create global DSP effects unless you are the device vendor. Prior to
Vista, the Windows audio environment was a mess. Many people created
what they thought were very clever audio filter solutions as supposed
“value add” solution. Individually, they weren’t bad, but some systems
ended up with quite a few of them, and they tended to fight.

Even worse, every such “value add” filter added to the latency and
unpredictability to the audio path. It made it impossible to create
professional-quality audio solutions. So, in the Vista audio redesign,
there are some overarching philosophies. One major philosophy is that
the audio application is the king. He gets to decide which effects to
use – the OEM with a clever idea does not. Many audio applications
need to go straight to the metal, with no outside interference at all.
That means you can’t have arbitrary filters.

Whether we agree with this philosophy is irrelevant – that’s simply the
way it is. The philosophically correct solution is for you to market
your “global DSP effects” to some audio hardware vendor, and have it
included as an APO with their install.

Note that it IS possible to install an APO without being a hardware
vendor, but it’s ugly, and it’s not supported.

–> I have checked the loopback recording earlier but was not sure whether I can introduce the DSP effects. Is it possible to do so in loopback mode?

You can GET the stream. You can’t ALTER the stream. It wasn’t clear
from your original post that’s what you wanted to do.

–> You mentioned “That’s represents some very tricky buffering issues.” could you please mention some?

You have two audio drivers and a user-mode application involved. All of
those things run at different rates, and at least one of them expects to
be running in real time. You have to be very careful to ensure that
buffers don’t run dry, and that they don’t grow in size infinitely if
there is a slight clock mismatch.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.