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

📄 wmwavepdd.c

📁 WM9713 audio codec driver for WinCE 5.0
💻 C
📖 第 1 页 / 共 5 页
字号:
            DEBUGMSG( ZONE_PDD, (TEXT( "WPDM_CONTINUE - %s\r\n" ), 
                (apidir == WAPI_OUT)?(TEXT("WAPI_OUT")):(TEXT("WAPI_IN")) ) );

            break;

        /*
         * This message instructs the audio PDD that no more output data is 
         * available and that the audio circuit should finish playing the 
         * data blocks already received.
         * After the driver processes this message, the hardware generates one
         * more interrupt of type AUDIO_STATE_OUT_STOPPED to indicate we
         * have completed asynchronously.
         */
        case WPDM_ENDOFDATA:
            if (apidir == WAPI_OUT)
            {
                if ( OUTPUTDMARUNNING( g_pWMAudioDeviceData ) )
                {
                    retval = private_PddWaveOutStop( g_pWMAudioDeviceData );
                }
            }
            else
            {
                retval = MMSYSERR_NOTSUPPORTED;
            }

            DEBUGMSG( ZONE_PDD, (TEXT( "WPDM_ENDOFDATA - %s\r\n" ), 
                (apidir == WAPI_OUT)?(TEXT("WAPI_OUT")):(TEXT("WAPI_IN")) ) );

            if( retval != MMSYSERR_NOERROR )
            {
                DEBUGMSG( ZONE_ERROR, (TEXT( "WPDM_ENDOFDATA error 0x%X\r\n" ), 
                    retval ) );
            }
            break;

        /*
         * This message instructs the audio PDD to query the hardware 
         * to determine its capabilities.
         */
        case WPDM_GETDEVCAPS:
            retval = private_PddWaveGetDeviceCaps( apidir, (void *) dwParam1 );

            DEBUGMSG( ZONE_PDD, (TEXT( "WPDM_GETDEVCAPS - %s\r\n" ), 
                (apidir == WAPI_OUT)?(TEXT("WAPI_OUT")):(TEXT("WAPI_IN")) ) );

            if( retval != MMSYSERR_NOERROR )
            {
                DEBUGMSG( ZONE_ERROR, (TEXT( "WPDM_GETDEVCAPS error 0x%X\r\n" ), 
                    retval ) );
            }
            break;

        /*
         * This message instructs the audio PDD to query the current volume
         * setting of the audio device.
         */
        case WPDM_GETVOLUME:
            if (apidir == WAPI_OUT)
            {
				*((PULONG) dwParam1) = private_PddWaveGetVolume();
            }
            else
            {
                retval = MMSYSERR_NOTSUPPORTED;
            }

            DEBUGMSG( ZONE_PDD, (TEXT( "WPDM_GETVOLUME - %s\r\n" ), 
                (apidir == WAPI_OUT)?(TEXT("WAPI_OUT")):(TEXT("WAPI_IN")) ) );

            if( retval != MMSYSERR_NOERROR )
            {
                DEBUGMSG( ZONE_ERROR, (TEXT( "WPDM_GETVOLUME error 0x%X\r\n" ), 
                    retval ) );
            }
            break;

        /*
         * This message instructs the audio PDD to indicate that the waveform
         * device will be sent data of the specified format.
         */
        case WPDM_OPEN:
            retval = private_PddWaveOpen( apidir, 
                                      (LPWAVEFORMATEX) dwParam1, 
                                      (BOOL) dwParam2
                                    );

            DEBUGMSG( ZONE_PDD, (TEXT( "WPDM_OPEN - %s\r\n" ), 
                (apidir == WAPI_OUT)?(TEXT("WAPI_OUT")):(TEXT("WAPI_IN")) ) );

            if( retval != MMSYSERR_NOERROR )
            {
                DEBUGMSG( ZONE_ERROR, (TEXT( "WPDM_OPEN error 0x%X\r\n" ), 
                    retval ) );
            }
            break;

        /*
         * This message instructs the audio PDD to pause playback.
         */
        case WPDM_PAUSE:
            if (apidir == WAPI_OUT)
            {
                if ( OUTPUTDMARUNNING( g_pWMAudioDeviceData ) )
                {
                    retval = private_PddWaveOutStop( g_pWMAudioDeviceData );
                }
            }
            else
            {
                retval = MMSYSERR_NOTSUPPORTED;

            }

            DEBUGMSG( ZONE_PDD, (TEXT( "WPDM_PAUSE - %s\r\n" ), 
                (apidir == WAPI_OUT)?(TEXT("WAPI_OUT")):(TEXT("WAPI_IN")) ) );

            if( retval != MMSYSERR_NOERROR )
            {
                DEBUGMSG( ZONE_ERROR, (TEXT( "WPDM_PAUSE error 0x%X\r\n" ), 
                    retval ) );
            }
            break;

        /*
         * This message instructs the audio PDD to continue playing 
         * the paused data.
         */
        case WPDM_RESTART:

            if (apidir == WAPI_OUT)
            {
                retval = private_PddWaveOutStart( (PWAVEHDR)dwParam1, g_pWMAudioDeviceData );             
            }
            else
            {
                retval = MMSYSERR_NOTSUPPORTED;

            }

            DEBUGMSG( ZONE_PDD, (TEXT( "WPDM_RESTART - %s\r\n" ), 
                (apidir == WAPI_OUT)?(TEXT("WAPI_OUT")):(TEXT("WAPI_IN")) ) );

            if( retval != MMSYSERR_NOERROR )
            {
                DEBUGMSG( ZONE_ERROR, (TEXT( "WPDM_RESTART error 0x%X\r\n" ), 
                    retval ) );
            }
            break;

        /*
         * This message instruct the audio PDD to modify the current volume 
         * setting of the audio device.
         */
        case WPDM_SETVOLUME:
            if (apidir == WAPI_OUT)
            {
                ULONG volume = (ULONG) dwParam1;

                retval = private_PddWaveSetVolume( volume ); 
            }
            else
            {
                retval = MMSYSERR_NOTSUPPORTED;

            }

            DEBUGMSG( ZONE_PDD, (TEXT( "WPDM_SETVOLUME - %s\r\n" ), 
                (apidir == WAPI_OUT)?(TEXT("WAPI_OUT")):(TEXT("WAPI_IN")) ) );

            if( retval != MMSYSERR_NOERROR )
            {
                DEBUGMSG( ZONE_ERROR, (TEXT( "WPDM_SETVOLUME error 0x%X\r\n" ), 
                    retval ) );
            }
            break;


        /*
         * This message instruct the audio PDD to put the audio circuitry 
         * in standby mode.
         * The help file says that this message will be used as a toggle.
         * What actually happens is this message gets called repeatedly
         * while Media Player is paused. Once Media Player is unpaused the
         * WPDM_START message is sent to the driver, which will power up the
         * device.
         * For the moment this message returns MMSYSERR_NOTSUPPORTED.
         * To make sure that we still make best use of power, we power
         * down the DAC when we receive a WPDM_ENDOFDATA message and power the
         * DAC back up when we receive a WPDM_START message.
         */
        case WPDM_STANDBY:
            DEBUGMSG( ZONE_PDD, (TEXT( "WPDM_STANDBY - %s\r\n" ), 
                (apidir == WAPI_OUT)?(TEXT("WAPI_OUT")):(TEXT("WAPI_IN")) ) );
            retval = MMSYSERR_NOTSUPPORTED;
            break;

        case WPDM_START:
            if (apidir == WAPI_OUT)
            {
                retval = private_PddWaveOutStart( (PWAVEHDR)dwParam1, g_pWMAudioDeviceData );             
            }
            else
            {
                retval = private_PddWaveInStart( g_pWMAudioDeviceData );              

            }

            DEBUGMSG( ZONE_PDD, (TEXT( "WPDM_START - %s\r\n" ), 
                (apidir == WAPI_OUT)?(TEXT("WAPI_OUT")):(TEXT("WAPI_IN")) ) );

            if( retval != MMSYSERR_NOERROR )
            {
                DEBUGMSG( ZONE_ERROR, (TEXT( "WPDM_START error 0x%X\r\n" ), 
                    retval ) );
            }
            break;

        /*
         * This message instructs the audio PDD to stop playback or recording 
         * immediately.
         */
        case WPDM_STOP:
            if (apidir == WAPI_OUT)
            {
                if ( OUTPUTDMARUNNING( g_pWMAudioDeviceData ) )
                {
                    retval = private_PddWaveOutStop( g_pWMAudioDeviceData );
                }
            }
            else
            {
                if ( INPUTDMARUNNING( g_pWMAudioDeviceData ) )
                {
                    retval = private_PddWaveInStop( g_pWMAudioDeviceData );
                }
            }
            
            DEBUGMSG( ZONE_PDD, (TEXT( "WPDM_STOP - %s\r\n" ), 
                (apidir == WAPI_OUT)?(TEXT("WAPI_OUT")):(TEXT("WAPI_IN")) ) );

            if( retval != MMSYSERR_NOERROR )
            {
                DEBUGMSG( ZONE_ERROR, (TEXT( "WPDM_STOP error 0x%X\r\n" ), 
                    retval ) );
            }
            break;

        case WPDM_SETMIXERVAL:
            retval = private_SetMixerValue( dwParam1, dwParam2 );
            DEBUGMSG( ZONE_PDD, (TEXT( "WPDM_SETMIXERVAL - %s\r\n" ), 
                (apidir == WAPI_OUT)?(TEXT("WAPI_OUT")):(TEXT("WAPI_IN")) ) );
            break;

        case WPDM_GETMIXERVAL:
            retval = private_GetMixerValue( dwParam1, (PULONG) dwParam2 );
            DEBUGMSG( ZONE_PDD, (TEXT( "WPDM_GETMIXERVAL - %s\r\n" ), 
                (apidir == WAPI_OUT)?(TEXT("WAPI_OUT")):(TEXT("WAPI_IN")) ) );
            break;

        default:
            DEBUGMSG( ZONE_PDD, (TEXT( "Unknown Message 0x%X - %s\r\n" ), 
                dwCode, (apidir == WAPI_OUT)?(TEXT("WAPI_OUT")):(TEXT("WAPI_IN")) ) );
            retval = MMSYSERR_NOTSUPPORTED;
    }

    DEBUGMSG(ZONE_FUNCTION, (TEXT( "PDD_WaveProc-\r\n" )) );    

    return retval;
}

