Try to make the audio sink mess clear
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -384,6 +384,8 @@ namespace config {
|
||||
{}, // audio_sink
|
||||
{}, // virtual_sink
|
||||
true, // install_steam_drivers
|
||||
true, // keep_sink_default
|
||||
true, // auto_capture
|
||||
};
|
||||
|
||||
stream_t stream {
|
||||
@@ -1051,6 +1053,8 @@ namespace config {
|
||||
string_f(vars, "audio_sink", audio.sink);
|
||||
string_f(vars, "virtual_sink", audio.virtual_sink);
|
||||
bool_f(vars, "install_steam_audio_drivers", audio.install_steam_drivers);
|
||||
bool_f(vars, "keep_sink_default", audio.keep_default);
|
||||
bool_f(vars, "auto_capture_sink", audio.auto_capture);
|
||||
|
||||
string_restricted_f(vars, "origin_web_ui_allowed", nvhttp.origin_web_ui_allowed, { "pc"sv, "lan"sv, "wan"sv });
|
||||
|
||||
|
||||
@@ -81,6 +81,8 @@ namespace config {
|
||||
std::string sink;
|
||||
std::string virtual_sink;
|
||||
bool install_steam_drivers;
|
||||
bool keep_default;
|
||||
bool auto_capture;
|
||||
};
|
||||
|
||||
constexpr int ENCRYPTION_MODE_NEVER = 0; // Never use video encryption, even if the client supports it
|
||||
|
||||
@@ -758,13 +758,15 @@ namespace platf::audio {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// If this is a virtual sink, set a callback that will change the sink back if it's changed
|
||||
auto virtual_sink_info = extract_virtual_sink_info(assigned_sink);
|
||||
if (virtual_sink_info) {
|
||||
mic->default_endpt_changed_cb = [this] {
|
||||
BOOST_LOG(info) << "Resetting sink to ["sv << assigned_sink << "] after default changed";
|
||||
set_sink(assigned_sink);
|
||||
};
|
||||
if (config::audio.keep_default) {
|
||||
// If this is a virtual sink, set a callback that will change the sink back if it's changed
|
||||
auto virtual_sink_info = extract_virtual_sink_info(assigned_sink);
|
||||
if (virtual_sink_info) {
|
||||
mic->default_endpt_changed_cb = [this] {
|
||||
BOOST_LOG(info) << "Resetting sink to ["sv << assigned_sink << "] after default changed";
|
||||
set_sink(assigned_sink);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return mic;
|
||||
|
||||
Reference in New Issue
Block a user