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

📄 wavemain.cpp

📁 realtek562x系列驱动源码。wince
💻 CPP
📖 第 1 页 / 共 2 页
字号:
            }
            else
            {
                pDeviceContext = g_pHWContext->GetOutputDeviceContext(uDeviceId);
            }

            dwRet = pDeviceContext->GetExtDevCaps((PVOID)dwParam1,dwParam2);
            break;
        }

    case WODM_OPEN:
        {
            DEBUGMSG(1, (TEXT("WODM_OPEN\r\n")));
            DeviceContext *pDeviceContext = g_pHWContext->GetOutputDeviceContext(uDeviceId);
            dwRet = pDeviceContext->OpenStream((LPWAVEOPENDESC)dwParam1, dwParam2, (StreamContext **)dwUser);
            break;
        }

    case WIDM_OPEN:
        {
            DEBUGMSG(1, (TEXT("WIDM_OPEN\r\n")));
            DeviceContext *pDeviceContext = g_pHWContext->GetInputDeviceContext(uDeviceId);
            dwRet = pDeviceContext->OpenStream((LPWAVEOPENDESC)dwParam1, dwParam2, (StreamContext **)dwUser);
            break;
        }

    case WODM_CLOSE:
    case WIDM_CLOSE:
        {
            DEBUGMSG(1, (TEXT("WIDM_CLOSE/WODM_CLOSE\r\n")));
            dwRet = pStreamContext->Close();

            // Release stream context here, rather than inside StreamContext::Close, so that if someone
            // (like CMidiStream) has subclassed Close there's no chance that the object will get released
            // out from under them.
            if (dwRet==MMSYSERR_NOERROR)
            {
                pStreamContext->Release();
            }
            break;
        }

    case WODM_RESTART:
    case WIDM_START:
        {
            DEBUGMSG(1, (TEXT("WIDM_START/WODM_START\r\n")));
            dwRet = pStreamContext->Run();
            break;
        }

    case WODM_PAUSE:
    case WIDM_STOP:
        {
            DEBUGMSG(1, (TEXT("WIDM_STOP/WODM_STOP\r\n")));
            dwRet = pStreamContext->Stop();
            break;
        }

    case WODM_GETPOS:
    case WIDM_GETPOS:
        {
            DEBUGMSG(1, (TEXT("WIDM_GETPOS/WODM_GETPOS\r\n")));
            dwRet = pStreamContext->GetPos((PMMTIME)dwParam1);
            break;
        }

    case WODM_RESET:
    case WIDM_RESET:
        {
            DEBUGMSG(1, (TEXT("WIDM_RESET/WODM_RESET\r\n")));
            dwRet = pStreamContext->Reset();
            break;
        }

    case WODM_WRITE:
    case WIDM_ADDBUFFER:
        {
            DEBUGMSG(1, (TEXT("WODM_WRITE/WIDM_ADDBUFFER, Buffer=0x%x\r\n"),dwParam1));
            dwRet = pStreamContext->QueueBuffer((LPWAVEHDR)dwParam1);
            break;
        }

    case WODM_GETVOLUME:
        {
            DEBUGMSG(ZONE_FUNCTION, (TEXT("WODM_GETVOLUME\r\n")));

            PULONG pdwGain = (PULONG)dwParam1;
            UINT NumDevs = g_pHWContext->GetNumOutputDevices();

            if (pStreamContext)
            {
                *pdwGain = pStreamContext->GetGain();
            }
            else
            {
                DeviceContext *pDeviceContext = g_pHWContext->GetOutputDeviceContext(uDeviceId);
                *pdwGain = pDeviceContext->GetGain();
            }

            dwRet = MMSYSERR_NOERROR;
            break;
        }

    case WODM_SETVOLUME:
        {
            DEBUGMSG(1, (TEXT("WODM_SETVOLUME\r\n")));

            UINT NumDevs = g_pHWContext->GetNumOutputDevices();
            LONG dwGain = dwParam1;

            DEBUGMSG(1, (TEXT("dwGain=0x%x\r\n"), dwGain));
            if (pStreamContext)
            {
                dwRet = pStreamContext->SetGain(dwGain);
            }
            else
            {
                DeviceContext *pDeviceContext = g_pHWContext->GetOutputDeviceContext(uDeviceId);
                dwRet = pDeviceContext->SetGain(dwGain);
            }
            break;
        }

    case WODM_BREAKLOOP:
        {
            dwRet = pStreamContext->BreakLoop();
            break;
        }

    case WODM_SETPLAYBACKRATE:
        {
            WaveStreamContext *pWaveStream = (WaveStreamContext *)dwUser;
            dwRet = pWaveStream->SetRate(dwParam1);
            break;
        }

    case WODM_GETPLAYBACKRATE:
        {
            WaveStreamContext *pWaveStream = (WaveStreamContext *)dwUser;
            dwRet = pWaveStream->GetRate((DWORD *)dwParam1);
            break;
        }

    case MM_WOM_SETSECONDARYGAINCLASS:
        {
            dwRet = pStreamContext->SetSecondaryGainClass(dwParam1);
            break;
        }

    case MM_WOM_SETSECONDARYGAINLIMIT:
        {
            DeviceContext *pDeviceContext;
            if (pStreamContext)
            {
                pDeviceContext = pStreamContext->GetDeviceContext();
            }
            else
            {
                pDeviceContext = g_pHWContext->GetOutputDeviceContext(uDeviceId);
            }
            dwRet = pDeviceContext->SetSecondaryGainLimit(dwParam1,dwParam2);
            break;
        }

    case MM_WOM_FORCESPEAKER:
        {
            if (pStreamContext)
            {
                dwRet = pStreamContext->ForceSpeaker((BOOL)dwParam1);
            }
            else
            {
                dwRet = g_pHWContext->ForceSpeaker((BOOL)dwParam1);
            }
            break;
        }

    case MM_MOM_MIDIMESSAGE:
        {
            CMidiStream *pMidiStream = (CMidiStream *)dwUser;
            dwRet = pMidiStream->MidiMessage(dwParam1);
            break;
        }

//    Disabled - these pose a security risk.

    case WPDM_PRIVATE_WRITE_CODEC:
        dwRet = g_pHWContext->MsgWriteCodec(dwParam1,dwParam2 );
        break;

    case WPDM_PRIVATE_READ_CODEC:
        dwRet = g_pHWContext->MsgReadCodec( dwParam1,dwParam2 );
        break;

	case WPDM_PRIVATE_CONFIG_HW_EQ:		//To enable/disable HW EQ
	case WPDM_PRIVATE_ENABLE_3D:		//To enable 3D
	case WPDM_PRIVATE_DISABLE_3D:		//To disable 3D
	case WPDM_PRIVATE_CONFIG_PSEUDO:	//To enable/disable Pseudo stereo
	case WPDM_PRIVATE_CONFIG_AVC:		//To enable/disable Auto Volume Control of inpust stream
		dwRet = g_pHWContext->RT_AudioMessage(uMsg,dwParam1,dwParam2);
		break;


/*	case WPDM_PRIVATE_SETUP_PHONE_PATH:
        NKDbgPrintfW(TEXT("call path enable\r\n"));
		switch(dwParam1)
		{
			case RIL_AUDIO_NONE:   //                           (0x00000000) 
				g_pHWContext->SetCfgNone();
				break;
			case RIL_AUDIO_HANDSET:       //                    (0x00000001) 
				g_pHWContext->SetCfgHandSet();
				break;
			case RIL_AUDIO_SPEAKERPHONE:    //                  (0x00000002) 
				g_pHWContext->SetCfgSpeakerPhone();
				break;
			case RIL_AUDIO_HEADSET:           //                (0x00000003) 
				g_pHWContext->SetCfgHeadSet();
				break;
			case RIL_AUDIO_CARKIT:              //              (0x00000004) 
				g_pHWContext->SetCfgCarKit();
				break;
			default:
				ASSERT(FALSE);

		}


		//g_pHWContext->SetupCallPath(dwParam1);
		break;*/
/*
	case WPDM_PRIVATE_DISABLE_PHONE_PATH:
        NKDbgPrintfW(TEXT("call path disable\r\n"));
		//g_pHWContext->DisableCallPath(dwParam1);
		break;
*/
    case WODM_GETPITCH:
    case WODM_SETPITCH:
    case WODM_PREPARE:
    case WODM_UNPREPARE:
    case WIDM_PREPARE:
    case WIDM_UNPREPARE:
        default:
        dwRet  = MMSYSERR_NOTSUPPORTED;
    }
    g_pHWContext->Unlock();

    // Pass the return code back via pBufOut
    if (pdwResult)
    {
        *pdwResult = dwRet;
    }

    return TRUE;
}

