ISpMMSysAudio :: SetLineId를 호출하여 SAPI에 대한 lineId를 설정하려고합니다. 내가 가지고있는 믹서 핸들에서 설정하고 싶은 라인을 찾으십시오. 그러나 믹서에서 얻은 라인 ID는 SAPI가 가정하는 ID가 아닙니다. 그것은 입력을 얻지 마이크에 대한 잘못된 입력 라인을 듣고 SAPI의 결과.매핑 ISpMMSysAudio :: SetLineId 및 mixerLineId
믹서 핸들에 대해 "DST_WAVEIN"에 대해 mux 컨트롤을 얻고 마이크에 대한 소스 라인이 활성 상태인지 확인합니다. 내가 SAPI에 "입력"으로 활성 라인을 설정하고 싶습니다.
나는 다음과 같이 MUX 제어를 열거하여 믹서에서 행 ID를 얻고있다 :
INT GetSelectedWaveInLine (UINT uMixrId) { INT iRetVal = -1; MMRESULT mmResult; HMIXER dwMixerHandle; 믹서에 의해 반환
mmResult = mixerOpen((LPHMIXER)&dwMixerHandle, uMixrId, 0L, 0L, 0L);
if (MMSYSERR_NOERROR != mmResult)
{
LOG_ERROR("FAILURE: Could not Open mixer, with id: %d. mmResult=%d",uMixrId, mmResult);
return -1;
}
MIXERLINE MixerLine;
memset(&MixerLine, 0, sizeof(MIXERLINE));
MixerLine.cbStruct = sizeof(MIXERLINE);
MixerLine.dwComponentType = MIXERLINE_COMPONENTTYPE_DST_WAVEIN;
mmResult = mixerGetLineInfo((HMIXEROBJ)dwMixerHandle, &MixerLine, MIXER_GETLINEINFOF_COMPONENTTYPE);
if (MMSYSERR_NOERROR != mmResult)
{
mixerClose((HMIXER)dwMixerHandle);
LOG_ERROR("FAILURE: Could not get WaveIn Destionation Line for the requested source while enumerating. mmResult=%d", mmResult);
return -1;
}
// get the MUX
MIXERCONTROL mxc;
MIXERLINECONTROLS mxlc;
mxlc.cbStruct = sizeof(MIXERLINECONTROLS);
mxlc.dwLineID = MixerLine.dwLineID;
mxlc.dwControlType = MIXERCONTROL_CONTROLTYPE_MUX;
mxlc.cControls = 1;
mxlc.cbmxctrl = sizeof(MIXERCONTROL);
mxlc.pamxctrl = &mxc;
mmResult = ::mixerGetLineControls(reinterpret_cast<HMIXEROBJ>(uMixrId),
&mxlc,
MIXER_OBJECTF_HMIXER |
MIXER_GETLINECONTROLSF_ONEBYTYPE);
if (MMSYSERR_NOERROR != mmResult)
{
LOG_INFO0("Could not get Mux control for waveIn line. Get selected id");
mixerClose((HMIXER)dwMixerHandle);
return -1;
}
LOG_INFO("Got mux controls. Total lines associated with mux = %d", mxc.cMultipleItems);
// from the MUX get as many lines for "MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE" {from dwParam1/dwParam2 }
// then get the boolean control for the line and return the one currently selected
MIXERCONTROLDETAILS_LISTTEXT *pmxcdSelectText = new MIXERCONTROLDETAILS_LISTTEXT[mxc.cMultipleItems];
if (pmxcdSelectText != NULL)
{
MIXERCONTROLDETAILS mxcd;
mxcd.cbStruct = sizeof(MIXERCONTROLDETAILS);
mxcd.dwControlID = mxc.dwControlID;
mxcd.cChannels = 1;
mxcd.cMultipleItems = mxc.cMultipleItems;
mxcd.cbDetails = sizeof(MIXERCONTROLDETAILS_LISTTEXT);
mxcd.paDetails = pmxcdSelectText;
if (::mixerGetControlDetails(reinterpret_cast<HMIXEROBJ>(uMixrId),
&mxcd,
MIXER_OBJECTF_HMIXER |
MIXER_GETCONTROLDETAILSF_LISTTEXT)
!= MMSYSERR_NOERROR)
{
delete []pmxcdSelectText;
mixerClose((HMIXER)dwMixerHandle);
return -1;
}
}
//get all the boolean values for the mux
MIXERCONTROLDETAILS_BOOLEAN *pmxcdSelectValue = new MIXERCONTROLDETAILS_BOOLEAN[mxc.cMultipleItems];
if (pmxcdSelectValue != NULL)
{
MIXERCONTROLDETAILS mxcd;
mxcd.cbStruct = sizeof(MIXERCONTROLDETAILS);
mxcd.dwControlID = mxc.dwControlID;
mxcd.cChannels = 1;
mxcd.cMultipleItems = mxc.cMultipleItems;
mxcd.cbDetails = sizeof(MIXERCONTROLDETAILS_BOOLEAN);
mxcd.paDetails = pmxcdSelectValue;
if (::mixerGetControlDetails(reinterpret_cast<HMIXEROBJ>(uMixrId),
&mxcd,
MIXER_OBJECTF_HMIXER |
MIXER_GETCONTROLDETAILSF_VALUE)
!= MMSYSERR_NOERROR)
{
delete []pmxcdSelectValue;
mixerClose((HMIXER)dwMixerHandle);
return -1;
}
}
for (int i = 0; i < mxc.cMultipleItems; i++)
{
if(/*(pmxcdSelectText[i].dwParam2 == MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE) && */pmxcdSelectValue[i].fValue)
{
LOG_INFO("Got SELECTED microphone source line. Line index = %d, Line name = %s",i,pmxcdSelectText[i].szName);
iRetVal = i;
break;
}
}
//LOG_INFO("Got mux controls. Total lines associated with mux = %d", mxc.cMultipleItems);
delete []pmxcdSelectText;
delete []pmxcdSelectValue;
mixerClose((HMIXER)dwMixerHandle);
return iRetVal;
}
지수는 ISpMMSysAudio에 의해 사용 된 인덱스와 일치하지 않습니다. 그리고 내 음성 엔진이 다른 회선 ID를 선택합니다.
감사