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

📄 wmaudiopaths.c

📁 WM9713 audio codec driver for WinCE 5.0
💻 C
📖 第 1 页 / 共 4 页
字号:
    case WM_AUDIO_MONOIN:
    /*   WM_AUDIO_PHONEIN = WM_AUDIO_MONOIN */
    case WM_AUDIO_CD:
    case WM_AUDIO_VIDEO:
    case WM_AUDIO_AUXIN:
    case WM_AUDIO_PCBEEP:
    case WM_AUDIO_HEADPHONE:
    case WM_AUDIO_HEADPHONE_MIXER:
    case WM_AUDIO_HEADPHONE_MIXER_MONO:
    case WM_AUDIO_MONOOUT:
    case WM_AUDIO_MONO_MIXER:
    case WM_AUDIO_FRONT_MIXER:
    /*   WM_AUDIO_PHONEOUT = WM_AUDIO_MONOOUT */
    case WM_AUDIO_PHONE_MIXER:
    case WM_AUDIO_SPEAKER_MIXER:
		if ( signalL == signalR )
		{
			/* Set up both inputs together */
			secondary_signal = signalR;
		}
		else
		{
			secondary_signal = WM_AUDIO_IGNORE;
		}
		status = WMAudioSetRecordSources( hDevice, 
										  signalL, 
										  secondary_signal
										);

		/* we have processed both signals so quit */
		if (  signalL == signalR )
		{
			goto exit;
		}
		break;
                
	case WM_AUDIO_IGNORE:
		/* Do nothing */  
		status = WMS_SUCCESS;
	break;
                     
	default:
		/* Invalid signal - return immediately */
		status = WMS_INVALID_SIGNAL;
		goto exit;
	}
	
	/* Handle first status value */
	if ( WM_ERROR( status ) )
	{
        WM_TRACE( hDevice,
                  ( "WMAudioSetRecPaths failed: %s",
                  WMStatusText( status ) ) );
		goto exit;
	}

	/* 
	 * We only get here if we want to set the right path 
	 * (independently of the left) and haven't already done so.
	 */
	switch (signalR)
	{
	case WM_AUDIO_LINEIN:
		status = WMAudioSetLineInRecPaths( hDevice, WM_AUDIO_IGNORE, signalR );
		break;

	case WM_AUDIO_MIC:
	case WM_AUDIO_MIC2:
	case WM_AUDIO_MIC2A:
	case WM_AUDIO_MIC2B:
	case WM_AUDIO_MIC2BTOA:
			status = WMAudioSetMicRecPaths( hDevice, WM_AUDIO_IGNORE, signalR );
		break;

    case WM_AUDIO_MONOIN:
    case WM_AUDIO_CD:
    case WM_AUDIO_VIDEO:
    case WM_AUDIO_AUXIN:
    case WM_AUDIO_PCBEEP:
    case WM_AUDIO_HEADPHONE_MIXER:
    case WM_AUDIO_HEADPHONE_MIXER_MONO:
    case WM_AUDIO_PHONE_MIXER:
    case WM_AUDIO_SPEAKER_MIXER:
    case WM_AUDIO_MONO_MIXER:
    case WM_AUDIO_FRONT_MIXER:
			status = WMAudioSetRecordSources( hDevice, WM_AUDIO_IGNORE, signalR );
		break;
                
	case WM_AUDIO_IGNORE:
		/* Do nothing */  
		status = WMS_SUCCESS;
	break;

	default:
		/* Invalid signal - return immediately */
		status = WMS_INVALID_SIGNAL;
		goto exit;
	}

exit:
    return status;
}

/*-----------------------------------------------------------------------------
 * Function:    WMAudioClearRecPaths
 *
 * Called to clear the signals PGAs for the input to the record ADCs.
 *
 * Parameters:
 *      hDevice     handle to the device (from WMOpenDevice).
 *      signalL     signal to clear on the left record channel.
 *      signalR     signal to clear on the right record channel.
 *
 * Returns:     WMSTATUS
 * 				WMS_UNSUPPORTED there is no guarantee that any record paths been
 * 								cleared as one of the parameters was unsupported.
 *      		For all other return values see WMStatus.h 
 *---------------------------------------------------------------------------*/