// -----------------------------------------------------------------------------
//
//  @doc    WDEV_EXT
//
//  @func   BOOL | WAV_IOControl | Device IO control routine
//
//  @parm   DWORD | dwOpenData | Value returned from WAV_Open call
//
//  @parm   DWORD | dwCode |
//          IO control code for the function to be performed. WAV_IOControl only
//          supports one IOCTL value (IOCTL_WAV_MESSAGE)
//
//  @parm   PBYTE | pBufIn |
//          Pointer to the input parameter structure (<t MMDRV_MESSAGE_PARAMS>).
//
//  @parm   DWORD | dwLenIn |
//          Size in bytes of input parameter structure (sizeof(<t MMDRV_MESSAGE_PARAMS>)).
//
//  @parm   PBYTE | pBufOut | Pointer to the return value (DWORD).
//
//  @parm   DWORD | dwLenOut | Size of the return value variable (sizeof(DWORD)).
//
//  @parm   PDWORD | pdwActualOut | Unused
//
//  @rdesc  Returns TRUE for success, FALSE for failure
//
//  @xref   <t Wave Input Driver Messages> (WIDM_XXX) <nl>
//          <t Wave Output Driver Messages> (WODM_XXX)
//
// -----------------------------------------------------------------------------
BOOL WAV_IOControl(
                   PDWORD pdwOpenData, 
                   DWORD  dwCode,
                   PBYTE  pBufIn,
                   DWORD  dwLenIn,
                   PBYTE  pBufOut,
                   DWORD  dwLenOut,
                   PDWORD pdwActualOut)
{
    DWORD   dwResult = MMSYSERR_NOERROR;

    // ACL needed?
    if (GetDirectCallerProcessId() != GetCurrentProcessId()) 
    {
        RETAILMSG(ZONE_WARN, (TEXT("WAV_IoControl: User mode calls not allowed.\r\n")));
        SetLastError(ERROR_ACCESS_DENIED);
        return FALSE;
    }

    //  set the error code to be no error first
    SetLastError(MMSYSERR_NOERROR);
    
    _try
    {
        switch (dwCode)
        {
        case IOCTL_WAV_MESSAGE:
            return HandleWaveMessage((PMMDRV_MESSAGE_PARAMS)pBufIn, (DWORD *)pBufOut);

        //
        // Power Management Support.
        //
        case IOCTL_POWER_CAPABILITIES:

            DEBUGMSG(ZONE_VERBOSE, (TEXT("WAV: IOCTL_POWER_CAPABILITIES\r\n")));
            if ( pBufOut == NULL || dwLenOut < sizeof(POWER_CAPABILITIES) )
                dwResult = MMSYSERR_INVALPARAM;
            else
            {
                g_pHWContext->GetPowerCapabilities(pBufOut);
                *pdwActualOut = sizeof(POWER_CAPABILITIES);
            }
            break;

        case IOCTL_POWER_QUERY:

            DEBUGMSG(ZONE_VERBOSE, (TEXT("WAV: IOCTL_POWER_QUERY\r\n")));
            if ( pBufOut == NULL || dwLenOut < sizeof(CEDEVICE_POWER_STATE) )
                dwResult = MMSYSERR_INVALPARAM;
            else
            {
                PCEDEVICE_POWER_STATE pState = (PCEDEVICE_POWER_STATE) pBufOut;

                // Check if hardware handles this power state.
                if ( ! g_pHWContext->QueryPowerState(*pState) )
                    dwResult = MMSYSERR_INVALPARAM;
            }
            break;

        case IOCTL_POWER_SET:

            DEBUGMSG(ZONE_VERBOSE, (TEXT("WAV: IOCTL_POWER_SET\r\n")));
            if ( pBufOut == NULL || dwLenOut < sizeof(CEDEVICE_POWER_STATE) )
                dwResult = MMSYSERR_INVALPARAM;
            else
            {
                PCEDEVICE_POWER_STATE pState = (PCEDEVICE_POWER_STATE) pBufOut;

                dwResult = g_pHWContext->SetPowerState(*pState);

                if ( dwResult == MMSYSERR_NOERROR )
                {
                    *pState = g_pHWContext->GetPowerState();
                    *pdwActualOut = sizeof(CEDEVICE_POWER_STATE);
                }
                else
                    dwResult = MMSYSERR_INVALPARAM;
            }
            break;

        case IOCTL_POWER_GET:

            DEBUGMSG(ZONE_VERBOSE, (TEXT("WAV: IOCTL_POWER_GET\r\n")));
            if ( pBufOut == NULL || dwLenOut < sizeof(CEDEVICE_POWER_STATE) )
                dwResult = MMSYSERR_INVALPARAM;
            else
            {
                *((PCEDEVICE_POWER_STATE) pBufOut) = g_pHWContext->GetPowerState();
                *pdwActualOut = sizeof(CEDEVICE_POWER_STATE);
            }
            break;
        }
    }
    _except (GetExceptionCode() == STATUS_ACCESS_VIOLATION ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH)
    {
        RETAILMSG(1, (TEXT("EXCEPTION IN WAV_IOControl!!!!\r\n")));
        dwResult = E_FAIL;
    }

    if (dwResult != MMSYSERR_NOERROR)
    {
        SetLastError(dwResult);
        return FALSE;
    }

    return TRUE;
}

⌨️ 快捷键说明

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