Exemplo n.º 1
0
// returns format id in style of WAVEFORMATEX wFormatTag, if it possible
bool FormatDetect(const WAVEFORMATEX* format, WORD* id)
{
	if (format->wFormatTag == WAVE_FORMAT_EXTENSIBLE)
	{
		const WAVEFORMATEXTENSIBLE *ext = (const WAVEFORMATEXTENSIBLE*)format;
		if (IS_VALID_WAVEFORMATEX_GUID(&ext->SubFormat))
		{
			*id = EXTRACT_WAVEFORMATEX_ID(&ext->SubFormat);
			return true;
		}
		return false;
	}
	*id = format->wFormatTag;
	return true;
}
Exemplo n.º 2
0
//=============================================================================
NTSTATUS                    
CMiniportWaveCyclic::ValidateFormat
(
    IN  ULONG               nPin,
    IN  PKSDATAFORMAT       pDataFormat 
)
/*++

Routine Description:

  Validates that the given dataformat is valid. This overwrites BaseWave's
  ValidateFormat and includes checks for AC3 format.

Arguments:

  pDataFormat - The dataformat for validation.

Return Value:

  NT status code.

--*/
{
    PAGED_CODE();

    DPF_ENTER(("[CMiniportWaveCyclic::ValidateFormat]"));

    NTSTATUS        ntStatus = STATUS_INVALID_PARAMETER;
    PWAVEFORMATEX   pwfx;

    pwfx = GetWaveFormatEx(pDataFormat);
    if (pwfx)
    {
        if (IS_VALID_WAVEFORMATEX_GUID(&pDataFormat->SubFormat))
        {
            USHORT wfxID = EXTRACT_WAVEFORMATEX_ID(&pDataFormat->SubFormat);

            if ((wfxID == WAVE_FORMAT_PCM) ||
                ((wfxID == WAVE_FORMAT_DOLBY_AC3_SPDIF) &&
                ((nPin == KSPIN_WAVE_SPDIF_CAPTURE_HOST) || (nPin == KSPIN_WAVE_SPDIF_RENDER_HOST))))
            {
                if
                (
                    (pDataFormat->FormatSize == sizeof(KSDATAFORMAT_WAVEFORMATEX)) &&
                    (pwfx->cbSize == 0)                              &&
                    (pwfx->nChannels <= MAX_CHANNELS )           &&
                    (pwfx->wBitsPerSample >= MIN_BITS_PER_SAMPLE)&&
                    (pwfx->wBitsPerSample <= MAX_BITS_PER_SAMPLE)&&
                    (pwfx->nSamplesPerSec >= MIN_SAMPLE_RATE)    &&
                    (pwfx->nSamplesPerSec <= MAX_SAMPLE_RATE)
                )
                {
                    ntStatus = STATUS_SUCCESS;
                }
                else
                {
                    DPF(D_TERSE, ("Invalid format"));
                }
            }
            else
            {
                DPF(D_TERSE, ("Invalid format tag"));
            }
        }
        else
        {
            DPF(D_TERSE, ("Invalid pDataFormat->SubFormat!") );
        }
    }

    return ntStatus;
} // ValidateFormat