Grailman
asked on
mixerGetLineControls failure
I'm trying to open a mixer to monitor audio levels but am getting a MIXERR_INVALCONTROL failure on mixerGetLineControls(). Here is the code I'm using:
MMRESULT rc; // Return code.
MIXERCONTROL mxc; // Holds the mixer control data.
MIXERLINE mxl; // Holds the mixer line data.
MIXERLINECONTROLS mxlc; // Obtains the mixer control.
MIXERCAPS mxrcaps;
HMIXER hMixer = NULL;
int nNumDevs = ::mixerGetNumDevs();
::ZeroMemory(&m_mxrcaps, sizeof(MIXERCAPS));
if(!nNumDevs)
{
GetMMError(rc);
return;
}
rc = ::mixerOpen(&m_hMixer, 0, 0, NULL, MIXER_OBJECTF_MIXER );
if(rc != MMSYSERR_NOERROR )
{
GetMMError(rc);
return;
}
if(m_hMixer == NULL)
{
GetMMError(rc);
return;
}
// Initialize MIXERLINE structure.
ZeroMemory(&mxl,sizeof(mxl ));
mxl.cbStruct = sizeof(mxl);
mxl.dwComponentType = MIXERLINE_COMPONENTTYPE_DS T_WAVEIN;
rc = mixerGetLineInfo((HMIXEROB J)m_hMixer , &mxl,
MIXER_GETLINEINFOF_COMPONE NTTYPE);
if(rc != MMSYSERR_NOERROR )
{
GetMMError(rc);
}
// Get the control.
ZeroMemory(&mxlc, sizeof(mxlc));
mxlc.cbStruct = sizeof(mxlc);
mxlc.dwLineID = mxl.dwLineID;
mxlc.dwControlType = MIXERCONTROL_CONTROLTYPE_P EAKMETER;
mxlc.cControls = 1;
mxlc.cbmxctrl = sizeof(mxc);
mxlc.pamxctrl = &mxc;
ZeroMemory(&mxc, sizeof(mxc));
mxc.cbStruct = sizeof(mxc);
rc = mixerGetLineControls((HMIX EROBJ)m_hM ixer,&mxlc ,
MIXER_GETLINECONTROLSF_ONE BYTYPE);
if (MMSYSERR_NOERROR != rc)
{
GetMMError(rc);
}
MIXERCONTROLDETAILS mxcd; // Gets the control values.
MIXERCONTROLDETAILS_SIGNED volStruct; // Gets the control values.
// Initialize the MIXERCONTROLDETAILS structure
ZeroMemory(&mxcd, sizeof(mxcd));
mxcd.cbStruct = sizeof(mxcd);
mxcd.cbDetails = sizeof(volStruct);
mxcd.dwControlID = mxc.dwControlID;
mxcd.paDetails = &volStruct;
mxcd.cChannels = 1;
rc = mixerGetControlDetails((HM IXEROBJ)m_ hMixer, &mxcd,
MIXER_GETCONTROLDETAILSF_V ALUE);
if (MMSYSERR_NOERROR != rc)
{
GetMMError(rc);
}
... use MIXERCONTROLDETAILS structure
Any ideas?
MMRESULT rc; // Return code.
MIXERCONTROL mxc; // Holds the mixer control data.
MIXERLINE mxl; // Holds the mixer line data.
MIXERLINECONTROLS mxlc; // Obtains the mixer control.
MIXERCAPS mxrcaps;
HMIXER hMixer = NULL;
int nNumDevs = ::mixerGetNumDevs();
::ZeroMemory(&m_mxrcaps, sizeof(MIXERCAPS));
if(!nNumDevs)
{
GetMMError(rc);
return;
}
rc = ::mixerOpen(&m_hMixer, 0, 0, NULL, MIXER_OBJECTF_MIXER );
if(rc != MMSYSERR_NOERROR )
{
GetMMError(rc);
return;
}
if(m_hMixer == NULL)
{
GetMMError(rc);
return;
}
// Initialize MIXERLINE structure.
ZeroMemory(&mxl,sizeof(mxl
mxl.cbStruct = sizeof(mxl);
mxl.dwComponentType = MIXERLINE_COMPONENTTYPE_DS
rc = mixerGetLineInfo((HMIXEROB
MIXER_GETLINEINFOF_COMPONE
if(rc != MMSYSERR_NOERROR )
{
GetMMError(rc);
}
// Get the control.
ZeroMemory(&mxlc, sizeof(mxlc));
mxlc.cbStruct = sizeof(mxlc);
mxlc.dwLineID = mxl.dwLineID;
mxlc.dwControlType = MIXERCONTROL_CONTROLTYPE_P
mxlc.cControls = 1;
mxlc.cbmxctrl = sizeof(mxc);
mxlc.pamxctrl = &mxc;
ZeroMemory(&mxc, sizeof(mxc));
mxc.cbStruct = sizeof(mxc);
rc = mixerGetLineControls((HMIX
MIXER_GETLINECONTROLSF_ONE
if (MMSYSERR_NOERROR != rc)
{
GetMMError(rc);
}
MIXERCONTROLDETAILS mxcd; // Gets the control values.
MIXERCONTROLDETAILS_SIGNED
// Initialize the MIXERCONTROLDETAILS structure
ZeroMemory(&mxcd, sizeof(mxcd));
mxcd.cbStruct = sizeof(mxcd);
mxcd.cbDetails = sizeof(volStruct);
mxcd.dwControlID = mxc.dwControlID;
mxcd.paDetails = &volStruct;
mxcd.cChannels = 1;
rc = mixerGetControlDetails((HM
MIXER_GETCONTROLDETAILSF_V
if (MMSYSERR_NOERROR != rc)
{
GetMMError(rc);
}
... use MIXERCONTROLDETAILS structure
Any ideas?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I tried using MIXERLINE_COMPONENTTYPE_SR C_COMPACTD ISC and MIXERLINE_COMPONENTTYPE_SR C_MICROPHO NE for mxl.dwComponentType but still could not get any response...?
The controls you are trying to get are unlikely to be supported by the audio driver. Check out the Windows Volume Control utility and the following Win32 sample to see if the controls are there.
ASKER
The win32 sample & volume controls show the mixer so it should be there. I don't have time to dig into it for now but it looks like I should be able t find it.
Good luck.
ASKER