]> code.delx.au - pulseaudio/blobdiff - src/pulsecore/protocol-native.c
sink-input, source-output: Remove redundant get_mute() functions
[pulseaudio] / src / pulsecore / protocol-native.c
index 86898e8c22ae89bb552e24b499f1235caa9048cc..96df383da6b1c61d9b066dfb5e80b62e468966a5 100644 (file)
@@ -3366,7 +3366,7 @@ static void sink_input_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t,
     pa_tagstruct_puts(t, pa_resample_method_to_string(pa_sink_input_get_resample_method(s)));
     pa_tagstruct_puts(t, s->driver);
     if (c->version >= 11)
-        pa_tagstruct_put_boolean(t, pa_sink_input_get_mute(s));
+        pa_tagstruct_put_boolean(t, s->muted);
     if (c->version >= 13)
         pa_tagstruct_put_proplist(t, s->proplist);
     if (c->version >= 19)
@@ -3413,7 +3413,7 @@ static void source_output_fill_tagstruct(pa_native_connection *c, pa_tagstruct *
         pa_tagstruct_put_boolean(t, (pa_source_output_get_state(s) == PA_SOURCE_OUTPUT_CORKED));
     if (c->version >= 22) {
         pa_tagstruct_put_cvolume(t, &v);
-        pa_tagstruct_put_boolean(t, pa_source_output_get_mute(s));
+        pa_tagstruct_put_boolean(t, s->muted);
         pa_tagstruct_put_boolean(t, has_volume);
         pa_tagstruct_put_boolean(t, s->volume_writable);
         pa_tagstruct_put_format_info(t, s->format);
@@ -3785,6 +3785,7 @@ static void command_set_volume(
                      pa_strnull(pa_proplist_gets(si->proplist, PA_PROP_MEDIA_NAME)));
         pa_sink_input_set_volume(si, &volume, true, true);
     } 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);
 
         pa_log_debug("Client %s changes volume of source output %s.",
@@ -4112,7 +4113,7 @@ static void command_update_stream_sample_rate(pa_pdispatch *pd, uint32_t command
     }
 
     CHECK_VALIDITY(c->pstream, c->authorized, tag, PA_ERR_ACCESS);
-    CHECK_VALIDITY(c->pstream, rate > 0 && rate <= PA_RATE_MAX, tag, PA_ERR_INVALID);
+    CHECK_VALIDITY(c->pstream, pa_sample_rate_valid(rate), tag, PA_ERR_INVALID);
 
     if (command == PA_COMMAND_UPDATE_PLAYBACK_STREAM_SAMPLE_RATE) {
         playback_stream *s;
@@ -4666,8 +4667,9 @@ static void command_extension(pa_pdispatch *pd, uint32_t command, uint32_t tag,
 static void command_set_card_profile(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
     pa_native_connection *c = PA_NATIVE_CONNECTION(userdata);
     uint32_t idx = PA_INVALID_INDEX;
-    const char *name = NULL, *profile = NULL;
+    const char *name = NULL, *profile_name = NULL;
     pa_card *card = NULL;
+    pa_card_profile *profile;
     int ret;
 
     pa_native_connection_assert_ref(c);
@@ -4675,7 +4677,7 @@ static void command_set_card_profile(pa_pdispatch *pd, uint32_t command, uint32_
 
     if (pa_tagstruct_getu32(t, &idx) < 0 ||
         pa_tagstruct_gets(t, &name) < 0 ||
-        pa_tagstruct_gets(t, &profile) < 0 ||
+        pa_tagstruct_gets(t, &profile_name) < 0 ||
         !pa_tagstruct_eof(t)) {
         protocol_error(c);
         return;
@@ -4684,6 +4686,7 @@ static void command_set_card_profile(pa_pdispatch *pd, uint32_t command, uint32_
     CHECK_VALIDITY(c->pstream, c->authorized, tag, PA_ERR_ACCESS);
     CHECK_VALIDITY(c->pstream, !name || pa_namereg_is_valid_name(name), tag, PA_ERR_INVALID);
     CHECK_VALIDITY(c->pstream, (idx != PA_INVALID_INDEX) ^ (name != NULL), tag, PA_ERR_INVALID);
+    CHECK_VALIDITY(c->pstream, profile_name, tag, PA_ERR_INVALID);
 
     if (idx != PA_INVALID_INDEX)
         card = pa_idxset_get_by_index(c->protocol->core->cards, idx);
@@ -4692,6 +4695,10 @@ static void command_set_card_profile(pa_pdispatch *pd, uint32_t command, uint32_
 
     CHECK_VALIDITY(c->pstream, card, tag, PA_ERR_NOENTITY);
 
+    profile = pa_hashmap_get(card->profiles, profile_name);
+
+    CHECK_VALIDITY(c->pstream, profile, tag, PA_ERR_NOENTITY);
+
     if ((ret = pa_card_set_profile(card, profile, true)) < 0) {
         pa_pstream_send_error(c->pstream, tag, -ret);
         return;
@@ -4739,7 +4746,7 @@ static void command_set_sink_or_source_port(pa_pdispatch *pd, uint32_t command,
     } else {
         pa_source *source;
 
-        pa_assert(command = PA_COMMAND_SET_SOURCE_PORT);
+        pa_assert(command == PA_COMMAND_SET_SOURCE_PORT);
 
         if (idx != PA_INVALID_INDEX)
             source = pa_idxset_get_by_index(c->protocol->core->sources, idx);
@@ -4774,6 +4781,7 @@ static void command_set_port_latency_offset(pa_pdispatch *pd, uint32_t command,
         pa_tagstruct_gets64(t, &offset) < 0 ||
         !pa_tagstruct_eof(t)) {
         protocol_error(c);
+        return;
     }
 
     CHECK_VALIDITY(c->pstream, c->authorized, tag, PA_ERR_ACCESS);