audio/sysvad/APO/SwapAPO/swapapomfx.cpp
STDMETHODIMP CSwapAPOMFX::IsOutputFormatSupported
(
    IAudioMediaType *pInputFormat, 
    IAudioMediaType *pRequestedOutputFormat, 
    IAudioMediaType **ppSupportedOutputFormat
)
{
    ASSERT_NONREALTIME();
    bool formatChanged = false;
    HRESULT hResult;
    UNCOMPRESSEDAUDIOFORMAT uncompOutputFormat;
    IAudioMediaType *recommendedFormat = NULL;

    IF_TRUE_ACTION_JUMP((NULL == pRequestedOutputFormat) || (NULL == ppSupportedOutputFormat), hResult = E_POINTER, Exit);
    *ppSupportedOutputFormat = NULL;

    // Initial comparison to make sure the requested format is valid and consistent with the input
    // format. Because of the APO flags specified during creation, the samples per frame value will
    // not be validated.
    hResult = IsFormatTypeSupported(pInputFormat, pRequestedOutputFormat, &recommendedFormat, true);
    IF_FAILED_JUMP(hResult, Exit);

    // Check to see if a custom format from the APO was used.
    if (S_FALSE == hResult)
    {
        hResult = CheckCustomFormats(pRequestedOutputFormat);

        // If the output format is changed, make sure we track it for our return code.
        if (S_FALSE == hResult)
        {
            formatChanged = true;
        }
    }

    // now retrieve the format that IsFormatTypeSupported decided on, building upon that by adding
    // our channel count constraint.
    hResult = recommendedFormat->GetUncompressedAudioFormat(&uncompOutputFormat);
    IF_FAILED_JUMP(hResult, Exit);

    // If the requested format exactly matched our requirements,
    // just return it.
    if (!formatChanged)
    {
        *ppSupportedOutputFormat = pRequestedOutputFormat;
        (*ppSupportedOutputFormat)->AddRef();
        hResult = S_OK;
    }
    else // we're proposing something different, copy it and return S_FALSE
    {
        hResult = CreateAudioMediaTypeFromUncompressedAudioFormat(&uncompOutputFormat, ppSupportedOutputFormat);
        IF_FAILED_JUMP(hResult, Exit);
        hResult = S_FALSE;
    }

Exit:
    if (recommendedFormat)
    {
        recommendedFormat->Release();
    }

    return hResult;
}
//-------------------------------------------------------------------------
// Description:
//
//  Implementation of IAudioProcessingObject::IsOutputFormatSupported
//
// Parameters:
//
//      pInputFormat - [in] A pointer to an IAudioMediaType interface. This parameter indicates the output format. This parameter must be set to NULL to indicate that the output format can be any type
//      pRequestedOutputFormat - [in] A pointer to an IAudioMediaType interface. This parameter indicates the output format that is to be verified
//      ppSupportedOutputFormat - [in] This parameter indicates the supported output format that is closest to the format to be verified
//
// Return values:
//
//      S_OK                            Success
//      S_FALSE                         The format of Input/output format pair is not supported. The ppSupportedOutPutFormat parameter returns a suggested new format
//      APOERR_FORMAT_NOT_SUPPORTED     The format is not supported. The value of ppSupportedOutputFormat does not change. 
//      E_POINTER                       Null pointer passed
//
// Remarks:
//





[in] A pointer to an IAudioMediaType interface. This parameter indicates the output format. This parameter must be set to NULL to indicate that the output format can be any type
pRequestedOutputFormat - [in] A pointer to an IAudioMediaType interface. This parameter indicates the output format that is to be verified
ppSupportedOutputFormat - [in] This parameter indicates the supported output format that is closest to the format to be verified

Return values.

S_OK                            Success
S_FALSE                         The format of Input/output format pair is not supported. The ppSupportedOutPutFormat parameter returns a suggested new format
APOERR_FORMAT_NOT_SUPPORTED     The format is not supported. The value of ppSupportedOutputFormat does not change.
E_POINTER                       Null pointer passed


