📄 wavemain.cpp
字号:
case WIDM_START:
{
if (pStreamContext)
{
dwRet = pStreamContext->Run();
}
else
{
dwRet = MMSYSERR_INVALPARAM;
}
break;
}
case WODM_PAUSE:
case WIDM_STOP:
{
if (pStreamContext)
{
dwRet = pStreamContext->Stop();
}
else
{
dwRet = MMSYSERR_INVALPARAM;
}
break;
}
case WODM_GETPOS:
case WIDM_GETPOS:
{
if (pStreamContext)
{
dwRet = pStreamContext->GetPos((PMMTIME)dwParam1);
}
else
{
dwRet = MMSYSERR_INVALPARAM;
}
break;
}
case WODM_RESET:
case WIDM_RESET:
{
if (pStreamContext)
{
dwRet = pStreamContext->Reset();
}
else
{
dwRet = MMSYSERR_INVALPARAM;
}
break;
}
case WODM_WRITE:
case WIDM_ADDBUFFER:
{
// DEBUGMSG(1, (TEXT("WODM_WRITE/WIDM_ADDBUFFER, Buffer=0x%x\r\n"),dwParam1);
if (pStreamContext)
{
dwRet = pStreamContext->QueueBuffer((LPWAVEHDR)dwParam1);
}
else
{
dwRet = MMSYSERR_INVALPARAM;
}
break;
}
case WODM_GETVOLUME:
{
PDWORD pdwGain = (PDWORD)dwParam1;
if (pStreamContext)
{
*pdwGain = pStreamContext->GetGain();
}
else
{
#ifdef USE_HW_GAIN_WODM_SETGETVOLUME
// Handle device gain in hardware
*pdwGain = g_pHWContext->GetOutputGain();
#else
// Handle device gain in software
DeviceContext *pDeviceContext = g_pHWContext->GetOutputDeviceContext(uDeviceId);
*pdwGain = pDeviceContext->GetGain();
#endif
}
dwRet = MMSYSERR_NOERROR;
break;
}
case WODM_SETVOLUME:
{
DWORD dwGain = dwParam1;
if (pStreamContext)
{
dwRet = pStreamContext->SetGain(dwGain);
}
else
{
#ifdef USE_HW_GAIN_WODM_SETGETVOLUME
// Handle device gain in hardware
dwRet = g_pHWContext->SetOutputGain(dwGain);
#else
// Handle device gain in software
DeviceContext *pDeviceContext = g_pHWContext->GetOutputDeviceContext(uDeviceId);
dwRet = pDeviceContext->SetGain(dwGain);
#endif
}
break;
}
case WODM_BREAKLOOP:
{
if (pStreamContext)
{
dwRet = pStreamContext->BreakLoop();
}
else
{
dwRet = MMSYSERR_INVALPARAM;
}
break;
}
case WODM_SETPLAYBACKRATE:
{
WaveStreamContext *pWaveStream = (WaveStreamContext *)dwUser;
if (pWaveStream)
{
dwRet = pWaveStream->SetRate(dwParam1);
}
else
{
dwRet = MMSYSERR_INVALPARAM;
}
break;
}
case WODM_GETPLAYBACKRATE:
{
WaveStreamContext *pWaveStream = (WaveStreamContext *)dwUser;
if (pWaveStream)
{
dwRet = pWaveStream->GetRate((DWORD *)dwParam1);
}
else
{
dwRet = MMSYSERR_INVALPARAM;
}
break;
}
case MM_WOM_SETSECONDARYGAINCLASS:
{
if (pStreamContext)
{
dwRet = pStreamContext->SetSecondaryGainClass(dwParam1);
}
else
{
dwRet = MMSYSERR_INVALPARAM;
}
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_MOM_MIDIMESSAGE:
{
CMidiStream *pMidiStream = (CMidiStream *)dwUser;
if (pMidiStream)
{
dwRet = pMidiStream->MidiMessage(dwParam1);
}
else
{
dwRet = MMSYSERR_INVALPARAM;
}
break;
}
// unsupported messages
case WODM_GETPITCH:
case WODM_SETPITCH:
case WODM_PREPARE:
case WODM_UNPREPARE:
case WIDM_PREPARE:
case WIDM_UNPREPARE:
default:
dwRet = MMSYSERR_NOTSUPPORTED;
}
// Pass the return code back via pBufOut
if (pdwResult)
{
*pdwResult = dwRet;
}
}
BOOL HandleWaveMessage(PMMDRV_MESSAGE_PARAMS pParams, DWORD *pdwResult)
{
g_pHWContext->Lock();
_try {
HandleWaveMessageInternal(pParams, pdwResult);
} _except(EXCEPTION_EXECUTE_HANDLER) {
SetLastError(E_FAIL);
}
g_pHWContext->Unlock();
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)
//
// -----------------------------------------------------------------------------
extern "C" BOOL WAV_IOControl(PDWORD pdwOpenData,
DWORD dwCode,
PBYTE pBufIn,
DWORD dwLenIn,
PBYTE pBufOut,
DWORD dwLenOut,
PDWORD pdwActualOut)
{
// ACL needed?
_try
{
switch (dwCode)
{
case IOCTL_MIX_MESSAGE:
return HandleMixerMessage((PMMDRV_MESSAGE_PARAMS)pBufIn, (DWORD *)pBufOut);
case IOCTL_WAV_MESSAGE:
return HandleWaveMessage((PMMDRV_MESSAGE_PARAMS)pBufIn, (DWORD *)pBufOut);
// Power management functions.
case IOCTL_POWER_CAPABILITIES:
case IOCTL_POWER_QUERY:
case IOCTL_POWER_SET:
case IOCTL_POWER_GET:
return g_pHWContext->PmControlMessage
(dwCode, pBufIn, dwLenIn, pBufOut, dwLenOut, pdwActualOut);
}
}
_except (EXCEPTION_EXECUTE_HANDLER)
{
RETAILMSG(1, (TEXT("EXCEPTION IN WAV_IOControl!!!!\r\n")));
SetLastError(E_FAIL);
}
return(FALSE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -