[wdmaudiodev] Re: Dynamic format negotiation on Windows 7

  • From: K93157 <k93157@xxxxxxxxx>
  • To: wdmaudiodev@xxxxxxxxxxxxx
  • Date: Wed, 10 Feb 2010 17:11:20 -0800 (PST)

Hi Cheng.

Thank you very much for very useful information. I have implemented the below 
changes. Now I am able to send event (GenerateEventList) successfully and also 
supporting PCPROPERTY_ITEM_FLAG_GET.

Audio Stack seems to call my driver's handler with 
KSPROPERTY_PIN_PROPOSEDDATAFORMAT and Get option. My driver is returning new 
capabilities (new sample rate and bits per sample). However windows is still 
using old sample rate and bits per sample and control panel still shows old 
sample rate, bits as the default values

I am at loss on what is going on.

Please let me know if I am missing anything

Kishore



----- Original Message ----
From: Cheng-mean Liu (SOCCER) <soccerl@xxxxxxxxxxxxx>
To: "wdmaudiodev@xxxxxxxxxxxxx" <wdmaudiodev@xxxxxxxxxxxxx>
Sent: Wed, February 10, 2010 10:57:11 AM
Subject: [wdmaudiodev] Re: Dynamic format negotiation on Windows 7

Hi Uwe:

The new PCPROPERTY_ITEM_FLAG_GET was also added into Win7 for the drivers to 
propose preferred device format to be set as default. As part of the whitepaper 
I mentioned earlier, here is the section related to this.  

".., but the old format was not removed automatically." I am not seeing this 
behavior in the implementation in our HD Audio Class driver, could you double 
check to see if the old format is not one of supported formats reported after 
the dynamic format is triggered.


Thanks

Cheng-mean 


KSProperty:Updated KSPROPERTY_PIN_PROPOSEDDATAFORMAT Property
This is a KS property that has been supported since Vista. However in Vista, 
only the PCPROPERTY_ITEM_FLAG_SET flag was supported for querying whether a 
format is supported by a driver. In Windows 7,  Support for the 
PCPROPERTY_ITEM_FLAG_GET request type was added to 
KSPROPERTY_PIN_PROPOSEDDATAFORMAT in Windows 7. for drivers to report their 
preference for the default device format settings of their devices.  The 
Windows 7 audio stack will sends KSPROPERTY_PIN_PROPOSEDDATAFORMAT with the 
PCPROPERTY_ITEM_FLAG_GET flag set to query a driver for its preferred device 
default format. 
KSPROPERTY_PIN_PROPOSEDDATAFORMAT This is a KS property that has been supported 
since Vista. However in Vista, only the PCPROPERTY_ITEM_FLAG_SET flag was 
supported for querying whether a particular format is supported by a driver. 

