From afc902a5cb4eb95ee6e436cde6aa8d3e3c8f8916 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Mon, 2 Mar 2020 11:31:04 +0400 Subject: [PATCH] Don't set device explicitly when capturing Also update openal to 1.20.1 since it has pulseaudio.allow-moves by default Fix playback devices enumerating --- .github/workflows/linux.yml | 2 +- .../SourceFiles/media/audio/media_audio.cpp | 4 ++-- .../media/audio/media_audio_capture.cpp | 18 ++++++------------ docs/building-cmake.md | 2 +- 4 files changed, 10 insertions(+), 16 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index f659e9e227..c9e9878ee8 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -323,7 +323,7 @@ jobs: run: | cd $LibrariesPath - git clone -b openal-soft-1.19.1 --depth=1 $GIT/kcat/openal-soft.git + git clone -b openal-soft-1.20.1 --depth=1 $GIT/kcat/openal-soft.git cd openal-soft/build cmake -D LIBTYPE:STRING=STATIC .. make -j$(nproc) diff --git a/Telegram/SourceFiles/media/audio/media_audio.cpp b/Telegram/SourceFiles/media/audio/media_audio.cpp index c1234c4dad..2ff60a1beb 100644 --- a/Telegram/SourceFiles/media/audio/media_audio.cpp +++ b/Telegram/SourceFiles/media/audio/media_audio.cpp @@ -82,7 +82,7 @@ bool PlaybackErrorHappened() { void EnumeratePlaybackDevices() { auto deviceNames = QStringList(); - auto devices = alcGetString(nullptr, ALC_DEVICE_SPECIFIER); + auto devices = alcGetString(nullptr, ALC_ALL_DEVICES_SPECIFIER); Assert(devices != nullptr); while (*devices != 0) { auto deviceName8Bit = QByteArray(devices); @@ -92,7 +92,7 @@ void EnumeratePlaybackDevices() { } LOG(("Audio Playback Devices: %1").arg(deviceNames.join(';'))); - if (auto device = alcGetString(nullptr, ALC_DEFAULT_DEVICE_SPECIFIER)) { + if (auto device = alcGetString(nullptr, ALC_DEFAULT_ALL_DEVICES_SPECIFIER)) { LOG(("Audio Playback Default Device: %1").arg(QString::fromLocal8Bit(device))); } else { LOG(("Audio Playback Default Device: (null)")); diff --git a/Telegram/SourceFiles/media/audio/media_audio_capture.cpp b/Telegram/SourceFiles/media/audio/media_audio_capture.cpp index c3b0dbd684..06b4ae2591 100644 --- a/Telegram/SourceFiles/media/audio/media_audio_capture.cpp +++ b/Telegram/SourceFiles/media/audio/media_audio_capture.cpp @@ -62,16 +62,12 @@ Instance::Instance() : _inner(new Inner(&_thread)) { void Instance::check() { _available = false; - if (auto defaultDevice = alcGetString(0, ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER)) { - if (auto device = alcCaptureOpenDevice(defaultDevice, kCaptureFrequency, AL_FORMAT_MONO16, kCaptureFrequency / 5)) { - auto error = ErrorHappened(device); - alcCaptureCloseDevice(device); - _available = !error; - } else { - LOG(("Audio Error: Could not open capture device!")); - } + if (auto device = alcCaptureOpenDevice(nullptr, kCaptureFrequency, AL_FORMAT_MONO16, kCaptureFrequency / 5)) { + auto error = ErrorHappened(device); + alcCaptureCloseDevice(device); + _available = !error; } else { - LOG(("Audio Error: No capture device found!")); + LOG(("Audio Error: Could not open capture device!")); } } @@ -177,9 +173,7 @@ void Instance::Inner::onInit() { void Instance::Inner::onStart() { // Start OpenAL Capture - const ALCchar *dName = alcGetString(0, ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER); - DEBUG_LOG(("Audio Info: Capture device name '%1'").arg(dName)); - d->device = alcCaptureOpenDevice(dName, kCaptureFrequency, AL_FORMAT_MONO16, kCaptureFrequency / 5); + d->device = alcCaptureOpenDevice(nullptr, kCaptureFrequency, AL_FORMAT_MONO16, kCaptureFrequency / 5); if (!d->device) { LOG(("Audio Error: capture device not present!")); emit error(); diff --git a/docs/building-cmake.md b/docs/building-cmake.md index 65ede9bfcf..0583ae4f3b 100644 --- a/docs/building-cmake.md +++ b/docs/building-cmake.md @@ -198,7 +198,7 @@ Go to ***BuildPath*** and run git clone git://repo.or.cz/openal-soft.git cd openal-soft - git checkout openal-soft-1.19.1 + git checkout openal-soft-1.20.1 cd build if [ `uname -p` == "i686" ]; then cmake -D LIBTYPE:STRING=STATIC -D ALSOFT_UTILS:BOOL=OFF ..