Previous Next

Declaring Non-PCM Data Ranges

This code example shows how to declare the KSDATARANGE_AUDIO table entries for the AC3-over-S/PDIF format:

static KSDATARANGE_AUDIO PinDataRangesAC3Stream[] =
{
  {
    {
      sizeof(KSDATARANGE_AUDIO),
      0,
      0,
      0,
      STATICGUIDOF(KSDATAFORMAT_TYPE_AUDIO),
      STATICGUIDOF(KSDATAFORMAT_SUBTYPE_DOLBY_AC3_SPDIF),
      STATICGUIDOF(KSDATAFORMAT_SPECIFIER_WAVEFORMATEX)
    },
    2,     // Max number of channels.
    16,    // Minimum number of bits per sample.
    16,    // Maximum number of bits per channel.
    48000, // Minimum rate.
    48000  // Maximum rate.
  },

  // If you do not include this second data range (which is identical
  // except for the SPECIFIER_DSOUND), then your non-PCM pin is
  // not seen by DirectSound on Win98SE or Win2K, regardless 
  // of the presence of QFE/service pack or the DirectX version.
  //
  {
    {
      sizeof(KSDATARANGE_AUDIO),
      0,
      0,
      0,
      STATICGUIDOF(KSDATAFORMAT_TYPE_AUDIO),
      STATICGUIDOF(KSDATAFORMAT_SUBTYPE_DOLBY_AC3_SPDIF),
      STATICGUIDOF(KSDATAFORMAT_SPECIFIER_DSOUND)
    },
    2,     // Max number of channels.
    16,    // Minimum number of bits per sample.
    16,    // Maximum number of bits per channel.
    48000, // Minimum rate.
    48000  // Maximum rate.
  }
};

The second data-range entry in the table above is necessary to enable DirectSound to handle the non-PCM AC3-over-S/PDIF format on Windows 98 SE + QFE and Windows 2000 SP2.

For each data range that the miniport driver specifies with KSDATAFORMAT_SPECIFIER_WAVEFORMATEX, PortCls automatically adds a second data range that is specified with KSDATAFORMAT_SPECIFIER_DSOUND but is otherwise identical to the first. (You can verify this by using the KsStudio utility to view the list of data ranges.) On Windows 98 and Windows 2000, PortCls creates KSDATAFORMAT_SPECIFIER_DSOUND versions of data ranges only for KSDATAFORMAT_SUBTYPE_PCM formats because DirectSound versions before DirectSound 8 support only PCM. This limitation is removed in Windows Me, and Windows XP and later, but is not fixed in the QFE for Windows 98 or in Windows 2000 SP2. In order for a driver to support non-PCM on DirectSound on these Windows versions, it should explicitly list two data ranges for each non-PCM data format—one with KSDATAFORMAT_SPECIFIER_WAVEFORMATEX and another with KSDATAFORMAT_SPECIFIER_DSOUND.