[Live-devel] detecting microphone in
WindowsAudioInputDevice_mixer.cpp
Syn
Syncanph at fox1.csie.ncu.edu.tw
Sat Jul 31 05:18:56 PDT 2004
Hi, I found that making microphone the first port in the list
doesn't work correctly in my system. Because it determines the
microphone port by the port names, which are usually different
in different language Windows box.
Using dwComponentType instead of port name might work out.
This is the small fix.
In WindowsAudioInputDevice_mixer.cpp,
around Line 28:
class AudioInputPort {
public:
int tag;
DWORD dwComponentType; // new line!
char name[MIXER_LONG_NAME_CHARS];
};
modifications around Line 311:
for (i = 0; i < numPorts; ++i) {
MIXERLINE mlc;
memcpy(&mlc, &mlt, sizeof mlc);
mlc.dwSource = i;
mixerGetLineInfo((HMIXEROBJ)hMixer, &mlc, MIXER_GETLINEINFOF_SOURCE/*|MIXER_OBJECTF_HMIXER*/);
ports[i].tag = mlc.dwLineID;
strncpy(ports[i].name, mlc.szName, MIXER_LONG_NAME_CHARS);
ports[i].dwComponentType = mlc.dwComponentType; // new line!
}
// A cute hack borrowed from the "rat" code: Make the microphone the first port in the list:
for (i = 1; i < numPorts; ++i) {
if(ports[i].dwComponentType == MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE) { // new line!
// if (strnicmp("mic", ports[i].name, 3) == 0 ||
// strnicmp("mik", ports[i].name, 3) == 0) {
AudioInputPort tmp = ports[0];
ports[0] = ports[i];
ports[i] = tmp;
}
}
--
Syncanph Xie
AIPR Lab., NCU, Taiwan
More information about the live-devel
mailing list