WMSTATUS WMAudioClearRecPaths( WM_DEVICE_HANDLE hDevice,
                               WM_AUDIO_SIGNAL  signalL,
                               WM_AUDIO_SIGNAL  signalR
                             )
{
	WMSTATUS status = WMS_INVALID_SIGNAL;

    if ( !WM_SIGNAL_IS_VALID(signalL) || !WM_SIGNAL_IS_VALID(signalR) )
    {
        WM_TRACE( hDevice,
                  ( "WMAudioClearRecPaths failed: not a valid signal (L=0x%X, R=0x%X)",
                    signalL,
                    signalR
                  )
                );
        goto exit;
    }

	/* 
	 * Any input sources where the types of left and right signals
	 * are the same, should be handled here. e.g. 2 mic inputs. 
	 * If not then we will have to clear up the right signal later. 
	 */
	switch (signalL)
	{
	case WM_AUDIO_LINEIN:
		status = WMAudioClearLineInRecPaths( hDevice, 
										     signalL,
										     ( WM_SIGNAL_IS_LINEIN(signalR) ) ? signalR : WM_AUDIO_IGNORE
										   );

		/* we have processed both signals so quit */
		if ( WM_SIGNAL_IS_LINEIN(signalR) )
		{
			goto exit;
		}
		break;
	
	case WM_AUDIO_MIC:
	case WM_AUDIO_MIC2:
	case WM_AUDIO_MIC2A:
	case WM_AUDIO_MIC2B:
	case WM_AUDIO_MIC2BTOA:
		status = WMAudioClearMicRecPaths( hDevice,
										  signalL,
										  ( WM_SIGNAL_IS_MIC(signalR) ) ? signalR : WM_AUDIO_IGNORE
										);

		/* we have processed both signals so quit */
 		if (WM_SIGNAL_IS_MIC( signalR ) )
		{
			goto exit;
		}
		break;

    case WM_AUDIO_MONOIN:
    case WM_AUDIO_CD:
    case WM_AUDIO_VIDEO:
    case WM_AUDIO_AUXIN:
    case WM_AUDIO_PCBEEP:
    case WM_AUDIO_HEADPHONE_MIXER:
    case WM_AUDIO_HEADPHONE_MIXER_MONO:
    case WM_AUDIO_PHONE_MIXER:
    case WM_AUDIO_SPEAKER_MIXER:
    case WM_AUDIO_MONO_MIXER:
    case WM_AUDIO_FRONT_MIXER:
		/* there is no current software support for clearing other record PGA's */
		status = WMS_SUCCESS;
		break;
                
	case WM_AUDIO_IGNORE:
		/* Do nothing */  
		status = WMS_SUCCESS;
	break;

	default:
		/* Bad parameter - return immediately */
		status = WMS_INVALID_PARAMETER;
		goto exit;
		break;
	}
	
	/* Handle first status value */
	if ( WM_ERROR( status ) )
	{
        WM_TRACE( hDevice,
                  ( "WMAudioClearRecPaths failed: 0%s",
                  WMStatusText( status ) ) );
		goto exit;
	}

	/* 
	 * We only get here if we want to set the right path 
	 * (independently of the left) and haven't already done so.
	 */
	switch (signalR)
	{
	case WM_AUDIO_LINEIN:
		WMAudioClearLineInRecPaths( hDevice, WM_AUDIO_IGNORE, signalR );
		break;

	case WM_AUDIO_MIC:
	case WM_AUDIO_MIC2:
	case WM_AUDIO_MIC2A:
	case WM_AUDIO_MIC2B:
	case WM_AUDIO_MIC2BTOA:
		status = WMAudioClearMicRecPaths( hDevice,  WM_AUDIO_IGNORE, signalR );
		break;

    case WM_AUDIO_MONOIN:
    case WM_AUDIO_CD:
    case WM_AUDIO_VIDEO:
    case WM_AUDIO_AUXIN:
    case WM_AUDIO_PCBEEP:
    case WM_AUDIO_HEADPHONE_MIXER:
    case WM_AUDIO_HEADPHONE_MIXER_MONO:
    case WM_AUDIO_PHONE_MIXER:
    case WM_AUDIO_SPEAKER_MIXER:
    case WM_AUDIO_MONO_MIXER:
    case WM_AUDIO_FRONT_MIXER:
		/* there is no current software support for clearing other record PGA's */
		status = WMS_SUCCESS;
		break;
                
	case WM_AUDIO_IGNORE:
		/* Do nothing */  
		status = WMS_SUCCESS;
		break;

	default:
		/* Bad parameter - return immediately */
		status = WMS_INVALID_PARAMETER;
		goto exit;
		break;
	}

exit:
    return status;
}

/*-----------------------------------------------------------------------------
 * Function:    WMAudioSetLineInRecPaths
 *
 * Set up Line In, left and/or right channels as the record path.
 *
 * Parameters:
 *      hDevice     handle to the device (from WMOpenDevice)
 *      lineInL     line In signal to record on left ADC channel.
 *      lineInR     line In signal to record on right ADC channel.
 *
 * Returns:     WMSTATUS
 *      See WMStatus.h
 *---------------------------------------------------------------------------*/
