Implement media device tracking on macOS.

This commit is contained in:
John Preston 2024-01-23 13:23:32 +04:00
parent 736b489eb7
commit 65a80766f4
3 changed files with 9 additions and 4 deletions

View file

@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "media/audio/media_audio_track.h"
#include "media/media_common.h"
#include "media/streaming/media_streaming_utility.h"
#include "webrtc/webrtc_environment.h"
#include "webrtc/webrtc_media_devices.h"
#include "data/data_document.h"
#include "data/data_file_origin.h"
@ -144,8 +145,11 @@ bool CreatePlaybackDevice() {
const auto id = Current().deviceId().toStdString();
AudioDevice = alcOpenDevice(id.c_str());
if (!AudioDevice) {
LOG(("Audio Error: Could not create default playback device, enumerating.."));
EnumeratePlaybackDevices();
LOG(("Audio Error: Could not create default playback device, refreshing.."));
crl::on_main([] {
const auto type = Webrtc::DeviceType::Playback;
Core::App().mediaDevices().forceRefresh(type);
});
return false;
}

View file

@ -555,7 +555,8 @@ void ChooseAudioDeviceBox(
return;
}
const auto weak = Ui::MakeWeak(box);
chosen(state->ids.take(value).value_or(kDefaultDeviceId));
const auto i = state->ids.find(value);
chosen((i != end(state->ids)) ? i->second : kDefaultDeviceId);
if (weak) {
box->closeBox();
}

@ -1 +1 @@
Subproject commit 5a831697880967bbccbd45177fb6cf6b11759a22
Subproject commit b78e51ad98cd5bf70e916becae0b13496b9f6aca