mirror of
https://github.com/LizardByte/Sunshine.git
synced 2025-01-04 02:39:56 +00:00
Don't shutdown stream if audio capture fails
This commit is contained in:
parent
315ec47523
commit
13d0106feb
@ -130,7 +130,7 @@ void capture(safe::mail_t mail, config_t config, void *channel_data) {
|
|||||||
|
|
||||||
auto &control = ref->control;
|
auto &control = ref->control;
|
||||||
if(!control) {
|
if(!control) {
|
||||||
BOOST_LOG(error) << "Couldn't create audio control"sv;
|
shutdown_event->view();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -223,21 +223,29 @@ int map_stream(int channels, bool quality) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int start_audio_control(audio_ctx_t &ctx) {
|
int start_audio_control(audio_ctx_t &ctx) {
|
||||||
|
auto fg = util::fail_guard([]() {
|
||||||
|
BOOST_LOG(warning) << "There will be no audio"sv;
|
||||||
|
});
|
||||||
|
|
||||||
ctx.sink_flag = std::make_unique<std::atomic_bool>(false);
|
ctx.sink_flag = std::make_unique<std::atomic_bool>(false);
|
||||||
|
|
||||||
if(!(ctx.control = platf::audio_control())) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto sink = ctx.control->sink_info();
|
|
||||||
if(!sink) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The default sink has not been replaced yet.
|
// The default sink has not been replaced yet.
|
||||||
ctx.restore_sink = false;
|
ctx.restore_sink = false;
|
||||||
|
|
||||||
|
if(!(ctx.control = platf::audio_control())) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto sink = ctx.control->sink_info();
|
||||||
|
if(!sink) {
|
||||||
|
// Let the calling code know it failed
|
||||||
|
ctx.control.reset();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
ctx.sink = std::move(*sink);
|
ctx.sink = std::move(*sink);
|
||||||
|
|
||||||
|
fg.disable();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user