diff options
author | Wim Taymans <wtaymans@redhat.com> | 2015-10-19 15:46:22 +0200 |
---|---|---|
committer | Wim Taymans <wtaymans@redhat.com> | 2015-10-19 15:46:22 +0200 |
commit | 1b203fe6bcc8bba1db1911fd4dbf225f36a6dbb9 (patch) | |
tree | 106ffbadf0f996a2bd56733f71ec7d835aaaf8b4 | |
parent | f8cd444de0c6dc46cbb7d3d5a0f50b398a60c3bb (diff) |
protocol-native: only allow flat volumes for control centerflat-volume-privilege-hack
This is a hack to only allow the volume control to see and modify
flat volumes. The apps all see non-flat volumes and can only change
the volume relative to the master volume.
-rw-r--r-- | src/pulsecore/protocol-native.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c index 145db0420..7a9d08f18 100644 --- a/src/pulsecore/protocol-native.c +++ b/src/pulsecore/protocol-native.c @@ -2009,7 +2009,7 @@ static void command_create_playback_stream(pa_pdispatch *pd, uint32_t command, u volume_set = true, muted_set = false, fail_on_suspend = false, - relative_volume = false, + relative_volume = true, passthrough = false; pa_sink_input_flags_t flags = 0; @@ -2110,6 +2110,7 @@ static void command_create_playback_stream(pa_pdispatch *pd, uint32_t command, u protocol_error(c); goto finish; } + relative_volume = 1; } if (c->version >= 18) { @@ -3424,15 +3425,20 @@ static void sink_input_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t, pa_usec_t sink_latency; pa_cvolume v; bool has_volume = false; + const char *client_name; + bool is_privileged = false; pa_assert(t); pa_sink_input_assert_ref(s); fixup_sample_spec(c, &fixed_ss, &s->sample_spec); + client_name = pa_strnull(pa_proplist_gets(c->client->proplist, PA_PROP_APPLICATION_PROCESS_BINARY)); + is_privileged = strcmp (client_name, "gnome-control-center") == 0; + has_volume = pa_sink_input_is_volume_readable(s); if (has_volume) - pa_sink_input_get_volume(s, &v, true); + pa_sink_input_get_volume(s, &v, is_privileged); else pa_cvolume_reset(&v, fixed_ss.channels); @@ -3860,13 +3866,16 @@ static void command_set_volume( pa_log_debug("Client %s changes volume of source %s.", client_name, source->name); pa_source_set_volume(source, &volume, true, true); } else if (si) { + bool is_privileged; CHECK_VALIDITY(c->pstream, si->volume_writable, tag, PA_ERR_BADSTATE); CHECK_VALIDITY(c->pstream, volume.channels == 1 || pa_cvolume_compatible(&volume, &si->sample_spec), tag, PA_ERR_INVALID); + is_privileged = strcmp (client_name, "gnome-control-center") == 0; + pa_log_debug("Client %s changes volume of sink input %s.", client_name, pa_strnull(pa_proplist_gets(si->proplist, PA_PROP_MEDIA_NAME))); - pa_sink_input_set_volume(si, &volume, true, true); + pa_sink_input_set_volume(si, &volume, true, is_privileged); } else if (so) { CHECK_VALIDITY(c->pstream, so->volume_writable, tag, PA_ERR_BADSTATE); CHECK_VALIDITY(c->pstream, volume.channels == 1 || pa_cvolume_compatible(&volume, &so->sample_spec), tag, PA_ERR_INVALID); |