WMSTATUS WMAudioSetLineInRecPaths( WM_DEVICE_HANDLE  hDevice, 
							       WM_AUDIO_SIGNAL   lineInL,
							       WM_AUDIO_SIGNAL   lineInR
								 )
{
    WMSTATUS            status;
    const WM_CHIPDEF    *pChipDef;

    /*
     * Try using the profile first.
     */
    status = WMLoadNamedProfile( hDevice, "Line record" );
    if ( WMS_UNKNOWN_PROFILE != status )
    {
        goto finish;
    }
    
	if ( ( !WM_SIGNAL_IS_LINEIN( lineInL ) && WM_AUDIO_IGNORE != lineInL ) ||
		 ( !WM_SIGNAL_IS_LINEIN( lineInR ) && WM_AUDIO_IGNORE != lineInR ) )

	{
        status = WMS_INVALID_SIGNAL;
        WM_TRACE( hDevice,
                  ( "WMAudioSetLineInRecPaths failed: %s",
                 WMStatusText( status ) ) );
		goto finish;
	}

	/* The caller does not want us to change anything, so just return */
	if ( WM_AUDIO_IGNORE == lineInL && WM_AUDIO_IGNORE == lineInR )
	{
		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.fnSetLineInRecPaths )
    {
        status = pChipDef->vtable.fnSetLineInRecPaths( hDevice, 
                                                       lineInL,
                                                       lineInR
                                                     );
    }
    else
    {
        status = WMS_UNSUPPORTED;
    }
    
finish:
    return status;
}

/*-----------------------------------------------------------------------------
 * Function:    WMAudioClearLineInRecPaths
 *
 * Turns off the Line In as the record path.
 *
 * Parameters:
 *      hDevice     handle to the device (from WMOpenDevice)
 *      lineInL     line In signal to clear on left ADC channel.
 *      lineInR     line In signal to clear on right ADC channel.
 *
 * Returns:     WMSTATUS
 *      See WMStatus.h
 *---------------------------------------------------------------------------*/
WMSTATUS WMAudioClearLineInRecPaths( WM_DEVICE_HANDLE  hDevice,
								     WM_AUDIO_SIGNAL   lineInL,
								     WM_AUDIO_SIGNAL   lineInR
								   )
{
	WMSTATUS            status;
    const WM_CHIPDEF    *pChipDef;

    /*
     * Try using the profile first.
     */
    status = WMLoadNamedProfile( hDevice, "Line off" );
    if ( WMS_UNKNOWN_PROFILE != status )
    {
        goto finish;
    }
    
	if ( ( !WM_SIGNAL_IS_LINEIN( lineInL ) && WM_AUDIO_IGNORE != lineInL ) ||
		 ( !WM_SIGNAL_IS_LINEIN( lineInR ) && WM_AUDIO_IGNORE != lineInR ) )

	{
        status = WMS_INVALID_SIGNAL;
        WM_TRACE( hDevice,
                  ( "WMAudioClearLineInRecPaths failed: %s",
                  WMStatusText( status ) ) );
		goto finish;
	}

	/* The caller does not want us to change anything, so just return */
	if ( WM_AUDIO_IGNORE == lineInL && WM_AUDIO_IGNORE == lineInR )
	{
		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.fnClearLineInRecPaths )
    {
        status = pChipDef->vtable.fnClearLineInRecPaths( hDevice, 
        												 lineInL, 
        												 lineInR 
        											   );
    }
    else
    {
        status = WMS_UNSUPPORTED;
    }

finish:
    return status;
}

/*-----------------------------------------------------------------------------
 * Function:    WMAudioSetMicRecPaths
 *
 * Set up a microphone paths to ADC channels as the record path.
 *
 * Parameters:
 *      hDevice         handle to the device (from WMOpenDevice)
 *      micSignalL      left channel microphone input to use.
 *      micSignalR      right channel microphone input to use.
 *      channels        which ADC channel(s) to record signal on.
 *
 * Returns:     WMSTATUS
 *      See WMStatus.h
 *---------------------------------------------------------------------------*/
WMSTATUS WMAudioSetMicRecPaths( 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,
                  ( "WMAudioSetMicRecPaths 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.fnSetMicRecPaths )
    {
        status = pChipDef->vtable.fnSetMicRecPaths( hDevice, 
                                                    micSignalL,
                                                    micSignalR
                                                  );
    }

finish:
    return status;
}

/*-----------------------------------------------------------------------------
 * Function:    WMAudioClearMicRecPaths
 *
 * Turns off the given microphone record paths.
 *
 * Parameters:
 *      hDevice         handle to the device (from WMOpenDevice)

⌨️ 快捷键说明

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