How do i use acmFormatEnum? All help is appreciated!
-
I'm trying to enumerate all the different formats of a specific driver but acmFormatEnum keeps returning MMSYSERR_INVALPARAM (At least one parameter is invalid.). Anyone have an example of how to do this? Here's my code (id is a valid driver identifier of a driver):
ACMFORMATTAGDETAILS acmTagDetails;
void StartEnum()
{
HACMDRIVER hAcm;acmDriverOpen(&hAcm, id, 0); acmTagDetails.cbStruct = sizeof(ACMFORMATTAGDETAILS); acmFormatTagEnum(hAcm, &acmTagDetails, acmTagCallback, NULL, 0); acmDriverClose(hAcm, 0);
}
BOOL WINAPI acmTagCallback(HACMDRIVERID hadid, LPACMFORMATTAGDETAILS paftd, DWORD dwInstance,DWORD fdwSupport)
{
ACMFORMATDETAILS acmFormat;
HACMDRIVER hAcm;memset(&acmFormat, 0, sizeof acmFormat); acmFormat.cbStruct = sizeof(ACMFORMATDETAILS); acmMetrics(NULL, ACM\_METRIC\_MAX\_SIZE\_FORMAT, &acmFormat.cbwfx); acmFormat.pwfx = (WAVEFORMATEX \*)malloc(acmFormat.cbwfx); acmDriverOpen(&hAcm, hadid, 0); acmFormatEnum(hAcm, &acmFormat, formatCallback, NULL, ACM\_FORMATENUMF\_WFORMATTAG); acmDriverClose(hAcm, 0); return TRUE;
}
BOOL WINAPI formatCallback(HACMDRIVERID hadid, LPACMFORMATDETAILS pafd, DWORD dwInstance, DWORD fdwSupport)
{
ACMDRIVERDETAILS details;details.cbStruct = sizeof(details); acmDriverDetails(hadid, &details, NULL); SendMessage(GetDlgItem(ghWnd, IDC\_FORMATS), LB\_INSERTSTRING, 0, (LPARAM)details.szLongName); return TRUE;
}
Thanks for your help! -Rune Svendsen
-
I'm trying to enumerate all the different formats of a specific driver but acmFormatEnum keeps returning MMSYSERR_INVALPARAM (At least one parameter is invalid.). Anyone have an example of how to do this? Here's my code (id is a valid driver identifier of a driver):
ACMFORMATTAGDETAILS acmTagDetails;
void StartEnum()
{
HACMDRIVER hAcm;acmDriverOpen(&hAcm, id, 0); acmTagDetails.cbStruct = sizeof(ACMFORMATTAGDETAILS); acmFormatTagEnum(hAcm, &acmTagDetails, acmTagCallback, NULL, 0); acmDriverClose(hAcm, 0);
}
BOOL WINAPI acmTagCallback(HACMDRIVERID hadid, LPACMFORMATTAGDETAILS paftd, DWORD dwInstance,DWORD fdwSupport)
{
ACMFORMATDETAILS acmFormat;
HACMDRIVER hAcm;memset(&acmFormat, 0, sizeof acmFormat); acmFormat.cbStruct = sizeof(ACMFORMATDETAILS); acmMetrics(NULL, ACM\_METRIC\_MAX\_SIZE\_FORMAT, &acmFormat.cbwfx); acmFormat.pwfx = (WAVEFORMATEX \*)malloc(acmFormat.cbwfx); acmDriverOpen(&hAcm, hadid, 0); acmFormatEnum(hAcm, &acmFormat, formatCallback, NULL, ACM\_FORMATENUMF\_WFORMATTAG); acmDriverClose(hAcm, 0); return TRUE;
}
BOOL WINAPI formatCallback(HACMDRIVERID hadid, LPACMFORMATDETAILS pafd, DWORD dwInstance, DWORD fdwSupport)
{
ACMDRIVERDETAILS details;details.cbStruct = sizeof(details); acmDriverDetails(hadid, &details, NULL); SendMessage(GetDlgItem(ghWnd, IDC\_FORMATS), LB\_INSERTSTRING, 0, (LPARAM)details.szLongName); return TRUE;
}
Thanks for your help! -Rune Svendsen
You have to many members not initialized in acmTagCallback. MSDN says that for
ACM_FORMATENUMF_WFORMATTAG
, you must initializeddwFormatTag
member of theACMFORMATDETAILS
structure must be equal to the wFormatTag member of WAVEFORMATEX. By the way, you need to free the memory you allocate with malloc or you may want to use a local variable :WAVEFORMATEX waveFormat = { 0 }
; and assign it toacmFormat.pwfx = &wafeFormat
; You still need to initialize wafeFormat with the format that you are looking for. An 8Khz, 8-bit, 1 channel may be your starting point. Sorry if I don't have code to show you right now! Good luck VOTD:"5. The Lord loves righteousness and justice; the Earth is full of his unfailing love. "-Psalm 33:5 -
I'm trying to enumerate all the different formats of a specific driver but acmFormatEnum keeps returning MMSYSERR_INVALPARAM (At least one parameter is invalid.). Anyone have an example of how to do this? Here's my code (id is a valid driver identifier of a driver):
ACMFORMATTAGDETAILS acmTagDetails;
void StartEnum()
{
HACMDRIVER hAcm;acmDriverOpen(&hAcm, id, 0); acmTagDetails.cbStruct = sizeof(ACMFORMATTAGDETAILS); acmFormatTagEnum(hAcm, &acmTagDetails, acmTagCallback, NULL, 0); acmDriverClose(hAcm, 0);
}
BOOL WINAPI acmTagCallback(HACMDRIVERID hadid, LPACMFORMATTAGDETAILS paftd, DWORD dwInstance,DWORD fdwSupport)
{
ACMFORMATDETAILS acmFormat;
HACMDRIVER hAcm;memset(&acmFormat, 0, sizeof acmFormat); acmFormat.cbStruct = sizeof(ACMFORMATDETAILS); acmMetrics(NULL, ACM\_METRIC\_MAX\_SIZE\_FORMAT, &acmFormat.cbwfx); acmFormat.pwfx = (WAVEFORMATEX \*)malloc(acmFormat.cbwfx); acmDriverOpen(&hAcm, hadid, 0); acmFormatEnum(hAcm, &acmFormat, formatCallback, NULL, ACM\_FORMATENUMF\_WFORMATTAG); acmDriverClose(hAcm, 0); return TRUE;
}
BOOL WINAPI formatCallback(HACMDRIVERID hadid, LPACMFORMATDETAILS pafd, DWORD dwInstance, DWORD fdwSupport)
{
ACMDRIVERDETAILS details;details.cbStruct = sizeof(details); acmDriverDetails(hadid, &details, NULL); SendMessage(GetDlgItem(ghWnd, IDC\_FORMATS), LB\_INSERTSTRING, 0, (LPARAM)details.szLongName); return TRUE;
}
Thanks for your help! -Rune Svendsen
Try to initialize your WAVEFORMATEX struct with this function:
void InitFormat(LPWAVEFORMATEX pwfx, WORD wChannel, DWORD dwSamplesPerSec, WORD wBitsPerSample)
{
_ASSERTE( NULL != pwfx );
pwfx->cbSize = sizeof(WAVEFORMATEX);
pwfx->wFormatTag = WAVE_FORMAT_PCM;
pwfx->nChannels = wChannel;
pwfx->nSamplesPerSec = dwSamplesPerSec;
pwfx->nAvgBytesPerSec = dwSamplesPerSec * wChannel * (wBitsPerSample>>3);
pwfx->wBitsPerSample = wBitsPerSample;
pwfx->nBlockAlign = wChannel * (wBitsPerSample>>3);
}VOTD:"5 I know that the Lord is great, that our Lord is greater than all gods. 6 The Lord does whatever pleases him, in the heavens and on the earth, in the seas and all their depths."- Psalm 135:5-6