[ in ] A pointer to an IAudioMediaType interface . This parameter indicates the output format . This parameter must be set to NULL to indicate that the output format can be any type pRequestedOutputFormat - [ in ] A pointer to an IAudioMediaType interface . This parameter indicates the output format that is to be verified ppSupportedOutputFormat - [ in ] This parameter indicates the supported output format that is closest to the format to be verified Return values . S_OK Success S_FALSE The format of Input / output format pair is not supported . The ppSupportedOutPutFormat parameter returns a suggested new format APOERR_FORMAT_NOT_SUPPORTED The format is not supported . The value of ppSupportedOutputFormat does not change . E_POINTER Null pointer passed
STDMETHODIMP CSwapAPOMFX::IsOutputFormatSupported
(
    IAudioMediaType *pInputFormat, 
    IAudioMediaType *pRequestedOutputFormat, 
    IAudioMediaType **ppSupportedOutputFormat
)
{
    ASSERT_NONREALTIME();
    bool formatChanged = false;
    HRESULT hResult;
    UNCOMPRESSEDAUDIOFORMAT uncompOutputFormat;
    IAudioMediaType *recommendedFormat = NULL;
    IF_TRUE_ACTION_JUMP((NULL == pRequestedOutputFormat) || (NULL == ppSupportedOutputFormat), hResult = E_POINTER, Exit);
    *ppSupportedOutputFormat = NULL;
    hResult = IsFormatTypeSupported(pInputFormat, pRequestedOutputFormat, &recommendedFormat, true);
    IF_FAILED_JUMP(hResult, Exit);
    if (S_FALSE == hResult)
    {
        hResult = CheckCustomFormats(pRequestedOutputFormat);
        if (S_FALSE == hResult)
        {
            formatChanged = true;
        }
    }
    hResult = recommendedFormat->GetUncompressedAudioFormat(&uncompOutputFormat);
    IF_FAILED_JUMP(hResult, Exit);
    if (!formatChanged)
    {
        *ppSupportedOutputFormat = pRequestedOutputFormat;
        (*ppSupportedOutputFormat)->AddRef();
        hResult = S_OK;
    }
    else 
    {
        hResult = CreateAudioMediaTypeFromUncompressedAudioFormat(&uncompOutputFormat, ppSupportedOutputFormat);
        IF_FAILED_JUMP(hResult, Exit);
        hResult = S_FALSE;
    }
Exit:
    if (recommendedFormat)
    {
        recommendedFormat->Release();
    }
    return hResult;
}
STDMETHODIMP CSwapAPOMFX :: IsOutputFormatSupported ( IAudioMediaType * pInputFormat , IAudioMediaType * pRequestedOutputFormat , IAudioMediaType * * ppSupportedOutputFormat ) { ASSERT_NONREALTIME ( ) ; bool formatChanged = false ; HRESULT hResult ; UNCOMPRESSEDAUDIOFORMAT uncompOutputFormat ; IAudioMediaType * recommendedFormat = NULL ; IF_TRUE_ACTION_JUMP ( ( NULL == pRequestedOutputFormat ) || ( NULL == ppSupportedOutputFormat ) , hResult = E_POINTER , Exit ) ; * ppSupportedOutputFormat = NULL ; hResult = IsFormatTypeSupported ( pInputFormat , pRequestedOutputFormat , & recommendedFormat , true ) ; IF_FAILED_JUMP ( hResult , Exit ) ; if ( S_FALSE == hResult ) { hResult = CheckCustomFormats ( pRequestedOutputFormat ) ; if ( S_FALSE == hResult ) { formatChanged = true ; } } hResult = recommendedFormat -> GetUncompressedAudioFormat ( & uncompOutputFormat ) ; IF_FAILED_JUMP ( hResult , Exit ) ; if ( ! formatChanged ) { * ppSupportedOutputFormat = pRequestedOutputFormat ; ( * ppSupportedOutputFormat ) -> AddRef ( ) ; hResult = S_OK ; } else { hResult = CreateAudioMediaTypeFromUncompressedAudioFormat ( & uncompOutputFormat , ppSupportedOutputFormat ) ; IF_FAILED_JUMP ( hResult , Exit ) ; hResult = S_FALSE ; } Exit : if ( recommendedFormat ) { recommendedFormat -> Release ( ) ; } return hResult ; }
Description:
Implementation of IAudioProcessingObject::IsOutputFormatSupported
Description : Implementation of IAudioProcessingObject :: IsOutputFormatSupported
// Initial comparison to make sure the requested format is valid and consistent with the input
 // format. Because of the APO flags specified during creation, the samples per frame value will
 // not be validated.
 // Check to see if a custom format from the APO was used.
 // If the output format is changed, make sure we track it for our return code.
 // now retrieve the format that IsFormatTypeSupported decided on, building upon that by adding
 // our channel count constraint.
 // If the requested format exactly matched our requirements,
 // just return it.
 // we're proposing something different, copy it and return S_FALSE
