|
CMixer::CMixer(DWORD ComponentType, DestKind dkKind): m_dwControlID(-1), m_bOK(false), m_dwChannels(0)
{
HMIXER hMixer;
HRESULT hr;
hr = mixerOpen(&hMixer, 0, 0, 0,0);
if (FAILED(hr)) return;
MIXERLINE mxl;
MIXERCONTROL mc;
MIXERLINECONTROLS mxlc;
DWORD kind, count;
if (dkKind == Play)
kind = MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT;
else
kind = MIXERLINE_COMPONENTTYPE_DST_WAVEIN;
mxl.cbStruct = sizeof(mxl);
mxl.dwComponentType = kind;
hr = mixerGetLineInfo((HMIXEROBJ)hMixer, &mxl, MIXER_GETLINEINFOF_COMPONENTTYPE);
if (FAILED(hr))
{
mixerClose(hMixer);
return;
}
count = mxl.dwSource;
for(UINT i = 0; i < count; i++)
{
mxl.dwSource = i;
mixerGetLineInfo((HMIXEROBJ)hMixer, &mxl, MIXER_GETLINEINFOF_SOURCE);
if (mxl.dwComponentType == ComponentType)
{
m_dwChannels = mxl.cChannels;
mc.cbStruct = sizeof(mc);
mxlc.cbStruct = sizeof(mxlc);
mxlc.dwLineID = mxl.dwLineID;
mxlc.dwControlType = MIXERCONTROL_CONTROLTYPE_VOLUME;
mxlc.cControls = 1;
mxlc.cbmxctrl = sizeof(MIXERCONTROL);
mxlc.pamxctrl = &mc;
hr = mixerGetLineControls((HMIXEROBJ)hMixer, &mxlc, MIXER_GETLINECONTROLSF_ONEBYTYPE);
m_dwControlID = mc.dwControlID;
break;
};
}
mixerClose(hMixer);
m_bOK = true;
}
why is the above code not functioning for controlling the play volume even if MIXERLINE_COMPONENTTYPE_DST_HEADPHONES and play are as passed as parameters to CMixer class. Please let me know the error.
Indu
|
|
|
|