/*-----------------------------------------------------------------------------
 * Function:    private_PddWaveGetDeviceCaps
 *
 * Return the capabilities of a specified device.
 *
 * Parameters:
 *      apidir  Input and output; one of the following values.
 *              WAPI_IN Obtain input capabilities. 
 *              WAPI_OUT  Obtain output capabilities. 
 *      pCaps   Pointer to a WAVEOUTCAPS or WAVEINCAPS structure that holds 
 *              information about capabilities. If this parameter is NULL, 
 *              the PDD returns immediately, indicating whether the driver 
 *              supports the specified direction of data transfer. For example, 
 *              if apidir is WAPI_IN, and input is not supported, this function 
 *              returns MMSYSERR_NOTSUPPORTED. 
 *
 * Returns:     MMRESULT
 *              MMSYSERR_NOERROR indicates success
 *              MMSYSERR_ERROR indicates failure
 *              MMSYSERR_NOTSUPPORTED if feature is not supported.
 *---------------------------------------------------------------------------*/
static MMRESULT private_PddWaveGetDeviceCaps( WAPI_INOUT apidir, void * pCaps )
{
    MMRESULT retval = MMSYSERR_NOERROR;
    PWAVEINCAPS pwic = (PWAVEINCAPS) pCaps;
    PWAVEOUTCAPS pwoc = (PWAVEOUTCAPS) pCaps;

    DEBUGMSG(ZONE_FUNCTION, (TEXT( "private_PddWaveGetDeviceCaps+\r\n" )) );    

    if (pCaps == NULL)
    {
        /*
         * If pCaps == NULL, we are requesting if the driver PDD is capable of
         * this mode at all. In other words, if APIDIR == WAPI_IN,  we return
         * no error if input is supported, and MMSYSERR_NOTSUPPORTED otherwise.
         */
        if( WAPI_IN == apidir)
        {
            goto exit;
        }
        else /* ( WAPI_OUT == apidir) */
        {
            goto exit;
        }
    }
    
    /*
     * Fill in the DevCaps here.
     */
    if (apidir == WAPI_OUT)
    {
        DEBUGMSG(ZONE_VERBOSE, (TEXT("private_PddWaveGetDeviceCaps - API_OUT\r\n" ) ) );

        pwoc->wMid = MM_MICROSOFT;
        pwoc->wPid = s_deviceType;
        pwoc->vDriverVersion = WM_VERSION;
        wsprintf (pwoc->szPname, TEXT("Wolfson Codec Stereo (%hs)"), __DATE__);
        pwoc->dwFormats =   WAVE_FORMAT_1M08 |
                            WAVE_FORMAT_1M16 |
                            WAVE_FORMAT_1S08 |
                            WAVE_FORMAT_1S16 |
                            WAVE_FORMAT_2M08 |
                            WAVE_FORMAT_2M16 |
                            WAVE_FORMAT_2S08 |
                            WAVE_FORMAT_2S16 |
                            WAVE_FORMAT_4M08 |
                            WAVE_FORMAT_4M16 |
                            WAVE_FORMAT_4S08 |
                            WAVE_FORMAT_4S16;

        pwoc->wChannels = 2;
    
        pwoc->dwSupport = WAVECAPS_VOLUME   | 
                          WAVECAPS_LRVOLUME | 
                          WAVECAPS_PLAYBACKRATE;
    }
    else
    {
        DEBUGMSG(ZONE_VERBOSE, (TEXT("private_PddWaveGetDeviceCaps - API_IN\r\n" ) ) );
        pwic->wMid = MM_MICROSOFT;
        pwic->wPid = s_deviceType;
        pwic->vDriverVersion = WM_VERSION;
        wsprintf (pwoc->szPname, TEXT("Wolfson Codec Stereo (%hs)"), __DATE__);
        pwic->dwFormats =   WAVE_FORMAT_1M08 |
                            WAVE_FORMAT_1M16 |
                            WAVE_FORMAT_1S08 |
                            WAVE_FORMAT_1S16 |
                            WAVE_FORMAT_2M08 |
                            WAVE_FORMAT_2M16 |
                            WAVE_FORMAT_2S08 |
                            WAVE_FORMAT_2S16 |
                            WAVE_FORMAT_4M08 |
                            WAVE_FORMAT_4M16 |
                            WAVE_FORMAT_4S08 |
                            WAVE_FORMAT_4S16;

        pwic->wChannels = 2;
    }

exit:
    DEBUGMSG(ZONE_FUNCTION, (TEXT( "private_PddWaveGetDeviceCaps-\r\n" )) );    

    return retval;
}

/*-----------------------------------------------------------------------------
 * Function:    private_PddWaveOpen
 *
 * Prepare to either send or recieve audio data 
 * (based on WAPI_INOUT direction flag).
 *
 * Parameters:
 *      apidir              Input and output; one of the following values.
 *                          WAPI_IN Open to record. 
 *                          WAPI_OUT  Open to playback. 
 *      lpFormat            Pointer to a WAVEFORMATEX structure that points to
 *                          the format of the data to be played. 
 *      fQueryFormatOnly    TRUE indicates that the driver needs to check
 *                          only if the specified format is supported.
 *                          If the format is not supported, the driver returns
 *                          WAVEERR_BADFORMAT.

⌨️ 快捷键说明

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