// Get the line info for the wave in destination line MIXERLINE mxl; mxl.cbStruct = sizeof(mxl); mxl.dwComponentType = MIXERLINE_COMPONENTTYPE_DST_WAVEIN; mmr = mixerGetLineInfo((HMIXEROBJ)hmx, &mxl,MIXER_GETLINEINFOF_COMPONENTTYPE);
// Find a LIST control, if any, for the wave in line LPMIXERCONTROL pmxctrl = (LPMIXERCONTROL)malloc(mxl.cControls * sizeof(MIXERCONTROL));
// Now walk through each control to find a type of LIST control. This // can be either Mux, Single-select, Mixer or Multiple-select. DWORD i; for(i=0; i < mxl.cControls; i++) { if (MIXERCONTROL_CT_CLASS_LIST == (pmxctrl[i].dwControlType & MIXERCONTROL_CT_CLASS_MASK)) break; }
if (i < mxl.cControls) { BOOL bOneItemOnly = FALSE; switch (pmxctrl[i].dwControlType) { case MIXERCONTROL_CONTROLTYPE_MUX: case MIXERCONTROL_CONTROLTYPE_SINGLESELECT: bOneItemOnly = TRUE; }
// Get the text description of each item LPMIXERCONTROLDETAILS_LISTTEXT plisttext = (LPMIXERCONTROLDETAILS_LISTTEXT)malloc(cChannels * cMultipleItems * sizeof(MIXERCONTROLDETAILS_LISTTEXT));
void LANSOUND_API __cdecl SetMicrophone()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
MMRESULT mmr;
HMIXER hmx;
mmr = mixerOpen(&hmx, 0, 0, 0, 0);
if(mmr != 0)
return ;
MIXERLINE mxl1;
mxl1.cbStruct = sizeof(mxl1);
mxl1.dwComponentType = MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE ;
mmr = mixerGetLineInfo((HMIXEROBJ)hmx, &mxl1,MIXER_GETLINEINFOF_COMPONENTTYPE);
char cName[MIXER_LONG_NAME_CHARS];
ZeroMemory((PVOID)cName,MIXER_LONG_NAME_CHARS);
strcpy(cName,mxl1.szName);
// Get the line info for the wave in destination line
MIXERLINE mxl;
mxl.cbStruct = sizeof(mxl);
mxl.dwComponentType = MIXERLINE_COMPONENTTYPE_DST_WAVEIN;
mmr = mixerGetLineInfo((HMIXEROBJ)hmx, &mxl,MIXER_GETLINEINFOF_COMPONENTTYPE);
// Find a LIST control, if any, for the wave in line
LPMIXERCONTROL pmxctrl = (LPMIXERCONTROL)malloc(mxl.cControls * sizeof(MIXERCONTROL));
MIXERLINECONTROLS mxlctrl = {sizeof(mxlctrl), mxl.dwLineID, 0,
mxl.cControls, sizeof(MIXERCONTROL), pmxctrl};
mmr = mixerGetLineControls((HMIXEROBJ) hmx, &mxlctrl,MIXER_GETLINECONTROLSF_ALL);
// Now walk through each control to find a type of LIST control. This
// can be either Mux, Single-select, Mixer or Multiple-select.
DWORD i;
for(i=0; i < mxl.cControls; i++)
{
if (MIXERCONTROL_CT_CLASS_LIST == (pmxctrl[i].dwControlType & MIXERCONTROL_CT_CLASS_MASK))
break;
}
if (i < mxl.cControls)
{
BOOL bOneItemOnly = FALSE;
switch (pmxctrl[i].dwControlType)
{
case MIXERCONTROL_CONTROLTYPE_MUX:
case MIXERCONTROL_CONTROLTYPE_SINGLESELECT:
bOneItemOnly = TRUE;
}
DWORD cChannels = mxl.cChannels, cMultipleItems = 0;
if (MIXERCONTROL_CONTROLF_UNIFORM & pmxctrl[i].fdwControl)
cChannels = 1;
if (MIXERCONTROL_CONTROLF_MULTIPLE & pmxctrl[i].fdwControl)
cMultipleItems = pmxctrl[i].cMultipleItems;
// Get the text description of each item
LPMIXERCONTROLDETAILS_LISTTEXT plisttext = (LPMIXERCONTROLDETAILS_LISTTEXT)malloc(cChannels * cMultipleItems * sizeof(MIXERCONTROLDETAILS_LISTTEXT));
MIXERCONTROLDETAILS mxcd = {sizeof(mxcd), pmxctrl[i].dwControlID,cChannels,
(HWND)cMultipleItems, sizeof(MIXERCONTROLDETAILS_LISTTEXT),
(LPVOID) plisttext};
mmr = mixerGetControlDetails((HMIXEROBJ)hmx, &mxcd,MIXER_GETCONTROLDETAILSF_LISTTEXT);
LPMIXERCONTROLDETAILS_BOOLEAN plistbool =(LPMIXERCONTROLDETAILS_BOOLEAN)malloc(cChannels * cMultipleItems * sizeof(MIXERCONTROLDETAILS_BOOLEAN));
MIXERCONTROLDETAILS mxcd1 = {sizeof(mxcd1), pmxctrl[i].dwControlID,cChannels,
(HWND)cMultipleItems, sizeof(MIXERCONTROLDETAILS_BOOLEAN),
(LPVOID) plistbool};
mmr = mixerGetControlDetails((HMIXEROBJ)hmx, &mxcd1,MIXER_GETCONTROLDETAILSF_VALUE);
// Select the "Microphone" item
for (DWORD j=0; j<cMultipleItems; j = j + cChannels)
if (0 == strcmp(plisttext[j].szName, cName))
{
plistbool[j].fValue = 1;
plistbool[j+ cChannels - 1].fValue = 1;
}
else
{
plistbool[j].fValue = 0;
plistbool[j+ cChannels - 1].fValue = 0;
}
// Now actually set the new values in
mmr = mixerSetControlDetails((HMIXEROBJ)hmx, &mxcd1,MIXER_GETCONTROLDETAILSF_VALUE);
free(pmxctrl);
free(plisttext);
free(plistbool);
}
else
free(pmxctrl);
mixerClose(hmx);
}
{
MMRESULT mmResult;
if ( !m_bOK )
return false;
TRACE(".InputXxxVolume: Initializing for the Source Line (%d) ..\n", uLineIndex );
MIXERLINE MixerLine;
memset( &MixerLine, 0, sizeof(MIXERLINE) );
MixerLine.cbStruct = sizeof(MIXERLINE);
MixerLine.dwComponentType = MIXERLINE_COMPONENTTYPE_DST_WAVEIN;
mmResult = mixerGetLineInfo( (HMIXEROBJ)m_dwMixerHandle, &MixerLine, MIXER_GETLINEINFOF_COMPONENTTYPE );
if ( mmResult != MMSYSERR_NOERROR )
{
TRACE(".InputXxxVolume: FAILURE: Could not get WaveIn Destionation Line for the requested source while initilaizing. mmResult=%d\n", mmResult );
return false;
} MIXERCONTROL Control;
memset( &Control, 0, sizeof(MIXERCONTROL) );
Control.cbStruct = sizeof(MIXERCONTROL); MIXERLINECONTROLS LineControls;
memset( &LineControls, 0, sizeof(MIXERLINECONTROLS) );
LineControls.cbStruct = sizeof(MIXERLINECONTROLS); MIXERLINE Line;
memset( &Line, 0, sizeof(MIXERLINE) );
Line.cbStruct = sizeof(MIXERLINE); if ( ( uLineIndex < MixerLine.cConnections ) )
{
Line.dwDestination = MixerLine.dwDestination;
Line.dwSource = uLineIndex;
mmResult = mixerGetLineInfo( (HMIXEROBJ)m_dwMixerHandle, &Line, MIXER_GETLINEINFOF_SOURCE );
if ( mmResult != MMSYSERR_NOERROR )
{
TRACE(".InputXxxVolume: FAILURE: Could not get the requested Source Line while initilaizing. mmResult=%d\n", mmResult );
return false;
}
TRACE(".InputXxxVolume: \"%s\" Source Line adopted.\n", Line.szShortName );
LineControls.dwControlType = MIXERCONTROL_CONTROLTYPE_VOLUME;
LineControls.dwLineID = Line.dwLineID;
LineControls.cControls = 1;
LineControls.cbmxctrl = sizeof(MIXERCONTROL);
LineControls.pamxctrl = &Control;
mmResult = mixerGetLineControls( (HMIXEROBJ)m_dwMixerHandle, &LineControls, MIXER_GETLINECONTROLSF_ONEBYTYPE );
if ( mmResult == MMSYSERR_NOERROR )
{
if ( !(Control.fdwControl & MIXERCONTROL_CONTROLF_DISABLED) )
{
m_bAvailable = true;
TRACE(".InputXxxVolume: \"%s\" Volume control for the Source Line adopted\n", Control.szShortName );
} else {
TRACE(".InputXxxVolume: WARNING: The Volume Control is disabled.\n" );
}
} else {
TRACE(".InputXxxVolume: WARNING: Could not get the requested Source Line Volume Control for the requested line while initilaizing. mmResult=%d\n", mmResult );
}
} else {
TRACE(".InputXxxVolume: FAILURE: Invalid Source Line index passed.\n" );
return false;
} // Retrieving Microphone Source Line
for ( UINT uLine = 0; uLine < MixerLine.cConnections; uLine++ )
{
MIXERLINE MicrophoneLine;
memset( &MicrophoneLine, 0, sizeof(MIXERLINE) );
MicrophoneLine.cbStruct = sizeof(MIXERLINE);
MicrophoneLine.dwDestination = MixerLine.dwDestination;
MicrophoneLine.dwSource = uLine;
mmResult = mixerGetLineInfo( (HMIXEROBJ)m_dwMixerHandle, &MicrophoneLine, MIXER_GETLINEINFOF_SOURCE );
if ( mmResult == MMSYSERR_NOERROR )
{
if ( MicrophoneLine.dwComponentType == MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE )
{
m_uMicrophoneSourceLineIndex = MicrophoneLine.dwSource;
TRACE(".InputXxxVolume: Microphone Source Line \"%s\" has been found.\n", MicrophoneLine.szShortName );
break;
}
}
}
if ( m_uMicrophoneSourceLineIndex == BAD_DWORD )
{
TRACE(".InputXxxVolume: WARNING: Could not retrieve Microphone Source Line.\n" );
} m_uSourceLineIndex = uLineIndex;
m_nChannelCount = Line.cChannels;
m_dwLineID = LineControls.dwLineID;
m_dwVolumeControlID = Control.dwControlID;
m_dwMinimalVolume = Control.Bounds.dwMinimum;
m_dwMaximalVolume = Control.Bounds.dwMaximum;
m_dwVolumeStep = Control.Metrics.cSteps; m_bInitialized = true;
return true;
}
楼上的,编译不通过啊,给各完整一点的好吗?