📄 acm.cpp
字号:
{ DWORD dwRes = 0L;//my_debug.OutPut(DEBUG_LEVEL_MSG, "message 0x%08X for ThisACM 0x%08X", msg, this);switch (msg) { case DRV_INSTALL: my_debug.OutPut(DEBUG_LEVEL_MSG, "DRV_INSTALL"); // Sent when the driver is installed. dwRes = DRVCNF_OK; // Can also return break; // DRVCNF_CANCEL // and DRV_RESTART case DRV_REMOVE: // Sent when the driver is removed. my_debug.OutPut(DEBUG_LEVEL_MSG, "DRV_REMOVE"); dwRes = 1L; // return value ignored break; case DRV_QUERYCONFIGURE: my_debug.OutPut(DEBUG_LEVEL_MSG, "DRV_QUERYCONFIGURE"); // Sent to determine if the driver can be // configured. dwRes = 1L; // Zero indicates configuration break; // NOT supported case DRV_CONFIGURE: my_debug.OutPut(DEBUG_LEVEL_MSG, "DRV_CONFIGURE"); // Sent to display the configuration // dialog box for the driver.// dwRes = Configure( (HWND) lParam1, (LPDRVCONFIGINFO) lParam2 ); if (my_EncodingProperties.Config(my_hModule, (HWND) lParam1)) { dwRes = DRVCNF_OK; // Can also return // DRVCNF_CANCEL // and DRVCNF_RESTART } else { dwRes = DRVCNF_CANCEL; } break; /************************************** // ACM additional messages ***************************************/ case ACMDM_DRIVER_ABOUT: my_debug.OutPut(DEBUG_LEVEL_MSG, "ACMDM_DRIVER_ABOUT"); dwRes = About( (HWND) lParam1 ); break; case ACMDM_DRIVER_DETAILS: // acmDriverDetails // Fill-in general informations about the driver/codec my_debug.OutPut(DEBUG_LEVEL_MSG, "ACMDM_DRIVER_DETAILS"); dwRes = OnDriverDetails(hdrvr, (LPACMDRIVERDETAILS) lParam1); break; case ACMDM_FORMATTAG_DETAILS: // acmFormatTagDetails my_debug.OutPut(DEBUG_LEVEL_MSG, "ACMDM_FORMATTAG_DETAILS"); dwRes = OnFormatTagDetails((LPACMFORMATTAGDETAILS) lParam1, lParam2); break; case ACMDM_FORMAT_DETAILS: // acmFormatDetails my_debug.OutPut(DEBUG_LEVEL_MSG, "ACMDM_FORMAT_DETAILS"); dwRes = OnFormatDetails((LPACMFORMATDETAILS) lParam1, lParam2); break; case ACMDM_FORMAT_SUGGEST: // acmFormatSuggest // Sent to determine if the driver can be // configured. my_debug.OutPut(DEBUG_LEVEL_MSG, "ACMDM_FORMAT_SUGGEST"); dwRes = OnFormatSuggest((LPACMDRVFORMATSUGGEST) lParam1); break; /************************************** // ACM stream messages ***************************************/ case ACMDM_STREAM_OPEN: // Sent to determine if the driver can be // configured. my_debug.OutPut(DEBUG_LEVEL_MSG, "ACMDM_STREAM_OPEN"); dwRes = OnStreamOpen((LPACMDRVSTREAMINSTANCE) lParam1); break; case ACMDM_STREAM_SIZE: // returns a recommended size for a source // or destination buffer on an ACM stream my_debug.OutPut(DEBUG_LEVEL_MSG, "ACMDM_STREAM_SIZE"); dwRes = OnStreamSize((LPACMDRVSTREAMINSTANCE)lParam1, (LPACMDRVSTREAMSIZE)lParam2); break; case ACMDM_STREAM_PREPARE: // prepares an ACMSTREAMHEADER structure for // an ACM stream conversion my_debug.OutPut(DEBUG_LEVEL_MSG, "ACMDM_STREAM_PREPARE"); dwRes = OnStreamPrepareHeader((LPACMDRVSTREAMINSTANCE)lParam1, (LPACMSTREAMHEADER) lParam2); break; case ACMDM_STREAM_UNPREPARE: // cleans up the preparation performed by // the ACMDM_STREAM_PREPARE message for an ACM stream my_debug.OutPut(DEBUG_LEVEL_MSG, "ACMDM_STREAM_UNPREPARE"); dwRes = OnStreamUnPrepareHeader((LPACMDRVSTREAMINSTANCE)lParam1, (LPACMSTREAMHEADER) lParam2); break; case ACMDM_STREAM_CONVERT: // perform a conversion on the specified conversion stream my_debug.OutPut(DEBUG_LEVEL_MSG, "ACMDM_STREAM_CONVERT"); dwRes = OnStreamConvert((LPACMDRVSTREAMINSTANCE)lParam1, (LPACMDRVSTREAMHEADER) lParam2); break; case ACMDM_STREAM_CLOSE: // closes an ACM conversion stream my_debug.OutPut(DEBUG_LEVEL_MSG, "ACMDM_STREAM_CLOSE"); dwRes = OnStreamClose((LPACMDRVSTREAMINSTANCE)lParam1); break; /************************************** // Unknown message ***************************************/ default: // Process any other messages. my_debug.OutPut(DEBUG_LEVEL_MSG, "ACM::DriverProc unknown message (0x%08X), lParam1 = 0x%08X, lParam2 = 0x%08X", msg, lParam1, lParam2); return DefDriverProc ((DWORD)this, hdrvr, msg, lParam1, lParam2); } return dwRes;}//////////////////////////////////////////////////////////////////////// Special message handlers///////////////////////////////////////////////////////////////////////*! Retreive the config details of this ACM driver The index represent the specified format \param a_FormatDetails will be filled with all the corresponding data*/inline DWORD ACM::OnFormatDetails(LPACMFORMATDETAILS a_FormatDetails, const LPARAM a_Query){ DWORD Result = ACMERR_NOTPOSSIBLE; my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "ACM_FORMATDETAILS a_Query = 0x%08X",a_Query); switch (a_Query & ACM_FORMATDETAILSF_QUERYMASK) { // Fill-in the informations corresponding to the FormatDetails->dwFormatTagIndex case ACM_FORMATDETAILSF_INDEX : my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "enter ACM_FORMATDETAILSF_INDEX for index 0x%04X:%03d",a_FormatDetails->dwFormatTag,a_FormatDetails->dwFormatIndex); if (a_FormatDetails->dwFormatTag == PERSONAL_FORMAT) { if (a_FormatDetails->dwFormatIndex < GetNumberEncodingFormats()) { LPWAVEFORMATEX WaveExt; WaveExt = a_FormatDetails->pwfx; WaveExt->wFormatTag = PERSONAL_FORMAT; my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "format in : channels %d, sample rate %d", WaveExt->nChannels, WaveExt->nSamplesPerSec); GetMP3FormatForIndex(a_FormatDetails->dwFormatIndex, *WaveExt, a_FormatDetails->szFormat); my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "format out : channels %d, sample rate %d", WaveExt->nChannels, WaveExt->nSamplesPerSec); Result = MMSYSERR_NOERROR; } else { my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "ACM_FORMATDETAILSF_INDEX unknown index 0x%04X:%03d",a_FormatDetails->dwFormatTag,a_FormatDetails->dwFormatIndex); } } else if (a_FormatDetails->dwFormatTag == WAVE_FORMAT_PCM) { if (a_FormatDetails->dwFormatIndex < FORMAT_MAX_NB_PCM) { LPWAVEFORMATEX WaveExt; WaveExt = a_FormatDetails->pwfx; WaveExt->wFormatTag = WAVE_FORMAT_PCM; my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "format in : channels %d, sample rate %d", WaveExt->nChannels, WaveExt->nSamplesPerSec); GetPCMFormatForIndex(a_FormatDetails->dwFormatIndex, *WaveExt, a_FormatDetails->szFormat); my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "format out : channels %d, sample rate %d", WaveExt->nChannels, WaveExt->nSamplesPerSec); Result = MMSYSERR_NOERROR; } else { my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "ACM_FORMATDETAILSF_INDEX unknown index 0x%04X:%03d",a_FormatDetails->dwFormatTag,a_FormatDetails->dwFormatIndex); } } else { my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "Unknown a_FormatDetails->dwFormatTag = 0x%08X",a_FormatDetails->dwFormatTag); } case ACM_FORMATDETAILSF_FORMAT : /// \todo we may output the corresponding strong (only for personal format) LPWAVEFORMATEX WaveExt; WaveExt = a_FormatDetails->pwfx; my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "enter ACM_FORMATDETAILSF_FORMAT : 0x%04X:%03d, format in : channels %d, sample rate %d",a_FormatDetails->dwFormatTag,a_FormatDetails->dwFormatIndex, WaveExt->nChannels, WaveExt->nSamplesPerSec); Result = MMSYSERR_NOERROR; break; default: Result = ACMERR_NOTPOSSIBLE; break; } a_FormatDetails->fdwSupport = ACMDRIVERDETAILS_SUPPORTF_CODEC; return Result;}/*! Retreive the details of each known format by this ACM driver The index represent the specified format (0 = MP3 / 1 = PCM) \param a_FormatTagDetails will be filled with all the corresponding data*/inline DWORD ACM::OnFormatTagDetails(LPACMFORMATTAGDETAILS a_FormatTagDetails, const LPARAM a_Query){ DWORD Result; DWORD the_format = WAVE_FORMAT_UNKNOWN; // the format to give details if (a_FormatTagDetails->cbStruct >= sizeof(*a_FormatTagDetails)) { my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "ACMDM_FORMATTAG_DETAILS, a_Query = 0x%08X",a_Query); switch(a_Query & ACM_FORMATTAGDETAILSF_QUERYMASK) { case ACM_FORMATTAGDETAILSF_INDEX: // Fill-in the informations corresponding to the a_FormatDetails->dwFormatTagIndex my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "get ACM_FORMATTAGDETAILSF_INDEX for index %03d",a_FormatTagDetails->dwFormatTagIndex); if (a_FormatTagDetails->dwFormatTagIndex < FORMAT_TAG_MAX_NB) { switch (a_FormatTagDetails->dwFormatTagIndex) { case 0: the_format = PERSONAL_FORMAT; break; default : the_format = WAVE_FORMAT_PCM; break; } } else { my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "ACM_FORMATTAGDETAILSF_INDEX for unsupported index %03d",a_FormatTagDetails->dwFormatTagIndex); Result = ACMERR_NOTPOSSIBLE; } break; case ACM_FORMATTAGDETAILSF_FORMATTAG: // Fill-in the informations corresponding to the a_FormatDetails->dwFormatTagIndex and hdrvr given switch (a_FormatTagDetails->dwFormatTag) { case WAVE_FORMAT_PCM: the_format = WAVE_FORMAT_PCM; break; case PERSONAL_FORMAT: the_format = PERSONAL_FORMAT; break; default: return (ACMERR_NOTPOSSIBLE); } my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "get ACM_FORMATTAGDETAILSF_FORMATTAG for index 0x%02X, cStandardFormats = %d",a_FormatTagDetails->dwFormatTagIndex,a_FormatTagDetails->cStandardFormats); break; case ACM_FORMATTAGDETAILSF_LARGESTSIZE: my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "ACM_FORMATTAGDETAILSF_LARGESTSIZE not used"); Result = 0L; break; default: my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "OnFormatTagDetails Unknown Format tag query"); Result = MMSYSERR_NOTSUPPORTED; break; } my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "OnFormatTagDetails the_format = 0x%08X",the_format); switch(the_format) { case WAVE_FORMAT_PCM: a_FormatTagDetails->dwFormatTag = WAVE_FORMAT_PCM; a_FormatTagDetails->dwFormatTagIndex = 0; a_FormatTagDetails->cbFormatSize = sizeof(PCMWAVEFORMAT); /// \note 0 may mean we don't know how to decode a_FormatTagDetails->fdwSupport = ACMDRIVERDETAILS_SUPPORTF_CODEC; a_FormatTagDetails->cStandardFormats = FORMAT_MAX_NB_PCM; // should be filled by Windows a_FormatTagDetails->szFormatTag[0] = '\0'; Result = MMSYSERR_NOERROR; break; case PERSONAL_FORMAT: a_FormatTagDetails->dwFormatTag = PERSONAL_FORMAT; a_FormatTagDetails->dwFormatTagIndex = 1; a_FormatTagDetails->cbFormatSize = SIZE_FORMAT_STRUCT; a_FormatTagDetails->fdwSupport = ACMDRIVERDETAILS_SUPPORTF_CODEC; a_FormatTagDetails->cStandardFormats = GetNumberEncodingFormats(); lstrcpyW( a_FormatTagDetails->szFormatTag, L"Lame MP3" ); Result = MMSYSERR_NOERROR; break; default: my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "OnFormatTagDetails Unknown format 0x%08X",the_format); return (ACMERR_NOTPOSSIBLE); } my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "OnFormatTagDetails %d possibilities for format 0x%08X",a_FormatTagDetails->cStandardFormats,the_format); } else { my_debug.OutPut(DEBUG_LEVEL_FUNC_CODE, "a_FormatTagDetails->cbStruct < sizeof(*a_FormatDetails)"); Result = ACMERR_NOTPOSSIBLE; } return Result;}/*! Retreive the global details of this ACM driver \param a_DriverDetail will be filled with all the corresponding data*/inline DWORD ACM::OnDriverDetails(const HDRVR hdrvr, LPACMDRIVERDETAILS a_DriverDetail){ if (my_hIcon == NULL) my_hIcon = LoadIcon(GetDriverModuleHandle(hdrvr), MAKEINTRESOURCE(IDI_ICON)); a_DriverDetail->hicon = my_hIcon; a_DriverDetail->fccType = ACMDRIVERDETAILS_FCCTYPE_AUDIOCODEC; a_DriverDetail->fccComp = ACMDRIVERDETAILS_FCCCOMP_UNDEFINED; /// \note this is an explicit hack of the FhG values /// \note later it could be a new value when the decoding is done a_DriverDetail->wMid = MM_FRAUNHOFER_IIS; a_DriverDetail->wPid = MM_FHGIIS_MPEGLAYER3; a_DriverDetail->vdwACM = VERSION_MSACM; a_DriverDetail->vdwDriver = VERSION_ACM_DRIVER; a_DriverDetail->fdwSupport = ACMDRIVERDETAILS_SUPPORTF_CODEC; a_DriverDetail->cFormatTags = FORMAT_TAG_MAX_NB; // 2 : MP3 and PCM// a_DriverDetail->cFormatTags = 1; // 2 : MP3 and PCM a_DriverDetail->cFilterTags = FILTER_TAG_MAX_NB; lstrcpyW( a_DriverDetail->szShortName, L"LAME MP3" ); char tmpStr[128]; wsprintf(tmpStr, "LAME MP3 Codec v%s", GetVersionString()); int u = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, tmpStr, -1, a_DriverDetail->szLongName, 0); MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, tmpStr, -1, a_DriverDetail->szLongName, u); lstrcpyW( a_DriverDetail->szCopyright, L"2002 Steve Lhomme" ); lstrcpyW( a_DriverDetail->szLicensing, L"LGPL (see gnu.org)" ); /// \todo update this part when the code changes lstrcpyW( a_DriverDetail->szFeatures , L"only CBR implementation" ); return MMSYSERR_NOERROR; // Can also return DRVCNF_CANCEL}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -