Thinking Kernel Mode

ExAllocatePoolWithTag(KMScrapPad, sizeof(KMSCRAP), TAG_TKM);

  Home  |   Contact  |   Syndication    |   Login
  15 Posts | 0 Stories | 43 Comments | 26 Trackbacks

News

Sreejith S

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

Archives

Blogs I Read

Links

New Page 1

{ Not invented here }

Unless I scribble this down somewhere, I will forget. So let me dump my memory . . 

Kernel Streaming is a fairly complicated topic. And to study this, the available resources are the DDK help documentation and the samples. AFAIK, there are no books written on this topic. And what is present online is also meager. 

The Streaming Devices (Video & Audio) subsection of the DDK help, has everything documented.

Now,  in order to emulate a virtual audio hardware, we have to write an Audio Miniport Adapter driver. The MSAVD sample source code can be used for this purpose.

WHDC Audio Device Technologies for Windows [http://www.microsoft.com/whdc/device/audio/default.mspx] 

Getting Started with WDM Audio Drivers [http://www.microsoft.com/whdc/device/audio/wdmaud-drv.mspx]

This is how the audio device stack will look like. 


System Audio Device (SysAudio.sys)
Kernel Mixer (Kmix.sys)
Streaming Class Driver (stream.sys) Port Class Driver (PortCls.sys)
USB Audio (USBAudio.sys)
USB Device  Adapter Driver
USB Controller Audio Device

The Adapter Driver is what we write and for a virtual audio device it will be a modified MSAVD driver. 

Modifying the MSAVD Driver to make your own virtual audio device.

In Kernel Streaming, every component is a Filter. Filters have input (sink) and output (source) pins. Data enters a filter through its input pin and leaves through the output pin. Every filter has a purpose :  to process the data flowing through them.

As an audio device (virtual or real), your hardware will have a range of audio data parameters which can be accepted. Or in other words, only data complying to a specific format and parameter range can be accepted by the input pins. This is called the property of the pin. 

Specify those ranges in the PinDataRangesStream static variable of the MSAVD source code. 

Now, in the WaveCyclic miniport there are two methods named CopyTo and CopyFrom for copying audio data to and from the audio device's  memory (DMA). Add code to those function to implement a virtual write and read and the minimal audio driver code is complete.

 

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati
posted on Wednesday, October 26, 2005 9:41 AM

Feedback

# re: Writing a virtual audio driver 11/16/2005 11:36 PM Nadya

Where can I found the MSAVD sample source code?

Thank you in advance

# re: Writing a virtual audio driver 11/20/2005 8:06 AM Sreejith S

You find it among the DDK samples

$DDK_INSTALL_DIR$\src\wdm\audio\msvad

# re: Writing a virtual audio driver 11/21/2005 3:10 AM Nadya
Hi Sreejith S

Thanks for the information.
I'm beginner in the C++ and driver's development.
What is the meaning of "miniport"? Can you tell me about its concept?



# re: Writing a virtual audio driver 12/2/2005 7:18 PM Sreejith

See
http://www.cmkrnl.com/faq04.html


# re: Writing a virtual audio driver 3/6/2006 11:55 AM Krishna Reddy
Hi
I would like to write virtual audio which can send/recieved PCM data from network. How can make MSVAD to use sockets. If i use #include <winsock2.h> in basedma.cpp i am getting lots of erros.

Thanks
Krishna

# re: Writing a virtual audio driver 3/6/2006 3:38 PM Sreejith S

See "Remoting Your Toaster Using Kernel-Mode TCP/IP" at WD-3

http://www.wd-3.com/archive/RemoteToaster.htm

Since wd3 domain has expired, see google's cache



# re: Writing a virtual audio driver 3/14/2006 1:35 PM Simhi
Hi,
1. Is reboot required after installation? If so, is there any alternative to write a virtual audio driver that will not require reboot ?
2. Will this driver work on Win2000 & XP ?
Thanks,
Simhi

# re: Writing a virtual audio driver 3/14/2006 3:25 PM Sreejith S
1. No, reboot is not required after installation.

2. Yes, will work on 2K and XP

# re: Writing a virtual audio driver 3/14/2006 4:08 PM simhi
Hi,
Thanks. I have few follow-up questions:
1. What is the best way for this driver to pass data from/to user space application ?
2. Could IOCTL be used ?
3. Shoud I use direct or buffered IO ?
Thanks,
Simhi

# re: Writing a virtual audio driver 3/15/2006 5:42 PM Sreejith S
Yes, IOCTLs are the way to go.

Direct IO is best suited if you are handling large amounts of data (more than a page).

# re: Writing a virtual audio driver 3/16/2006 8:25 AM Zhaofeng
Hi,
I'm doing something on msvad now.
I have 2 questions to ask you.
1. Does msvad(simple) support kernel streaming?
2. If I want to use AMR codec, how to add? Can I use msvad(simple)?

# re: Writing a virtual audio driver 4/2/2006 9:44 PM richard
Exactly which DDK has the MSVAD set?

# re: Writing a virtual audio driver 4/8/2006 7:47 AM Sreejith S
XP DDK

# re: Writing a virtual audio driver 5/3/2006 8:35 PM Hadong
Hi, Sreejith
I'm now working on the MSVAD(Simple). I have a question about it.

1. You said "Yes, IOCTLs are the way to go.". But how can I get the handle of the MSVAD(Simple)?
2. I tried to use IoRegisterDeviceInterface() in AddDevice() of MSVAD(Simple), and then in my user mode application I use SetupDiGetDeviceInterfaceDetail() and CreateFile() to get the handle of the MSVAD device. Debugging in VC6++, it seems that I can get the handle of the MSVAD(Simple), but when I send IOCTL code using DeviceIoControl(), the call fails. Do you have any idea about this?

Thanks,

# re: Writing a virtual audio driver 5/8/2006 6:39 AM Alex
Hi Sreejith S ,

would you send MSAVD sample source code to me,
i can't find it in win2k ntddk.
my email is lzcx_cn@yahoo.com.cn

TIA

# re: Writing a virtual audio driver 6/20/2006 10:57 AM xing_xin@yahoo.com
Hi,

You may find it in WinDDK.
After installation at <drv>:\WinDDK\XXXX.XXXX\src\wdm\audio\msvad.

Xin

# re: Writing a virtual audio driver 7/20/2006 5:15 AM weiji zheng
hi hadong

have you resolved your questions? that is, how to implement IRP_MJ_CREATE, IRP_MJ_CLOSE, IRP_MJ_DEVICE_CONTROL in MSVAD?
actaully, I encounter the same problem, would you please give me some hints?
thanks.

# re: Writing a virtual audio driver 11/28/2006 1:06 PM Duc
Hi,
I want to receive data from Microphone using MSVAD but it seem MSVAD it design for render purpose only, not for capture.
I insert code into CopyFrom function and trace all the data but it alway zero.
Anybody have expierence in this issue ?

Duc

# Virtal Audio Driver Volume Control 1/19/2007 5:54 PM urukhai
I have virtual audio driver that just sends data from render stream to capture stream.
It has Topology with MUTE and VOLUME nodes on render line and appropriate property handlers for them? How can I make sndvol32.exe to change volume level without multiplying amplitudes in render stream on a volume coefficient? Now it only shows volume level changer, but it doesn't change volume level actually.

# re: Writing a virtual audio driver 1/23/2007 10:00 PM fab
I have problem with on my VAD with the ISR precision. The Timer is not precise enough so my audio sample rate is a bit wrong. It seems that even if I try to change the timer, the system refuses to be trigged (pMiniport->m_Port->Notify(pMiniport->m_ServiceGroup);)
if at least 10 ms passed since the last call. Then the trigger will be too late.
Is there a way to get a more precise timer or to force the system to accept triggers a little bit less than 10 ms ?

# re: Writing a virtual audio driver 2/7/2007 10:57 PM mikej
Hi:

I built msvad(simple) from the DDK with no modification. It work to render/play but it will not allow for capture.

You said to add code to "WaveCyclic miniport there are two methods named CopyTo and CopyFrom"; what code are you talking about and will adding this code allow me to capture using msvad

# re: Writing a virtual audio driver 3/1/2007 11:16 PM hariharan
What does mavad(simple)exactly do?

My application demands a virtual driver where i need to process the audio data.

mic-->sound card-->virtual driver-->rocessing-->Virtual driver-->Audio Application(ex gtalk).

I installed SIMPLE and changed the sound setting is control panel.

IN device is Sound card driver
OUT device is MSVAD driver.

In the audio application(ex cool edit) I changed the

In device to MSVAD driver.
Out device to Sound card driver.

When I play a audio file in Media player and record in cool edit . I get junk data recorded not the file what I am playing in media player.

Is this possible with SIMPLE .

Please explain me how to modify the SIMPLE to do this type of task.I am electrical guy and totally ignorant about whats happening in these drivers.

Any help is appreciated.

Hariharan


# re: Writing a virtual audio driver 7/30/2007 12:21 AM Nick
Interesting topic. I need to write a driver, also, but not an audio one. I am interested in the most efficient way of allocating memory to be used just by the driver. I need about 2 or 3 pages to be allocate at DriverEntry, and, when a certain event occurs, chunks of 8 pages. I've searched the net about this topic, but had no luck.

Thanks!
Nick

# re: Writing a virtual audio driver 12/8/2007 2:00 AM kisine
hi, all

how can i send stream data form MSVAD to real sound cards??

how can i make app for control MSVAD??

thanx

# re: Writing a virtual audio driver 12/14/2007 7:40 PM Bernt Ronningsbakk
I need a virtual audio rendering driver.

Has ayone made msvad actually work here?


thanks,
Bx

# re: ioctl for the msvad 3/27/2008 3:45 PM sreejith
Please see
http://msdn2.microsoft.com/en-us/library/ms793658.aspx

When you are overwriting any of the DriverObject's dispatch function pointers, within your function you must forward the IRPs which you do not handle using PcDispatchIrp.

# re: Writing a virtual audio driver 5/18/2008 9:27 PM Maverick
I need to write a virtual MIC driver. I have som HW that generates sound data and I what to write a Mic driver that e.g. Skype can use to receive this data. Is a minidriver/msvad the right way to go and does anybody know any examples I can use ?

# re: Writing a virtual audio driver 10/15/2008 7:41 PM swapnil
I am creating a virtual audio device driver based on MSVAD. I am able to hear the sound. Actually the problem is when I am trying to play audio, live on other stream instead of writing it on
file. Some delay is getting introduced in render stream, which does
not happen when written into file. Quality of audio in live streaming
is little low as compared when written into file. I guess it might be
due to some read/write pointers issue managed by port class. So can
you please suggest me any reason for this ? Is there change required in FrameSize formula or Interval for DPC?

Any suggestion regarding this would really helpful to me.

Thanks in advance.

# re: Writing a virtual audio driver 10/15/2008 7:42 PM swapnil
I am trying another way of VAD implementation. I have implemented WavePCI in my driver. My mapping calls of GetMapping () and ReleaseMapping () are working fine. Following are thing which I have done.

1. I created DmaChannel through NewMasterDmaChannel(), this works fine gives DmaChannel object. Passed as out parameter to NewStream ().
2. Allocated tables through AllocateCommonBuffer() call.
3. Created a timer object , DPC object which calls DPC after every interval(e.g. 10ms) and wrote a DPC in which I am calling Notify() of PortCls.
4. Methods of WavePCI interface are implemented one of them is Service () which is invoked after above Notfiy() call by PortCls.
5. This Service() gives call to ReleaseMapping()/GetMapping() methods saves their out parameters in a table as ac'97 does.

This is implemented as per MSDN documentation. Now the Driver runs continuously and consumes so many CPU cycles, the system slows down. But if I only obtain possible mappings in first GetMapping () call that is no MappingAvailable () then it runs smoothly. But still I do not get any audio only noise is produced. And one more thing I do get some value in VirtAddr pointer of GetMapping () .
I also tried with common table between Capture / Renderer streams, but that didn't help. With IDmaChannel channel implementation also I tried, and passed casted stream object through Newstream(), but that also didn't helped.

Is there something else also that in WavePCI it needs to be implemented. If anyone has any suggestion about then please reply ?

# re: Writing a virtual audio driver 10/23/2008 12:14 AM Dan
I also encountered the same problem with MSVAD as swapnil did. when I send the audio through RTP I find out that not enough PCM samples arrive to the CopyTo function, and as a result after a few seconds I have no PCM buffer left to and I cannot generate new packets.
Any idea ?



# re: Writing a virtual audio driver 12/14/2008 5:44 PM swapnil
Hi,
Is Roman Divacky's driver completed ? Are you here ? Can we get his email - id ????

# re: Writing a virtual audio driver 3/24/2010 12:03 PM ben
See this virtual sound driver:
http://www.shiningmorning.com/VirtualAudioStreaming/index.html

# re: Writing a virtual audio driver 7/19/2010 3:58 PM tobias
Hi

Im in need of a virtual audio driver that works with Windows Vista and Windows 7 (with source code). Would anyone sell it to me?

Thanks Tobias

gtobias
att
gmx.net

# re: Writing a virtual audio driver 9/16/2010 7:44 AM rajesh s. butala
hello, i need to write audio driver which wil work separately for each individual user session
please help me for the same.

# re: Writing a virtual audio driver 7/10/2011 1:20 PM Brasov Hotels
In signal processing, a filter is a device or process that removes from a signal some unwanted component or feature. Filtering is a class of signal processing, the defining feature of filters being the complete or partial suppression of some aspect of the signal. Most often, this means removing some frequencies and not others in order to suppress interfering signals and reduce background noise. However, filters do not exclusively act in the frequency domain; especially in the field of image processing many other targets for filtering exist.
Cluj Hotels


# re: Writing a virtual audio driver 7/10/2011 1:25 PM Brasov Hotels
A digital filter system usually consists of an analog-to-digital converter to sample the input signal, followed by a microprocessor and some peripheral components such as memory to store data and filter coefficients etc. Finally a digital-to-analog converter to complete the output stage. Program Instructions (software) running on the microprocessor implement the digital filter by performing the necessary mathematical operations on the numbers received from the ADC. In some high performance applications, an FPGA or ASIC is used instead of a general purpose microprocessor, or a specialized DSP with specific paralleled architecture for expediting operations such as filtering.
Brasov Hotels


# re: Writing a virtual audio driver 7/10/2011 1:35 PM Timisoara Hotels
A multifunction device is a single adapter card that incorporates two or more separate functions (or subdevices). A multifunction device can contain two or more audio subdevices. It may also span device classes. A device containing audio and modem subdevices, for instance, belongs to both the media class and the modem class. A multifunction device occupies one location on its parent bus but contains more than one function. Combination printer/scanner/fax devices and modem/network cards are common multifunction devices. In a multifunction device, the individual functions are independent. This means the functions must have the following characteristics:
The functions cannot have start-order dependencies. The resource requirements for one function cannot be expressed in terms of the resources of another function (for example, function1 uses I/O port x and function2 uses port x + 200). Each function must be able to operate as a separate device, even if it is serviced by the same drivers as another function.
Timisoara Hotels

# re: Writing a virtual audio driver 7/10/2011 1:40 PM Bucharest Hotels
Additionally, the following requirements must be met so that a multifunction device can be correctly configured on an NT-based platform: Each function on the device must be enumerated. Resource requirements for each function must be communicated to the PnP manager. There must be INF files and drivers for each function. The component responsible for each of these tasks depends on the multifunction standard for the device's parent bus, the extent to which the device conforms to the standard, and the capabilities of the parent bus driver. If the device complies with the multifunction standards for its bus, your driver requirements are significantly reduced. Industry-wide multifunction standards have been defined for the PC Card and PCI buses.
Bucharest Hotels

# re: Writing a virtual audio driver 7/10/2011 1:43 PM Sibiu Hotels
If you are working with a multifunction DVD/CD-ROM device used for data storage (not for audio/video playback) on a Windows XP or later operating system, you should use the system-supplied WDM DVD class driver, which treats the device as a single logical unit. For Windows 2000 and Windows 98, you should treat the device as two logical units (so it will appear with two drive letters). If the DVD capabilities are combined with some other type of function, you should treat the device as a single logical unit and supply a class driver that implements common command sets for all the features of the device.
Sibiu Hotels

# re: Writing a virtual audio driver 7/15/2011 4:51 AM IoanaRentacar
No hardware compatibility list for Windows 7 yet, even at this late stage. Sound cards are a definite issue, especially the Asus MB ones created by Creative. The final release of Windows 7 renders even more sound cards useless. Most of the fuxes that worked with the beta releases of Windows 7 do nor work anymore. Good luck, I'm waiting for the list too.Rent A Car Timisoara

# re: Writing a virtual audio driver 7/15/2011 4:56 AM CosminaEastcomfort
Here is an actual list of what works on Windows 7 64x/32x
33-124 USB Microphone RadioShack Corporation Compatible with Windows 7
33-331 XLR to Mini USB Microphone Adapter RadioShack Corporation ----
AIM AS301 USB Audio Formosa21 Inc. Compatible with Windows 7
AMD HDMI Controller ATI Technologies, ULC Compatible with Windows 7
AMD HDMI Controller Advanced Micro Devices, Inc. Compatible with Windows 7
AS301DTS USB Audio Formosa21 Inc. Compatible with Windows 7
AS301DTS USB Audio Driver Formosa21 Inc. Compatible with Windows 7
AS302DTS Device Formosa21 Inc. Compatible with Windows 7
AS302DTS USB AUDIO Formosa21 Inc. Compatible with Windows 7
ASUS Xonar Audio Device C-Media Electronics, Inc. Compatible with Windows 7
Bucharest Apartments


# re: Writing a virtual audio driver 7/15/2011 4:56 AM CosminaEastcomfort
and:

Microsoft LifeCam Cinema Microsoft Corporation Compatible with Windows 7
Microsoft LifeCam HD-5000 Microsoft Corporation Compatible with Windows 7
Microsoft LifeCam HD-5001 Microsoft Corporation Compatible with Windows 7
Microsoft LifeCam HD-6000 for Notebooks Microsoft Corporation Compatible with Windows 7
Microsoft LifeCam NX-3000 Microsoft Corporation Compatible with Windows 7
Microsoft LifeCam NX-6000 Microsoft Corporation Compatible with Windows 7
Microsoft LifeCam Show Microsoft Corporation Compatible with Windows 7
Microsoft LifeCam VX-1000 Microsoft Corporation Compatible with Windows 7
Microsoft LifeCam VX-2000 Microsoft Corporation Compatible with Windows 7
Microsoft LifeCam VX-3000 Microsoft Corporation Compatible with Windows 7
Microsoft LifeCam VX-5000 Microsoft Corporation Compatible with Windows 7
Microsoft LifeCam VX-5500 Microsoft Corporation Compatible with Windows 7
Microsoft LifeCam VX-7000 Microsoft Corporation Compatible with Windows 7
Microsoft LifeCam VX-800 Microsoft Corporation Compatible with Windows 7
Microsoft LifeChat LX-3000 Microsoft Corporation Compatible with Windows 7
Bucharest Apartments

# re: Writing a virtual audio driver 10/10/2011 10:49 PM roger
Any example sources out there? :)

Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification: