mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-06 13:29:56 -05:00
sink-input: Add volume_writable to pa_sink_input.
This is pretty cosmetic change; there's no actual functionality added. Previously the volume_writable information was available through the pa_sink_input_is_volume_writable() function, but I find it cleaner to have a real variable. The sink input introspection variable name was also changed from read_only_volume to volume_writable for consistency.
This commit is contained in:
parent
b358f1c71d
commit
e72e75570c
9 changed files with 27 additions and 47 deletions
|
|
@ -57,7 +57,6 @@ struct pa_dbusiface_stream {
|
|||
pa_proplist *proplist;
|
||||
|
||||
pa_bool_t has_volume;
|
||||
pa_bool_t read_only_volume;
|
||||
|
||||
pa_dbus_protocol *dbus_protocol;
|
||||
pa_subscription *subscription;
|
||||
|
|
@ -357,6 +356,7 @@ static void handle_get_volume(DBusConnection *conn, DBusMessage *msg, void *user
|
|||
|
||||
static void handle_set_volume(DBusConnection *conn, DBusMessage *msg, DBusMessageIter *iter, void *userdata) {
|
||||
pa_dbusiface_stream *s = userdata;
|
||||
pa_bool_t volume_writable = TRUE;
|
||||
DBusMessageIter array_iter;
|
||||
int stream_channels = 0;
|
||||
dbus_uint32_t *volume = NULL;
|
||||
|
|
@ -369,12 +369,14 @@ static void handle_set_volume(DBusConnection *conn, DBusMessage *msg, DBusMessag
|
|||
pa_assert(iter);
|
||||
pa_assert(s);
|
||||
|
||||
if (!s->has_volume || s->read_only_volume) {
|
||||
volume_writable = (s->type == STREAM_TYPE_PLAYBACK) ? s->sink_input->volume_writable : FALSE;
|
||||
|
||||
if (!s->has_volume || !volume_writable) {
|
||||
char *str = stream_to_string(s);
|
||||
|
||||
if (!s->has_volume)
|
||||
pa_dbus_send_error(conn, msg, PA_DBUS_ERROR_NO_SUCH_PROPERTY, "%s doesn't have volume.", str);
|
||||
else if (s->read_only_volume)
|
||||
else if (!volume_writable)
|
||||
pa_dbus_send_error(conn, msg, DBUS_ERROR_ACCESS_DENIED, "%s has read-only volume.", str);
|
||||
pa_xfree(str);
|
||||
|
||||
|
|
@ -853,7 +855,6 @@ pa_dbusiface_stream *pa_dbusiface_stream_new_playback(pa_dbusiface_core *core, p
|
|||
s->sink = pa_sink_ref(sink_input->sink);
|
||||
s->sample_rate = sink_input->sample_spec.rate;
|
||||
s->has_volume = pa_sink_input_is_volume_readable(sink_input);
|
||||
s->read_only_volume = s->has_volume ? !pa_sink_input_is_volume_writable(sink_input) : FALSE;
|
||||
|
||||
if (s->has_volume)
|
||||
pa_sink_input_get_volume(sink_input, &s->volume, TRUE);
|
||||
|
|
@ -891,7 +892,6 @@ pa_dbusiface_stream *pa_dbusiface_stream_new_record(pa_dbusiface_core *core, pa_
|
|||
s->mute = FALSE;
|
||||
s->proplist = pa_proplist_copy(source_output->proplist);
|
||||
s->has_volume = FALSE;
|
||||
s->read_only_volume = FALSE;
|
||||
s->dbus_protocol = pa_dbus_protocol_get(source_output->core);
|
||||
s->subscription = pa_subscription_new(source_output->core, PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT, subscription_cb, s);
|
||||
s->send_event_slot = pa_hook_connect(&source_output->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_SEND_EVENT],
|
||||
|
|
|
|||
|
|
@ -1168,7 +1168,7 @@ static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint3
|
|||
}
|
||||
|
||||
if (sink_input->save_volume) {
|
||||
pa_assert(pa_sink_input_is_volume_writable(sink_input));
|
||||
pa_assert(sink_input->volume_writable);
|
||||
|
||||
entry.channel_map = sink_input->channel_map;
|
||||
pa_sink_input_get_volume(sink_input, &entry.volume, FALSE);
|
||||
|
|
@ -1329,7 +1329,7 @@ static pa_hook_result_t sink_input_fixate_hook_callback(pa_core *c, pa_sink_inpu
|
|||
if ((e = read_entry(u, name))) {
|
||||
|
||||
if (u->restore_volume && e->volume_valid) {
|
||||
if (!pa_sink_input_new_data_is_volume_writable(new_data))
|
||||
if (!new_data->volume_writable)
|
||||
pa_log_debug("Not restoring volume for sink input %s, because its volume can't be changed.", name);
|
||||
else if (new_data->volume_is_set)
|
||||
pa_log_debug("Not restoring volume for sink input %s, because already set.", name);
|
||||
|
|
@ -1619,7 +1619,7 @@ static void apply_entry(struct userdata *u, const char *name, struct entry *e) {
|
|||
}
|
||||
pa_xfree(n);
|
||||
|
||||
if (u->restore_volume && e->volume_valid && pa_sink_input_is_volume_writable(si)) {
|
||||
if (u->restore_volume && e->volume_valid && si->volume_writable) {
|
||||
pa_cvolume v;
|
||||
|
||||
v = e->volume;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue