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

📄 wavemain.cpp

📁 pxa270平台 windows mobile 5.2 wm9713 触摸屏+音频驱动
💻 CPP
📖 第 1 页 / 共 2 页
字号:
        {
            DeviceContext *pDeviceContext;
            UINT NumDevs = g_pHWContext->GetNumInputDevices();

            if (pStreamContext)
            {
                pDeviceContext=pStreamContext->GetDeviceContext();
            }
            else
            {
                pDeviceContext = g_pHWContext->GetInputDeviceContext(uDeviceId);
            }

			//
			// Is there support for this input (both hardware and software) ?
			//
			if ( pDeviceContext )
            {
				dwRet = pDeviceContext->GetDevCaps((PVOID)dwParam1,dwParam2);
			}
            else
            {
            	dwRet = MMSYSERR_BADDEVICEID;
            }
            break;
        }

    case WODM_GETEXTDEVCAPS:
        {
            DeviceContext *pDeviceContext;
            UINT NumDevs = g_pHWContext->GetNumOutputDevices();

            if (pStreamContext)
            {
                pDeviceContext=pStreamContext->GetDeviceContext();
            }
            else
            {
                pDeviceContext = g_pHWContext->GetOutputDeviceContext(uDeviceId);
            }

			//
			// Is there support for this output (both hardware and software) ?
			//
			if ( pDeviceContext )
            {
				dwRet = pDeviceContext->GetExtDevCaps((PVOID)dwParam1,dwParam2);
			}
            else
            {
            	dwRet = MMSYSERR_BADDEVICEID;
            }
            break;
        }

    case WODM_OPEN:
        {
            DEBUGMSG(ZONE_WODM, (TEXT("WODM_OPEN\r\n")));
            DeviceContext *pDeviceContext = g_pHWContext->GetOutputDeviceContext(uDeviceId);
			// 
			// Is there support for this output (both hardware and software) ?
			//
            if ( pDeviceContext )
            {
				dwRet = pDeviceContext->OpenStream((LPWAVEOPENDESC)dwParam1, dwParam2, (StreamContext **)dwUser);
			}
            else
            {
            	dwRet = MMSYSERR_BADDEVICEID;
            }
            break;
        }

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

    case WODM_CLOSE:
    case WIDM_CLOSE:
        {
            DEBUGMSG(ZONE_WODM|ZONE_WIDM, (TEXT("WIDM_CLOSE/WODM_CLOSE\r\n")));
            ASSERT( pStreamContext );
            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:
        {
            ASSERT( pStreamContext );
            // This message will cause a performance loss so be careful usng it.
            // DEBUGMSG(ZONE_WODM|ZONE_WIDM, (TEXT("WIDM_START/WODM_START\r\n")));
            dwRet = pStreamContext->Run();
            break;
        }

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

    case WODM_GETPOS:
    case WIDM_GETPOS:
        {
            ASSERT( pStreamContext );
            // This message will cause a performance loss so be careful usng it.
            // DEBUGMSG(ZONE_WODM|ZONE_WIDM, (TEXT("WIDM_GETPOS/WODM_GETPOS\r\n")));
            dwRet = pStreamContext->GetPos((PMMTIME)dwParam1);
            break;
        }

    case WODM_RESET:
    case WIDM_RESET:
        {
            ASSERT( pStreamContext );
            // This message will cause a performance loss so be careful usng it.
            // DEBUGMSG(ZONE_WODM|ZONE_WIDM, (TEXT("WIDM_RESET/WODM_RESET\r\n")));
            dwRet = pStreamContext->Reset();
            break;
        }

    case WODM_WRITE:
    case WIDM_ADDBUFFER:
        {
            ASSERT( pStreamContext );
            // This message will cause a performance loss so be careful usng it.
            // DEBUGMSG(ZONE_WODM|ZONE_WIDM, (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();

            DEBUGMSG(ZONE_WODM, (TEXT("WODM_GETVOLUME\r\n")));

            if (pStreamContext)
            {
                *pdwGain = pStreamContext->GetGain();
            }
            else
            {
                DeviceContext *pDeviceContext = g_pHWContext->GetOutputDeviceContext(uDeviceId);
#ifdef USE_HW_GAIN_WODM_SETGETVOLUME
                // Handle device gain in hardware

				if ( pDeviceContext )
				{
					*pdwGain = g_pHWContext->GetOutputGain();
				}
				else
				{
					dwRet = MMSYSERR_BADDEVICEID;
					break;
				}
                *pdwGain = g_pHWContext->GetOutputGain();
#else
                // Handle device gain in software

				if ( pDeviceContext )
				{
					*pdwGain = pDeviceContext->GetGain();
				}
				else
				{
					dwRet = MMSYSERR_BADDEVICEID;
					break;
				}
#endif
            }
            dwRet = MMSYSERR_NOERROR;
            break;
        }

    case WODM_SETVOLUME:
        {
            UINT NumDevs = g_pHWContext->GetNumOutputDevices();
            DWORD dwGain = dwParam1;

            DEBUGMSG(ZONE_WODM, (TEXT("WODM_SETVOLUME\r\n")));

            if (pStreamContext)
            {
                dwRet = pStreamContext->SetGain(dwGain);
            }
            else
            {
                DeviceContext *pDeviceContext = g_pHWContext->GetOutputDeviceContext(uDeviceId);
#ifdef USE_HW_GAIN_WODM_SETGETVOLUME
                // Handle device gain in hardware

				if ( pDeviceContext )
				{
                    dwRet = g_pHWContext->SetOutputGain(dwGain);
				}
				else
				{
					dwRet = MMSYSERR_BADDEVICEID;
					break;
				}
#else
                // Handle device gain in software

				if ( pDeviceContext )
				{
					dwRet = pDeviceContext->SetGain(dwGain);
				}
				else
				{
					dwRet = MMSYSERR_BADDEVICEID;
					break;
				}
#endif
            }
            break;
        }

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

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

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

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

    case MM_WOM_SETSECONDARYGAINLIMIT:
        {
            DeviceContext *pDeviceContext;
            if (pStreamContext)
            {
                pDeviceContext = pStreamContext->GetDeviceContext();
            }
            else
            {
                pDeviceContext = g_pHWContext->GetOutputDeviceContext(uDeviceId);
            }
			// 
			// Is there support for this output (both hardware and software) ?
			//
			if ( pDeviceContext )
			{
				dwRet = pDeviceContext->SetSecondaryGainLimit(dwParam1,dwParam2);
			}
			else
			{
				dwRet = MMSYSERR_BADDEVICEID;
			}
            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;
        }
    // unsupported messages
    case WODM_GETPITCH:
    case WODM_SETPITCH:
    case WODM_PREPARE:
    case WODM_UNPREPARE:
    case WIDM_PREPARE:
    case WIDM_UNPREPARE:
        dwRet  = MMSYSERR_NOTSUPPORTED;
        break;
        
    default:
        //
        // Pass it on to the hardware driver in case it's a hardware-specific
        // message.
        //
        dwRet = g_pHWContext->HandleDriverMessage( uDeviceId, uMsg, dwParam1, dwParam2 );
    }
    // This message can cause a performance loss so be careful using it.
    // DEBUGMSG(ZONE_FUNCTION, (TEXT("-HandleWaveMessage\r\n")));
    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 )
{
    // check caller trust. if context hasn't been initialized, load from CeGetCallerTrust.
    if (dwOpenData != OEM_CERTIFY_TRUST) {
        if (OEM_CERTIFY_TRUST != (dwOpenData = CeGetCallerTrust())) {
            PRINTMSG(ZONE_WARN, (TEXT("WAV_IoControl: untrusted process\r\n")));
            SetLastError(ERROR_ACCESS_DENIED);
            return FALSE;
        }
    }

    _try
    {
        switch (dwCode)
        {
        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 (GetExceptionCode() == STATUS_ACCESS_VIOLATION ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH)
    {
        RETAILMSG(ZONE_ALWAYS, (TEXT("EXCEPTION IN WAV_IOControl!!!!\r\n")));
        SetLastError(E_FAIL);
    }

    return FALSE;
}

//------------------------------- END OF FILE ----------------------------------

⌨️ 快捷键说明

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