KSPROPERTY_PIN_PROPOSEDDATAFORMATThis  is a property on the Wave filter pin. 
For more details, please see the KSPROPERTY_PIN_PROPOSEDDATAFORMAT reference 
page on MSDN.
The following sample code shows how you can update your miniport driver code to 
handle the PCPROPERTY_ITEM_FLAG_GET flag.
http://msdn.microsoft.com/en-us/library/ms808355.aspx
Sample code:
NTSTATUS CMiniportHelper::PropertyHandlerPinProposeFormat(__inout 
PPCPROPERTY_REQUEST _pPropReq)
{
...
  //
  // command basic support handling
  //
  if (_pPropReq->Verb & KSPROPERTY_TYPE_BASICSUPPORT)
  {
    // Validate buffer size
    if (!_pPropReq->ValueSize)
    {
      // ValueSize buffer too small
      _pPropReq->ValueSize = sizeof(ULONG);
      SET_STATUS_AND_JUMP(STATUS_BUFFER_OVERFLOW, exit);
    }
    else if (_pPropReq->ValueSize < sizeof (ULONG))
    {
      SET_STATUS_AND_JUMP(STATUS_BUFFER_TOO_SMALL,exit);
    }
    else
    { 
      // we have at least a ulong to work with so fill in access flags
      ULONG *accessFlags = static_cast<ULONG*>(_pPropReq->Value);
      *accessFlags = KSPROPERTY_TYPE_BASICSUPPORT | KSPROPERTY_TYPE_SET | 
KSPROPERTY_TYPE_GET;
      _pPropReq->ValueSize = sizeof(ULONG);
      SET_STATUS_AND_JUMP(STATUS_SUCCESS, exit);
    } 
  }
  else if (_pPropReq->Verb & KSPROPERTY_TYPE_SET)
  {
    ULONG cbMinSize = sizeof(KSDATAFORMAT_WAVEFORMATEX);

...
    KSDATAFORMAT_WAVEFORMATEX *pKsFormat = 
(KSDATAFORMAT_WAVEFORMATEX*)_pPropReq->Value;

...
  // replace with your own format checking routine here.
    status = pDataPin->IsFormatSupported(&pKsFormat->WaveFormatEx); 
..
  }
  else if (_pPropReq->Verb & KSPROPERTY_TYPE_GET)
  {
    ULONG cbMinSize = sizeof(KSDATAFORMAT) + sizeof(WAVEFORMATEXTENSIBLE);

    ...    
    // Fill in the KSDATAFORMAT
    KSDATAFORMAT *pKsFormat = static_cast<KSDATAFORMAT*>(_pPropReq->Value);
    pKsFormat->FormatSize = sizeof(KSDATAFORMAT) + sizeof(WAVEFORMATEXTENSIBLE);
    pKsFormat->Flags = 0;
    pKsFormat->Reserved = 0;
    pKsFormat->SampleSize = 0;
    pKsFormat->MajorFormat = KSDATAFORMAT_TYPE_AUDIO;
    pKsFormat->SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
    pKsFormat->Specifier = KSDATAFORMAT_SPECIFIER_WAVEFORMATEX;

    // Fill in the Waveformat Extensible with preferred format parameters
    WAVEFORMATEXTENSIBLE *pWfx = 
reinterpret_cast<WAVEFORMATEXTENSIBLE*>(pKsFormat + 1);
    pWfx->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
    pWfx->Format.nChannels = static_cast<WORD>(numChannels);
    pWfx->Format.nSamplesPerSec = sampleRate;
    pWfx->Format.nBlockAlign = static_cast<WORD>(numChannels * (containerSize / 
8));
    pWfx->Format.nAvgBytesPerSec = sampleRate * pWfx->Format.nBlockAlign;
    pWfx->Format.wBitsPerSample = static_cast<WORD>(containerSize);
    pWfx->Format.cbSize = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX);
    pWfx->SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
    pWfx->Samples.wValidBitsPerSample = static_cast<WORD>(bitDepth);
    pWfx->dwChannelMask = channelMask;    
  }
  else
  {
    ...
  }
  ...  

exit:
  return status;
}    

-----Original Message-----
From: wdmaudiodev-bounce@xxxxxxxxxxxxx 
[mailto:wdmaudiodev-bounce@xxxxxxxxxxxxx] On Behalf Of uwekirst
Sent: Wednesday, February 10, 2010 10:47 AM
To: wdmaudiodev@xxxxxxxxxxxxx
Subject: [wdmaudiodev] Re: Dynamic format negotiation on Windows 7

Hi Chen-mean Liu,

I have also tried to implement dynamic Format changes to my driver (it's 
wavecyclic though).
I wasn't 100% sucessful.
The basic issue was that after changing the format, the new format 
appeared in the ms win7 audio control panel, but the old format was not 
removed automatically.
The old one was still selected.
If I tried to test the two formats (old and new) it turned out that the 
old one does not work, but the new one works as expected.
Because there seem to be still user interaction necessary (changing the 
selection from old to new format) I feel that this feature is not usefull.
Any ideas what am I missing?

Thanks,
/Uwe

Cheng-mean Liu (SOCCER) schrieb:
> Hi Kishore:
>
>  This is a whitepaper on " Windows 7 Changes Related to Audio Drivers", it 
>has a section called "Dynamic Format Change Support", that has instructions on 
>how to do it.
> This whitepaper is in the final stage of getting published to WHDC site.
>
> Here is the information I cut from the current state of this paper. Let me 
> know if you have any question in implementing this feature.
>  

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

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/


      

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

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: