[wdmaudiodev] Re: WDM Audio Subdevice registration and unregistration

  • From: Matt Gonzalez <matt@xxxxxxxxxxxxx>
  • To: wdmaudiodev@xxxxxxxxxxxxx
  • Date: Thu, 04 Sep 2008 13:43:32 -0700

Here is what I did. It was a lot of trouble; you have to keep around a lot of information that the sample driver code doesn't bother to store. I ended up rewriting from scratch all of the miniport creation and destruction code.


This code unregisters a playback-only miniport and the associated topology miniport. Note the call to AddRef; calling UnregisterSubdevice decrements the reference count and you need to keep the pointers to call UnregisterPhysicalConnection.

This works pretty well, even though it was a hassle.

You also want to make sure that when you create your miniports, you give them a unique name. For example, say you want to create and miniport that is only 44.1 kHz; I would call it "wave-44". Then, if you want to unregistered that one and create one that only runs at 48 kHz, call it "wave-48". Vista doesn't like it if you destroy a miniport and then re-create it with the same name; often, the re-created one simply won't show up in the Sound control panel. Even if it does appear, it will use the cached format information in the registry rather than that provided by your driver.

Finally, Vista service pack 1 seems to work much better with all this.

Hope that helps,

Matt

#pragma paged
NTSTATUS MiniMgr::UnregisterMini(IPort *port)
{
   IUnregisterSubdevice *us;
   NTSTATUS status;

   passivelvl;

   status = port->QueryInterface(IID_IUnregisterSubdevice,(PVOID *)&us);
   if (!NT_SUCCESS(status))
{ dout(dbg_print,("----failed to qi IID_IUnregisterSubdevice for port"));
       return status;
   }

   status = us->UnregisterSubdevice( _Monkey->GetFdo(), port);
   us->Release();
   if (!NT_SUCCESS(status))
   {
       dout(dbg_print,("----failed to unregister miniport"));
   }

   return status;
}

#pragma paged
NTSTATUS MiniMgr::DestroyPlayback(DWORD samplerate,int iFirstPlayPipe)
{
   NTSTATUS status;
   rtmini *wave,*next;
   CMinTopo *topo;

   passivelvl;

   //
   // Unregister playback & topo miniport pairs
   //
  wave = _PlaybackMinis;
   _PlaybackMinis = NULL;
   while (wave != NULL)
   {
       next = wave->_next;

       if (iFirstPlayPipe <= wave->_pipe)
       {
           //
           // Release wave and topo minis
           //
           topo = wave->_topo;
           if (topo != NULL)
           {
topo->AddRef(); // Calling UnregisterSubdevice decrements the reference count
               status = UnregisterMini( topo->m_PortTopo );
               if (!NT_SUCCESS(status))
               {
                   topo->Release();
                   return status;
               }
           }

wave->AddRef(); // Calling UnregisterSubdevice decrements the reference count
           status = UnregisterMini( wave->Port );
           if (!NT_SUCCESS(status))
           {
               wave->Release();
               return status;
           }

status = UnregisterPhysicalConnection(wave->Port,topo->m_PortTopo);

           if (topo)
               topo->Release();
           wave->Release();

           if (!NT_SUCCESS(status))
               return status;
       }
       else
       {
           //
           // Add it back to the list
           //
           wave->_next = _PlaybackMinis;
           _PlaybackMinis = wave;
       }

       wave = next;
   }

   return STATUS_SUCCESS;
}
Uwe Kirst wrote:
The purpose is obvious. I want to do what everyone wants: to change the samplerate within vista. I did it already but the prise was that I had to unload the whole driver, which takes very long (some minutes or so, depending on the number of subdevices). During the unload of the driver the subdevices are unregistered automatically, so no problem here. I had to add nothing to my driver for the unregistration. Ioctls are no problem for me, I want to try the unregistration by ioclt, but dont know how to start. Does anyone have some sample source code (I mean an examples howto simply unregister a single subdevice)?
The model is WaveCyc, but I dont think that makes a difference.

thanks
/Uwe

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

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: