Merge pull request #587 from moralrecordings/pulseaudio_fix

This commit is contained in:
Nico 2022-04-20 23:48:34 +02:00 committed by GitHub
commit 5106ba5307
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 24 deletions

View File

@ -37,7 +37,7 @@ bool Soundux::PulseApi::setup()
load(context_move_sink_input_by_index);
load(context_move_source_output_by_name);
load(context_move_source_output_by_index);
load(context_set_sink_input_mute);
load(context_set_source_mute_by_name);
load(context_unload_module);
load(context_get_state);
load(operation_get_state);
@ -69,7 +69,7 @@ bool Soundux::PulseApi::setup()
load(context_move_sink_input_by_index);
load(context_move_source_output_by_name);
load(context_move_source_output_by_index);
load(context_set_sink_input_mute);
load(context_set_source_mute_by_name);
load(context_unload_module);
load(context_get_state);
load(operation_get_state);

View File

@ -26,9 +26,9 @@ namespace Soundux
pulse_forward_decl(context_get_server_info);
pulse_forward_decl(context_set_state_callback);
pulse_forward_decl(context_set_default_source);
pulse_forward_decl(context_set_sink_input_mute);
pulse_forward_decl(context_get_module_info_list);
pulse_forward_decl(context_move_sink_input_by_name);
pulse_forward_decl(context_set_source_mute_by_name);
pulse_forward_decl(context_move_sink_input_by_index);
pulse_forward_decl(context_get_sink_input_info_list);
pulse_forward_decl(context_move_source_output_by_name);

View File

@ -144,8 +144,7 @@ namespace Soundux::Objects
fetchLoopBackSinkId();
if (!nullSink || !loopBack || !loopBackSink || !passthrough || !passthroughSink || !passthroughLoopBack ||
!defaultSourceId)
if (!nullSink || !loopBack || !loopBackSink || !passthrough || !passthroughSink || !passthroughLoopBack)
{
unloadLeftOvers();
return false;
@ -196,17 +195,6 @@ namespace Soundux::Objects
}
},
this));
await(PulseApi::context_get_sink_input_info_list(
context,
[]([[maybe_unused]] pa_context *ctx, const pa_sink_input_info *info, [[maybe_unused]] int eol,
void *userData) {
auto *thiz = reinterpret_cast<PulseAudio *>(userData);
if (info && info->name == thiz->defaultSource)
{
thiz->defaultSourceId = info->index;
}
},
this));
}
void PulseAudio::fetchLoopBackSinkId()
{
@ -644,8 +632,8 @@ namespace Soundux::Objects
{
bool success = false;
await(PulseApi::context_set_sink_input_mute(
context, *defaultSourceId, state,
await(PulseApi::context_set_source_mute_by_name(
context, defaultSource.c_str(), state,
+[]([[maybe_unused]] pa_context *ctx, int success, void *userData) {
*reinterpret_cast<bool *>(userData) = success;
},
@ -653,7 +641,7 @@ namespace Soundux::Objects
if (!success)
{
Fancy::fancy.logTime().failure() << "Failed to mute loopback sink" << std::endl;
Fancy::fancy.logTime().failure() << "Failed to mute default source" << std::endl;
}
return success;

View File

@ -49,7 +49,6 @@ namespace Soundux
std::string serverName;
std::string defaultSource;
std::optional<std::uint32_t> defaultSourceId;
std::map<std::string, std::uint32_t> movedApplications;
std::map<std::string, std::uint32_t> movedPassthroughApplications;