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

📄 wavemain.cpp

📁 Windows CE 6.0 BSP for the Beagle Board.
💻 CPP
📖 第 1 页 / 共 2 页
字号:
        {
            DEBUGMSG(ZONE_WODM|ZONE_WIDM, (TEXT("WODM_PAUSE/WIDM_STOP\r\n")));
            dwRet = pStreamContext->Stop();
            break;
        }

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

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

    case WODM_WRITE:
    case WIDM_ADDBUFFER:
        {
            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:
        {
            PDWORD pdwGain = (PDWORD)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 & 0xffff;
            LONG ulRight = (dwParam1>>16);

            // Left and rights volume are the same.
            if (ulRight>dwGain)
            {
                dwGain = (ulRight<<16) + ulRight;
            }
            else
            {
                dwGain = (dwGain<<16) + dwGain;
            }

            if (pStreamContext)
            {
                dwRet = pStreamContext->SetGain(dwGain);
                DEBUGMSG(ZONE_WODM, (TEXT("WODM_SETVOLUME, stream=0x%x\r\n"),dwGain));
            }
            else
            {
                DeviceContext *pDeviceContext = g_pHWContext->GetOutputDeviceContext(uDeviceId);
                dwRet = pDeviceContext->SetGain(dwGain);
                DEBUGMSG(ZONE_WODM, (TEXT("WODM_SETVOLUME, device=0x%x\r\n"),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:
        {
            DEBUGMSG(ZONE_WODM, (TEXT("WAVE: MM_WOM_SETSECONDARYGAINCLASS \r\n")));

            dwRet = pStreamContext->SetSecondaryGainClass(dwParam1);
            break;
        }

    case MM_WOM_SETSECONDARYGAINLIMIT:
        {
            DeviceContext *pDeviceContext;
            DEBUGMSG(ZONE_WODM, (TEXT("WAVE: MM_WOM_SETSECONDARYGAINLIMIT \r\n")));

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

    case MM_WOM_FORCESPEAKER:
        {
            DEBUGMSG(ZONE_WODM, (TEXT("WAVE: MM_WOM_FORCESPEAKER \r\n")));
            if (pStreamContext)
            {
                dwRet = pStreamContext->ForceSpeaker((BOOL)dwParam1);
            }
            else
            {
                dwRet = g_pHWContext->ForceSpeaker((BOOL)dwParam1);
            }
            break;
        }

    case MM_MOM_MIDIMESSAGE:
        {
            DEBUGMSG(ZONE_WODM, (TEXT("WAVE: MM_MOM_MIDIMESSAGE \r\n")));
            CMidiStream *pMidiStream = (CMidiStream *)dwUser;
            dwRet = pMidiStream->MidiMessage(dwParam1);
            break;
        }

    case WODM_BT_SCO_AUDIO_CONTROL:
        {
            DEBUGMSG(ZONE_WODM,(TEXT("WODM_BT_SCO_AUDIO_CONTROL\r\n")));
            if (pParams->dwParam2)
            {
                g_pHWContext->NotifyBtHeadsetOn(BT_AUDIO_SYSTEM|BT_AUDIO_MODEM);
            }
            else
            {
                g_pHWContext->NotifyBtHeadsetOn(BT_AUDIO_NONE);
            }
            dwRet = MMSYSERR_NOERROR;
            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;
        break;
    }

    }
    _except (GetExceptionCode() == STATUS_ACCESS_VIOLATION ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH)
    {
        ERRORMSG(1, (TEXT("Access violation in HandleWaveMessage!!!!\r\n")));
        SetLastError(E_FAIL);
    }

    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);

        case IOCTL_SET_EXTSPEAKER_POWER:
            if(dwLenIn<sizeof(BOOL))
                return FALSE;
            g_pHWContext->SetExtSpeakerPower((BOOL)*(DWORD*)pBufIn);
            if(pdwActualOut)
                *pdwActualOut = 0;
            return TRUE;

        case IOCTL_NOTIFY_HEADSET:
            if(dwLenIn<sizeof(BOOL))
                return FALSE;
            if(pdwActualOut)
                *pdwActualOut = 0;
            g_pHWContext->NotifyHeadsetOn((BOOL)*(DWORD *)pBufIn);
            return TRUE;

        case IOCTL_NOTIFY_BT_HEADSET:
            if(dwLenIn<sizeof(DWORD))
                return FALSE;
            if(pdwActualOut)
                *pdwActualOut = 0;
            g_pHWContext->NotifyBtHeadsetOn(*(DWORD *)pBufIn);
            return TRUE;

        case IOCTL_TOGGLE_EXT_SPEAKER:
            if(pdwActualOut)
                *pdwActualOut = 0;
            g_pHWContext->ToggleExtSpeaker();
            return TRUE;

        case IOCTL_GSM_CALL_ACTIVE:
            g_pHWContext->PrepareForVoiceCall(TRUE);
            if(pdwActualOut)
                *pdwActualOut = 0;
            return TRUE;

        case IOCTL_GSM_CALL_INACTIVE:
            g_pHWContext->PrepareForVoiceCall(FALSE);
            dwLenOut = 0;
            if(pdwActualOut)
                *pdwActualOut = 0;
            return TRUE;

        // 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);
            break;

        case IOCTL_DDK_GET_DRIVER_IFC:
            {
            // We can give interface only to our peer in device process
            if (GetCurrentProcessId() != (DWORD)GetCallerProcess()) 
            {
                DEBUGMSG(ZONE_ERROR, (L"ERROR: WAV_IOControl: "
                    L"IOCTL_DDK_GET_DRIVER_IFC can be called only from "
                    L"device process (caller process id 0x%08x)\r\n", 
                    GetCallerProcess()
                ));
                SetLastError(ERROR_ACCESS_DENIED);
                break;
            }
            if (pBufIn != NULL || 
                pBufOut == NULL ||
                dwLenOut < sizeof(CEDDK_DRIVER_PFN)) 
            {
                SetLastError(ERROR_INVALID_PARAMETER);
                break;
            }

            CEDDK_DRIVER_PFN *pFN;
            pFN = (CEDDK_DRIVER_PFN*)pBufOut;
            pFN->context = dwOpenData;
            pFN->pfnIOControl = WAV_IOControl;
            }
            return TRUE;


        default:
            return g_pHWContext->HandleExtMessage (dwCode, pBufIn, dwLenIn, pBufOut, dwLenOut, pdwActualOut);
            break;
        }
    }
    __except (GetExceptionCode() == STATUS_ACCESS_VIOLATION ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH)
    {
        ERRORMSG(1, (TEXT("EXCEPTION IN WAV_IOControl!!!!\r\n")));
        SetLastError(E_FAIL);
    }

    return FALSE;
}

⌨️ 快捷键说明

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