⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wmaudiopaths.c

📁 WM9713 audio codec driver for WinCE 5.0
💻 C
📖 第 1 页 / 共 4 页
字号:
 *      micSignalL      Left channel microphone input to clear.
 *      micSignalR      Right channel microphone input to clear.
 *
 * Returns:     WMSTATUS
 *      See WMStatus.h
 *---------------------------------------------------------------------------*/
WMSTATUS WMAudioClearMicRecPaths( WM_DEVICE_HANDLE hDevice,
								  WM_AUDIO_SIGNAL micSignalL, 
								  WM_AUDIO_SIGNAL micSignalR 
								)
{
    WMSTATUS            status = WMS_UNSUPPORTED;
    const WM_CHIPDEF    *pChipDef;

    if( ( !WM_SIGNAL_IS_MIC( micSignalL ) && WM_AUDIO_IGNORE != micSignalL ) ||
		( !WM_SIGNAL_IS_MIC( micSignalR ) && WM_AUDIO_IGNORE != micSignalR ) )
    {
        status = WMS_INVALID_SIGNAL;
        WM_TRACE( hDevice,
                  ( "WMAudioClearMicRecPaths failed: %s",
                  WMStatusText( status ) ) );
        goto finish;
    }

	/* The caller does not want us to change anything */
    if( WM_AUDIO_IGNORE == micSignalL && WM_AUDIO_IGNORE == micSignalR )
	{
		status = WMS_SUCCESS;
		goto finish;
	}

    /*
     * Look up our chipdef.
     */
    pChipDef = WMGetChipDef( hDevice );

    WM_ASSERT( hDevice, NULL != pChipDef);

    if ( !pChipDef )
    {
        status = WMS_NO_SUPPORTED_DEVICE;
        goto finish;
    }
    
    if ( pChipDef->vtable.fnClearMicRecPaths)
    {
        status = pChipDef->vtable.fnClearMicRecPaths( hDevice, 
                                                      micSignalL,
                                                      micSignalR
                                                    );
    }

finish:
    return status;
}

/*-----------------------------------------------------------------------------
 * Function:    WMAudioEnableHeadphoneMixerToHPPath
 *
 * Enable/Disable the headphone mixer to output to the headphone left and right
 * outputs.
 *
 * Parameters:
 *      hDevice         handle to the device (from WMOpenDevice)
 *      enable          TRUE enables the path, FALSE disables the path.
 *
 * Returns:     WMSTATUS
 *      See WMStatus.h
 *---------------------------------------------------------------------------*/
WMSTATUS WMAudioEnableHeadphoneMixerToHPPath( WM_DEVICE_HANDLE hDevice,
                                              WM_BOOL enable
                                            )
{
    WMSTATUS status = WMS_UNSUPPORTED;

    if ( IS_WM9713_FAMILY( hDevice ) )
    {
        if ( enable )
        {
            status = WMSetField( hDevice, 
                                 WM9713_OUTPUT_SELECT, 
                                 WM9713_HPR_PGA_HPMIX | WM9713_HPL_PGA_HPMIX, 
                                 WM9713_HPR_PGA_MASK | WM9713_HPL_PGA_MASK 
                               );
            if ( WM_ERROR( status ) )
            {
                WM_TRACE( hDevice,
                          ( "WMAudioEnableHeadphoneMixerToHPPath failed to enable path: %s",
                          WMStatusText( status ) ) );
            }
        }
        else
        {
            status = WMClearField( hDevice, 
                                   WM9713_OUTPUT_SELECT, 
                                   WM9713_HPR_PGA_HPMIX | WM9713_HPL_PGA_HPMIX
                                 );
            if ( WM_ERROR( status ) )
            {
                WM_TRACE( hDevice,
                          ( "WMAudioEnableHeadphoneMixerToHPPath failed to disable path: %s",
                          WMStatusText( status ) ) );
            }
        }
    }

    return status;
}

/*-----------------------------------------------------------------------------
 * Function:    WMAudioEnableSpeakerMixerToSPKPath
 *
 * Enable/Disable the speaker mixer to output to the speaker left and right
 * outputs.
 *
 * Parameters:
 *      hDevice         handle to the device (from WMOpenDevice)
 *      enable          TRUE enables the path, FALSE disables the path.
 *
 * Returns:     WMSTATUS
 *      See WMStatus.h
 *---------------------------------------------------------------------------*/
WMSTATUS WMAudioEnableSpeakerMixerToSPKPath( WM_DEVICE_HANDLE hDevice,
                                             WM_BOOL enable
                                           )
{
    WMSTATUS status = WMS_UNSUPPORTED;

    if ( IS_WM9712_FAMILY( hDevice ) )
    {
        /*
         * There is no disable for this as we can only switch
         * between speaker mixer and headphone mixer.
         */
        if ( enable )
        {
            status = WMClearField( hDevice, 
                                   WM9712_OUT3_VOLUME, 
                                   WM9712_OUT3_SRC
                                 );
            if ( WM_ERROR( status ) )
            {
                WM_TRACE( hDevice,
                          ( "WMAudioEnableSpeakerMixerToSPKPath failed to enable path: %s",
                          WMStatusText( status ) ) );
            }
        }
    } 

    if ( IS_WM9713_FAMILY( hDevice ) )
    {
        if ( enable )
        {
            /*
             * Enable the Speaker Mixer for left and right
             */
            status = WMSetField( hDevice,
                                 WM9713_OUTPUT_SELECT,
                                 WM9713_SPKR_PGA_SPKMIX | WM9713_SPKL_PGA_SPKMIX, 
                                 WM9713_SPKR_PGA_MASK | WM9713_SPKL_PGA_MASK
                               );
            if ( WM_ERROR( status ) )
            {
                WM_TRACE( hDevice,
                          ( "WMAudioEnableSpeakerMixerToSPKPath failed to enable path: %s",
                          WMStatusText( status ) ) );
            }

        }
        else
        {
            status = WMClearField( hDevice,
                                   WM9713_OUTPUT_SELECT,
                                   WM9713_SPKR_PGA_SPKMIX | WM9713_SPKL_PGA_SPKMIX
                                 );
            if ( WM_ERROR( status ) )
            {
                WM_TRACE( hDevice,
                          ( "WMAudioEnableSpeakerMixerToSPKPath failed to disable path: %s",
                          WMStatusText( status ) ) );
            }
        }
    }

    return status;
}

/*-----------------------------------------------------------------------------
 * Function:    WMAudioEnableMonoMixerToMONOPath
 *
 * Enable/Disable the mono mixer to output to the mono output.
 *
 * Parameters:
 *      hDevice         handle to the device (from WMOpenDevice)
 *      enable          TRUE enables the path, FALSE disables the path.
 *
 * Returns:     WMSTATUS
 *      See WMStatus.h
 *---------------------------------------------------------------------------*/
WMSTATUS WMAudioEnableMonoMixerToMONOPath( WM_DEVICE_HANDLE hDevice,
                                           WM_BOOL enable
                                         )
{
    WMSTATUS status = WMS_UNSUPPORTED;

    if ( IS_WM9713_FAMILY( hDevice ) )
    {
        if ( enable )
        {
            status = WMSetField( hDevice, 
                                 WM9713_OUTPUT_SELECT, 
                                 WM9713_MONO_PGA_MONOMIX, 
                                 WM9713_MONO_PGA_MASK 
                               );
            if ( WM_ERROR( status ) )
            {
                WM_TRACE( hDevice,
                          ( "WMAudioEnableMonoMixerToMONOPath failed to enable path: %s",
                          WMStatusText( status ) ) );
            }
        }
        else
        {
            status = WMClearField( hDevice, 
                                   WM9713_OUTPUT_SELECT, 
                                   WM9713_MONO_PGA_MONOMIX
                               );
            if ( WM_ERROR( status ) )
            {
                WM_TRACE( hDevice,
                          ( "WMAudioEnableMonoMixerToMONOPath failed to disable path: %s",
                          WMStatusText( status ) ) );
            }
        }
    }

    return status;
}

static WMSTATUS private_enableMixersToOutputs( WM_DEVICE_HANDLE hDevice, 
                                               WM_BOOL          enable
                                             )
{
    WMSTATUS status = WMS_UNSUPPORTED;

    /*
     * Enable/Disable the paths from the headphone mixer to HPL/R.
     */
    status = WMAudioEnableHeadphoneMixerToHPPath( hDevice, enable );
    if ( WM_ERROR( status ) && ( status != WMS_UNSUPPORTED ) )
    {
        goto error;
    }

    /*
     * Enable/Disable the paths from the speaker mixer to SPKL/R.
     */
    status = WMAudioEnableSpeakerMixerToSPKPath( hDevice, enable );
    if ( WM_ERROR( status ) && ( status != WMS_UNSUPPORTED ) )
    {
        goto error;
    }

    /*
     * Enable/Disable the paths from the mono mixer to MONO.
     */
    status = WMAudioEnableMonoMixerToMONOPath( hDevice, enable );
    if ( WM_ERROR( status ) && ( status != WMS_UNSUPPORTED ) )
    {
        goto error;
    }

    return WMS_SUCCESS;

error:

    return status;
}

/*-----------------------------------------------------------------------------
 * Function:    WMAudioSetHeadphoneMixerToSPKPath
 *
 * Set up the headphone mixer to output to the speaker left and right
 * outputs (SPKL&SPKR).
 *
 * Parameters:
 *      hDevice         handle to the device (from WMOpenDevice)
 *
 * Returns:     WMSTATUS
 *      See WMStatus.h
 *---------------------------------------------------------------------------*/
WMSTATUS WMAudioSetHeadphoneMixerToSPKPath( WM_DEVICE_HANDLE hDevice )
{
    WMSTATUS status = WMS_UNSUPPORTED;

    if ( IS_WM9713_FAMILY( hDevice ) )
    {
        status = WMSetField( hDevice, 
                             WM9713_OUTPUT_SELECT, 
                             WM9713_SPKR_PGA_HPMIX | WM9713_SPKL_PGA_HPMIX, 
                             WM9713_SPKR_PGA_MASK | WM9713_SPKL_PGA_MASK 
                           );
        if ( WM_ERROR( status ) )
        {
            WM_TRACE( hDevice,
                      ( "WMAudioSetHeadphoneMixerToSPKPath failed: %s",
                      WMStatusText( status ) ) );
        }
    }  
    
    return status;
}

/*-----------------------------------------------------------------------------
 * Function:    WMAudioSetHeadphoneMixerToLOUTPath
 *
 * Set up the headphone mixer to output to the line out left and right
 * outputs (LOUTL&LOUTR).
 *
 * Parameters:
 *      hDevice         handle to the device (from WMOpenDevice)
 *
 * Returns:     WMSTATUS
 *      See WMStatus.h
 *---------------------------------------------------------------------------*/
WMSTATUS WMAudioSetHeadphoneMixerToLOUTPath( WM_DEVICE_HANDLE hDevice )
{
    WMSTATUS status = WMS_UNSUPPORTED;

    if ( IS_WM9712_FAMILY( hDevice ) )
    {            
        status = WMSetField( hDevice, 
                             WM9712_OUT3_VOLUME, 
                             WM9712_OUT3_SRC,
                             WM9712_OUT3_SRC
                           );
        if ( WM_ERROR( status ) )
        {
            WM_TRACE( hDevice,
                      ( "WMAudioSetHeadphoneMixerToLOUTPath failed: %s",
                      WMStatusText( status ) ) );
        }
    }   
    
    return status;
}

/*-----------------------------------------------------------------------------
 * Function:    WMAudioSetSpeakerMixerToLOUTPath
 *
 * Set up the speaker mixer to output to the line out left and right
 * outputs (LOUTL&LOUTR).
 *
 * Parameters:
 *      hDevice         handle to the device (from WMOpenDevice)
 *
 * Returns:     WMSTATUS
 *      See WMStatus.h
 *---------------------------------------------------------------------------*/
WMSTATUS WMAudioSetSpeakerMixerToLOUTPath( WM_DEVICE_HANDLE hDevice )
{
    WMSTATUS status = WMS_UNSUPPORTED;

    if ( IS_WM9712_FAMILY( hDevice ) )
    {
        status = WMClearField( hDevice, 
                               WM9712_OUT3_VOLUME, 
                               WM9712_OUT3_SRC
                             );
        if ( WM_ERROR( status ) )
        {
            WM_TRACE( hDevice,
                      ( "WMAudioSetSpeakerMixerToLOUTPath failed: %s",
                      WMStatusText( status ) ) );
        }
    } 
    
    return status;
}

/*-----------------------------------------------------------------------------
 * Function:    WMAudioEnableOutputPaths
 *
 * Enables/disables the path from the given streams DAC to all outputs.
 *
 * Parameters:
 *      hDevice         handle to the device (from WMOpenDevice)
 *      ifStream        the stream to enable/disable
 *      enable          TRUE enables the path, FALSE disables the path.
 *
 * Returns:     WMSTATUS
 *      See WMStatus.h
 *---------------------------------------------------------------------------*/
WMSTATUS WMAudioEnableOutputPaths( WM_DEVICE_HANDLE hDevice,
                                   WM_STREAM_ID     ifStream,
                                   WM_BOOL          enable
                                 )
{
    WMSTATUS        status = WMS_UNSUPPORTED;
    WM_STREAM_ID    stream = _WMAudioGetRealStream( hDevice, ifStream );

    /*
     * Check our stream.
     */
    if ( !WM_IS_OUTPUT_STREAM( stream ) )
    {
        goto finish;
    }

    switch ( stream )
    {
        case WM_STREAM_HIFI_OUT:
            status = private_EnableHiFiOutputPaths( hDevice, enable );
            break;

#if WM_VOICE
        case WM_STREAM_VOICE_OUT:
            status = private_EnableVoiceOutputPaths( hDevice, enable );
            break;
#endif /* WM_VOICE */

#if WM_MONODAC
        case WM_STREAM_MONO_OUT:
            status = private_EnableMonoOutputPaths( hDevice, enable );
            break;
#endif /* WM_MONODAC */

        default:
            /* We checked we had a valid output stream above */
            WM_ASSERT( hDevice, WM_IS_OUTPUT_STREAM( stream ) );
			goto finish;
    }

finish:

    return status;
}

/*-----------------------------------------------------------------------------
 * Function:    WMAudioEnableHiFiOutputPaths
 *
 * Enables the path from the HiFi DAC to all outputs.
 *
 * Parameters:
 *      hDevice         handle to the device (from WMOpenDevice)
 *
 * Returns:     WMSTATUS
 *      See WMStatus.h
 *---------------------------------------------------------------------------*/
WMSTATUS WMAudioEnableHiFiOutputPaths( WM_DEVICE_HANDLE hDevice )
{
    return private_EnableHiFiOutputPaths( hDevice, TRUE );
}

/*-----------------------------------------------------------------------------
 * Function:    private_EnableHiFiOutputPaths
 *
 * Enables/disables the path from the HiFi DAC to all outputs.
 *
 * Parameters:
 *      hDevice         handle to the device (from WMOpenDevice)
 *      enable          TRUE enables the path, FALSE disables the path.
 *
 * Returns:     WMSTATUS
 *      See WMStatus.h
 *---------------------------------------------------------------------------*/
static WMSTATUS private_EnableHiFiOutputPaths( WM_DEVICE_HANDLE hDevice,
                                               WM_BOOL enable
                                             )
{
    WMSTATUS status = WMS_UNSUPPORTED;
    WM_BOOL  mute   = !enable;

    if ( WM_IS_I2S( hDevice ) )
    {
        /*
         * Try using the generic function first.
         */
        if ( enable )
        {
            status = WMAudioConfigurePath( hDevice, WM_STREAM_HIFI_OUT );
        }
        else

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -