Try to make the audio sink mess clear

This commit is contained in:
Yukino Song
2024-07-31 20:16:00 +08:00
committed by Yukino Song
parent d5605cc899
commit 774ce93162
7 changed files with 56 additions and 22 deletions

View File

@@ -192,6 +192,8 @@ namespace audio {
}
}
BOOST_LOG(info) << "Selected audio sink: "sv << *sink;
// Only the first to start a session may change the default sink
if (!ref->sink_flag->exchange(true, std::memory_order_acquire)) {
// If the selected sink is different than the current one, change sinks.
@@ -238,14 +240,17 @@ namespace audio {
case platf::capture_e::timeout:
continue;
case platf::capture_e::reinit:
BOOST_LOG(info) << "Reinitializing audio capture"sv;
mic.reset();
do {
mic = control->microphone(stream.mapping, stream.channelCount, stream.sampleRate, frame_size);
if (!mic) {
BOOST_LOG(warning) << "Couldn't re-initialize audio input"sv;
}
} while (!mic && !shutdown_event->view(5s));
if (config::audio.auto_capture) {
BOOST_LOG(info) << "Reinitializing audio capture"sv;
mic.reset();
do {
mic = control->microphone(stream.mapping, stream.channelCount, stream.sampleRate, frame_size);
if (!mic) {
BOOST_LOG(warning) << "Couldn't re-initialize audio input"sv;
}
} while (!mic && !shutdown_event->view(5s));
}
continue;
default:
return;