📄 wavemain.cpp
字号:
{
dwRet = g_pHWContext->GetNumOutputDevices();
break;
}
case WIDM_GETNUMDEVS:
{
dwRet = g_pHWContext->GetNumInputDevices();
break;
}
case WODM_GETDEVCAPS:
{
DeviceContext *pDeviceContext;
UINT NumDevs = g_pHWContext->GetNumOutputDevices();
if (pStreamContext)
{
pDeviceContext=pStreamContext->GetDeviceContext();
}
else
{
pDeviceContext = g_pHWContext->GetOutputDeviceContext(uDeviceId);
}
dwRet = pDeviceContext->GetDevCaps((PVOID)dwParam1,dwParam2);
break;
}
case WIDM_GETDEVCAPS:
{
DeviceContext *pDeviceContext;
UINT NumDevs = g_pHWContext->GetNumInputDevices();
if (pStreamContext)
{
pDeviceContext=pStreamContext->GetDeviceContext();
}
else
{
pDeviceContext = g_pHWContext->GetInputDeviceContext(uDeviceId);
}
dwRet = pDeviceContext->GetDevCaps((PVOID)dwParam1,dwParam2);
break;
}
case WODM_GETEXTDEVCAPS:
{
DeviceContext *pDeviceContext;
UINT NumDevs = g_pHWContext->GetNumOutputDevices();
if (pStreamContext)
{
pDeviceContext=pStreamContext->GetDeviceContext();
}
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:
{
dwRet = pStreamContext->Run();
break;
}
case WODM_PAUSE:
case WIDM_STOP:
{
dwRet = pStreamContext->Stop();
break;
}
case WODM_GETPOS:
case WIDM_GETPOS:
{
dwRet = pStreamContext->GetPos((PMMTIME)dwParam1);
break;
}
case WODM_RESET:
case WIDM_RESET:
{
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:
{
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:
{
UINT NumDevs = g_pHWContext->GetNumOutputDevices();
LONG dwGain = dwParam1;
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;
}
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(DWORD dwOpenData,
DWORD dwCode,
PBYTE pBufIn,
DWORD dwLenIn,
PBYTE pBufOut,
DWORD dwLenOut,
PDWORD pdwActualOut)
{
_try
{
switch (dwCode)
{
case IOCTL_WAV_MESSAGE:
return HandleWaveMessage((PMMDRV_MESSAGE_PARAMS)pBufIn, (DWORD *)pBufOut);
default:
return g_pHWContext->IOControl(dwOpenData, dwCode, pBufIn, dwLenIn, pBufOut, dwLenOut, pdwActualOut);
}
}
_except (GetExceptionCode() == STATUS_ACCESS_VIOLATION ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH)
{
RETAILMSG(1, (TEXT("EXCEPTION IN WAV_IOControl!!!!\r\n")));
SetLastError(E_FAIL);
}
return FALSE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -