From a405ceca9dc605de474be5b9373a679a61662feb Mon Sep 17 00:00:00 2001 From: Jacob Henner Date: Mon, 14 Dec 2015 05:09:34 -0500 Subject: [PATCH] Fixes #2631: Automatically select capture device. --- src/audio/audio.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/audio/audio.cpp b/src/audio/audio.cpp index 859f68666..acb55a819 100644 --- a/src/audio/audio.cpp +++ b/src/audio/audio.cpp @@ -201,7 +201,24 @@ void Audio::openInput(const QString& inDevDescr) const uint32_t chnls = AUDIO_CHANNELS; const ALCsizei bufSize = (frameDuration * sampleRate * 4) / 1000 * chnls; if (inDevDescr.isEmpty()) - alInDev = alcCaptureOpenDevice(nullptr, sampleRate, stereoFlag, bufSize); + { + const ALchar *pDeviceList = alcGetString(NULL, ALC_CAPTURE_DEVICE_SPECIFIER); + if (pDeviceList) + { + alInDev = alcCaptureOpenDevice(pDeviceList, sampleRate, stereoFlag, bufSize); + int len = strlen(pDeviceList); +#ifdef Q_OS_WIN + QString inDev = QString::fromUtf8(pDeviceList, len); +#else + QString inDev = QString::fromLocal8Bit(pDeviceList, len); +#endif + Settings::getInstance().setInDev(inDev); + } + else + { + alInDev = alcCaptureOpenDevice(nullptr, sampleRate, stereoFlag, bufSize); + } + } else alInDev = alcCaptureOpenDevice(inDevDescr.toStdString().c_str(), sampleRate, stereoFlag, bufSize);