[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v0.9.11-120-gb8ba2de

Lennart Poettering gitmailer-noreply at 0pointer.de
Mon Aug 18 08:49:54 PDT 2008


This is an automated email from the git hooks/post-receive script. It was
generated because of a push to the "PulseAudio Sound Server" repository.

The master branch has been updated
      from  74719c24f561cd04ba430a69a8885e7b4a05edb6 (commit)

- Log -----------------------------------------------------------------
b8ba2de... restore volume/device for streams only when it wasn't set before
ec62596... allow clients to not specify the volume for their streams
c35d1bb... rework validity checking of sink/source/... names
d315dcf... save a bit of memory
67858c6... fix type error
-----------------------------------------------------------------------

Summary of changes:
 PROTOCOL                            |    4 ++
 src/modules/module-stream-restore.c |   29 +++++++++----
 src/modules/rtp/module-rtp-send.c   |   12 ++++--
 src/pulse/stream.c                  |   12 +++++
 src/pulsecore/protocol-native.c     |   77 +++++++++++++++++++++++++---------
 src/pulsecore/sink-input.h          |   18 ++++----
 src/pulsecore/sink.h                |   15 ++++---
 src/pulsecore/source-output.h       |    7 ++-
 src/pulsecore/source.h              |   15 ++++---
 9 files changed, 130 insertions(+), 59 deletions(-)

-----------------------------------------------------------------------

commit 67858c6e46b6795893ef1337bef1d86c018cdd9e
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Aug 18 17:36:59 2008 +0200

    fix type error

diff --git a/src/modules/rtp/module-rtp-send.c b/src/modules/rtp/module-rtp-send.c
index aad2126..1423cbc 100644
--- a/src/modules/rtp/module-rtp-send.c
+++ b/src/modules/rtp/module-rtp-send.c
@@ -170,7 +170,7 @@ int pa__init(pa_module*m) {
     pa_modargs *ma = NULL;
     const char *dest;
     uint32_t port = DEFAULT_PORT, mtu;
-    unsigned char ttl = DEFAULT_TTL;
+    uint32_t ttl = DEFAULT_TTL;
     int af, fd = -1, sap_fd = -1;
     pa_source *s;
     pa_sample_spec ss;
@@ -288,9 +288,13 @@ int pa__init(pa_module*m) {
         goto fail;
     }
 
-    if (ttl != DEFAULT_TTL && setsockopt(fd, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof(ttl)) < 0) {
-        pa_log("IP_MULTICAST_TTL failed: %s", pa_cstrerror(errno));
-        goto fail;
+    if (ttl != DEFAULT_TTL) {
+        int _ttl = (int) ttl;
+
+        if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_TTL, &_ttl, sizeof(_ttl)) < 0) {
+            pa_log("IP_MULTICAST_TTL failed: %s", pa_cstrerror(errno));
+            goto fail;
+        }
     }
 
     /* If the socket queue is full, let's drop packets */

commit d315dcf5d98ab89942b78b092e83721d33a51a23
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Aug 18 17:46:57 2008 +0200

    save a bit of memory

diff --git a/src/pulsecore/sink-input.h b/src/pulsecore/sink-input.h
index c07a740..7663f22 100644
--- a/src/pulsecore/sink-input.h
+++ b/src/pulsecore/sink-input.h
@@ -212,19 +212,19 @@ typedef struct pa_sink_input_new_data {
 
     pa_sink *sink;
 
+    pa_resample_method_t resample_method;
+
+    pa_sink_input *sync_base;
+
     pa_sample_spec sample_spec;
-    pa_bool_t sample_spec_is_set;
     pa_channel_map channel_map;
-    pa_bool_t channel_map_is_set;
-
     pa_cvolume volume;
-    pa_bool_t volume_is_set;
-    pa_bool_t muted;
-    pa_bool_t muted_is_set;
-
-    pa_resample_method_t resample_method;
+    pa_bool_t muted:1;
 
-    pa_sink_input *sync_base;
+    pa_bool_t sample_spec_is_set:1;
+    pa_bool_t channel_map_is_set:1;
+    pa_bool_t volume_is_set:1;
+    pa_bool_t muted_is_set:1;
 } pa_sink_input_new_data;
 
 pa_sink_input_new_data* pa_sink_input_new_data_init(pa_sink_input_new_data *data);
diff --git a/src/pulsecore/sink.h b/src/pulsecore/sink.h
index 0aed8bc..672bdd3 100644
--- a/src/pulsecore/sink.h
+++ b/src/pulsecore/sink.h
@@ -180,21 +180,22 @@ typedef enum pa_sink_message {
 
 typedef struct pa_sink_new_data {
     char *name;
-    pa_bool_t namereg_fail;
     pa_proplist *proplist;
 
     const char *driver;
     pa_module *module;
 
     pa_sample_spec sample_spec;
-    pa_bool_t sample_spec_is_set;
     pa_channel_map channel_map;
-    pa_bool_t channel_map_is_set;
-
     pa_cvolume volume;
-    pa_bool_t volume_is_set;
-    pa_bool_t muted;
-    pa_bool_t muted_is_set;
+    pa_bool_t muted :1;
+
+    pa_bool_t sample_spec_is_set:1;
+    pa_bool_t channel_map_is_set:1;
+    pa_bool_t volume_is_set:1;
+    pa_bool_t muted_is_set:1;
+
+    pa_bool_t namereg_fail:1;
 } pa_sink_new_data;
 
 pa_sink_new_data* pa_sink_new_data_init(pa_sink_new_data *data);
diff --git a/src/pulsecore/source-output.h b/src/pulsecore/source-output.h
index 61825b2..a7aac81 100644
--- a/src/pulsecore/source-output.h
+++ b/src/pulsecore/source-output.h
@@ -174,12 +174,13 @@ typedef struct pa_source_output_new_data {
 
     pa_source *source;
 
+    pa_resample_method_t resample_method;
+
     pa_sample_spec sample_spec;
-    pa_bool_t sample_spec_is_set;
     pa_channel_map channel_map;
-    pa_bool_t channel_map_is_set;
 
-    pa_resample_method_t resample_method;
+    pa_bool_t sample_spec_is_set:1;
+    pa_bool_t channel_map_is_set:1;
 } pa_source_output_new_data;
 
 pa_source_output_new_data* pa_source_output_new_data_init(pa_source_output_new_data *data);
diff --git a/src/pulsecore/source.h b/src/pulsecore/source.h
index 706ff1b..cae7869 100644
--- a/src/pulsecore/source.h
+++ b/src/pulsecore/source.h
@@ -168,21 +168,22 @@ typedef enum pa_source_message {
 
 typedef struct pa_source_new_data {
     char *name;
-    pa_bool_t namereg_fail;
     pa_proplist *proplist;
 
     const char *driver;
     pa_module *module;
 
     pa_sample_spec sample_spec;
-    pa_bool_t sample_spec_is_set;
     pa_channel_map channel_map;
-    pa_bool_t channel_map_is_set;
-
     pa_cvolume volume;
-    pa_bool_t volume_is_set;
-    pa_bool_t muted;
-    pa_bool_t muted_is_set;
+    pa_bool_t muted:1;
+
+    pa_bool_t volume_is_set:1;
+    pa_bool_t muted_is_set:1;
+    pa_bool_t sample_spec_is_set:1;
+    pa_bool_t channel_map_is_set:1;
+
+    pa_bool_t namereg_fail:1;
 } pa_source_new_data;
 
 pa_source_new_data* pa_source_new_data_init(pa_source_new_data *data);

commit c35d1bbec3d6dab9acd9c6f57688fb05cbd3dcc9
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Aug 18 17:48:04 2008 +0200

    rework validity checking of sink/source/... names

diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c
index 27e66b2..3c54002 100644
--- a/src/pulsecore/protocol-native.c
+++ b/src/pulsecore/protocol-native.c
@@ -1621,7 +1621,9 @@ static void command_create_playback_stream(pa_pdispatch *pd, uint32_t command, u
     }
 
     CHECK_VALIDITY(c->pstream, c->authorized, tag, PA_ERR_ACCESS);
-    CHECK_VALIDITY(c->pstream, sink_index != PA_INVALID_INDEX || !sink_name || (*sink_name && pa_utf8_valid(sink_name)), tag, PA_ERR_INVALID);
+    CHECK_VALIDITY(c->pstream, !sink_name || pa_namereg_is_valid_name(sink_name), tag, PA_ERR_INVALID);
+    CHECK_VALIDITY(c->pstream, sink_index == PA_INVALID_INDEX || !sink_name, tag, PA_ERR_INVALID);
+    CHECK_VALIDITY(c->pstream, !sink_name || sink_index == PA_INVALID_INDEX, tag, PA_ERR_INVALID);
     CHECK_VALIDITY(c->pstream, pa_channel_map_valid(&map), tag, PA_ERR_INVALID);
     CHECK_VALIDITY(c->pstream, pa_sample_spec_valid(&ss), tag, PA_ERR_INVALID);
     CHECK_VALIDITY(c->pstream, pa_cvolume_valid(&volume), tag, PA_ERR_INVALID);
@@ -1835,9 +1837,11 @@ static void command_create_record_stream(pa_pdispatch *pd, uint32_t command, uin
     }
 
     CHECK_VALIDITY(c->pstream, c->authorized, tag, PA_ERR_ACCESS);
+    CHECK_VALIDITY(c->pstream, !source_name || pa_namereg_is_valid_name(source_name), tag, PA_ERR_INVALID);
+    CHECK_VALIDITY(c->pstream, source_index == PA_INVALID_INDEX || !source_name, tag, PA_ERR_INVALID);
+    CHECK_VALIDITY(c->pstream, !source_name || source_index == PA_INVALID_INDEX, tag, PA_ERR_INVALID);
     CHECK_VALIDITY(c->pstream, pa_sample_spec_valid(&ss), tag, PA_ERR_INVALID);
     CHECK_VALIDITY(c->pstream, pa_channel_map_valid(&map), tag, PA_ERR_INVALID);
-    CHECK_VALIDITY(c->pstream, source_index != PA_INVALID_INDEX || !source_name || (*source_name && pa_utf8_valid(source_name)), tag, PA_ERR_INVALID);
     CHECK_VALIDITY(c->pstream, map.channels == ss.channels, tag, PA_ERR_INVALID);
 
     p = pa_proplist_new();
@@ -2158,7 +2162,7 @@ static void command_lookup(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_
     }
 
     CHECK_VALIDITY(c->pstream, c->authorized, tag, PA_ERR_ACCESS);
-    CHECK_VALIDITY(c->pstream, name && *name && pa_utf8_valid(name), tag, PA_ERR_INVALID);
+    CHECK_VALIDITY(c->pstream, name && pa_namereg_is_valid_name(name), tag, PA_ERR_INVALID);
 
     if (command == PA_COMMAND_LOOKUP_SINK) {
         pa_sink *sink;
@@ -2349,7 +2353,7 @@ static void command_create_upload_stream(pa_pdispatch *pd, uint32_t command, uin
         if (!(name = pa_proplist_gets(p, PA_PROP_EVENT_ID)))
             name = pa_proplist_gets(p, PA_PROP_MEDIA_NAME);
 
-    CHECK_VALIDITY(c->pstream, name && *name && pa_utf8_valid(name), tag, PA_ERR_INVALID);
+    CHECK_VALIDITY(c->pstream, name && pa_namereg_is_valid_name(name), tag, PA_ERR_INVALID);
 
     s = upload_stream_new(c, &ss, &map, name, length, p);
     pa_proplist_free(p);
@@ -2414,8 +2418,10 @@ static void command_play_sample(pa_pdispatch *pd, uint32_t command, uint32_t tag
         return;
     }
 
-    CHECK_VALIDITY(c->pstream, sink_index != PA_INVALID_INDEX || !sink_name || (*sink_name && pa_utf8_valid(name)), tag, PA_ERR_INVALID);
-    CHECK_VALIDITY(c->pstream, name && *name && pa_utf8_valid(name), tag, PA_ERR_INVALID);
+    CHECK_VALIDITY(c->pstream, !sink_name || pa_namereg_is_valid_name(sink_name), tag, PA_ERR_INVALID);
+    CHECK_VALIDITY(c->pstream, sink_index == PA_INVALID_INDEX || !sink_name, tag, PA_ERR_INVALID);
+    CHECK_VALIDITY(c->pstream, !sink_name || sink_index == PA_INVALID_INDEX, tag, PA_ERR_INVALID);
+    CHECK_VALIDITY(c->pstream, name && pa_namereg_is_valid_name(name), tag, PA_ERR_INVALID);
 
     if (sink_index != PA_INVALID_INDEX)
         sink = pa_idxset_get_by_index(c->protocol->core->sinks, sink_index);
@@ -2465,7 +2471,7 @@ static void command_remove_sample(pa_pdispatch *pd, uint32_t command, uint32_t t
     }
 
     CHECK_VALIDITY(c->pstream, c->authorized, tag, PA_ERR_ACCESS);
-    CHECK_VALIDITY(c->pstream, name && *name && pa_utf8_valid(name), tag, PA_ERR_INVALID);
+    CHECK_VALIDITY(c->pstream, name && pa_namereg_is_valid_name(name), tag, PA_ERR_INVALID);
 
     if (pa_scache_remove_item(c->protocol->core, name) < 0) {
         pa_pstream_send_error(c->pstream, tag, PA_ERR_NOENTITY);
@@ -2686,7 +2692,10 @@ static void command_get_info(pa_pdispatch *pd, uint32_t command, uint32_t tag, p
     }
 
     CHECK_VALIDITY(c->pstream, c->authorized, tag, PA_ERR_ACCESS);
-    CHECK_VALIDITY(c->pstream, idx != PA_INVALID_INDEX || !name || (*name && pa_utf8_valid(name)), tag, PA_ERR_INVALID);
+    CHECK_VALIDITY(c->pstream, !name || pa_namereg_is_valid_name(name), tag, PA_ERR_INVALID);
+    CHECK_VALIDITY(c->pstream, idx != PA_INVALID_INDEX || name, tag, PA_ERR_INVALID);
+    CHECK_VALIDITY(c->pstream, idx == PA_INVALID_INDEX || !name, tag, PA_ERR_INVALID);
+    CHECK_VALIDITY(c->pstream, !name || idx == PA_INVALID_INDEX, tag, PA_ERR_INVALID);
 
     if (command == PA_COMMAND_GET_SINK_INFO) {
         if (idx != PA_INVALID_INDEX)
@@ -2903,7 +2912,10 @@ static void command_set_volume(
     }
 
     CHECK_VALIDITY(c->pstream, c->authorized, tag, PA_ERR_ACCESS);
-    CHECK_VALIDITY(c->pstream, idx != PA_INVALID_INDEX || !name || (*name && pa_utf8_valid(name)), tag, PA_ERR_INVALID);
+    CHECK_VALIDITY(c->pstream, !name || pa_namereg_is_valid_name(name), tag, PA_ERR_INVALID);
+    CHECK_VALIDITY(c->pstream, idx != PA_INVALID_INDEX || name, tag, PA_ERR_INVALID);
+    CHECK_VALIDITY(c->pstream, idx == PA_INVALID_INDEX || !name, tag, PA_ERR_INVALID);
+    CHECK_VALIDITY(c->pstream, !name || idx == PA_INVALID_INDEX, tag, PA_ERR_INVALID);
     CHECK_VALIDITY(c->pstream, pa_cvolume_valid(&volume), tag, PA_ERR_INVALID);
 
     switch (command) {
@@ -2970,7 +2982,10 @@ static void command_set_mute(
     }
 
     CHECK_VALIDITY(c->pstream, c->authorized, tag, PA_ERR_ACCESS);
-    CHECK_VALIDITY(c->pstream, idx != PA_INVALID_INDEX || !name || (*name && pa_utf8_valid(name)), tag, PA_ERR_INVALID);
+    CHECK_VALIDITY(c->pstream, !name || pa_namereg_is_valid_name(name), tag, PA_ERR_INVALID);
+    CHECK_VALIDITY(c->pstream, idx != PA_INVALID_INDEX || name, tag, PA_ERR_INVALID);
+    CHECK_VALIDITY(c->pstream, idx == PA_INVALID_INDEX || !name, tag, PA_ERR_INVALID);
+    CHECK_VALIDITY(c->pstream, !name || idx == PA_INVALID_INDEX, tag, PA_ERR_INVALID);
 
     switch (command) {
 
@@ -3427,7 +3442,7 @@ static void command_set_default_sink_or_source(pa_pdispatch *pd, uint32_t comman
     }
 
     CHECK_VALIDITY(c->pstream, c->authorized, tag, PA_ERR_ACCESS);
-    CHECK_VALIDITY(c->pstream, !s || (*s && pa_utf8_valid(s)), tag, PA_ERR_INVALID);
+    CHECK_VALIDITY(c->pstream, !s || pa_namereg_is_valid_name(s), tag, PA_ERR_INVALID);
 
     pa_namereg_set_default(c->protocol->core, s, command == PA_COMMAND_SET_DEFAULT_SOURCE ? PA_NAMEREG_SOURCE : PA_NAMEREG_SINK);
     pa_pstream_send_simple_ack(c->pstream, tag);
@@ -3713,14 +3728,14 @@ static void command_get_autoload_info_list(pa_pdispatch *pd, uint32_t command, u
 static void command_move_stream(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, idx_device = PA_INVALID_INDEX;
-    const char *name = NULL;
+    const char *name_device = NULL;
 
     pa_native_connection_assert_ref(c);
     pa_assert(t);
 
     if (pa_tagstruct_getu32(t, &idx) < 0 ||
         pa_tagstruct_getu32(t, &idx_device) < 0 ||
-        pa_tagstruct_gets(t, &name) < 0 ||
+        pa_tagstruct_gets(t, &name_device) < 0 ||
         !pa_tagstruct_eof(t)) {
         protocol_error(c);
         return;
@@ -3728,7 +3743,11 @@ static void command_move_stream(pa_pdispatch *pd, uint32_t command, uint32_t tag
 
     CHECK_VALIDITY(c->pstream, c->authorized, tag, PA_ERR_ACCESS);
     CHECK_VALIDITY(c->pstream, idx != PA_INVALID_INDEX, tag, PA_ERR_INVALID);
-    CHECK_VALIDITY(c->pstream, idx_device != PA_INVALID_INDEX || !name || (*name && pa_utf8_valid(name)), tag, PA_ERR_INVALID);
+
+    CHECK_VALIDITY(c->pstream, !name_device || pa_namereg_is_valid_name(name_device), tag, PA_ERR_INVALID);
+    CHECK_VALIDITY(c->pstream, idx_device != PA_INVALID_INDEX || name_device, tag, PA_ERR_INVALID);
+    CHECK_VALIDITY(c->pstream, idx_device == PA_INVALID_INDEX || !name_device, tag, PA_ERR_INVALID);
+    CHECK_VALIDITY(c->pstream, !name_device || idx_device == PA_INVALID_INDEX, tag, PA_ERR_INVALID);
 
     if (command == PA_COMMAND_MOVE_SINK_INPUT) {
         pa_sink_input *si = NULL;
@@ -3739,7 +3758,7 @@ static void command_move_stream(pa_pdispatch *pd, uint32_t command, uint32_t tag
         if (idx_device != PA_INVALID_INDEX)
             sink = pa_idxset_get_by_index(c->protocol->core->sinks, idx_device);
         else
-            sink = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_SINK, 1);
+            sink = pa_namereg_get(c->protocol->core, name_device, PA_NAMEREG_SINK, 1);
 
         CHECK_VALIDITY(c->pstream, si && sink, tag, PA_ERR_NOENTITY);
 
@@ -3758,7 +3777,7 @@ static void command_move_stream(pa_pdispatch *pd, uint32_t command, uint32_t tag
         if (idx_device != PA_INVALID_INDEX)
             source = pa_idxset_get_by_index(c->protocol->core->sources, idx_device);
         else
-            source = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_SOURCE, 1);
+            source = pa_namereg_get(c->protocol->core, name_device, PA_NAMEREG_SOURCE, 1);
 
         CHECK_VALIDITY(c->pstream, so && source, tag, PA_ERR_NOENTITY);
 
@@ -3789,7 +3808,10 @@ static void command_suspend(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa
     }
 
     CHECK_VALIDITY(c->pstream, c->authorized, tag, PA_ERR_ACCESS);
-    CHECK_VALIDITY(c->pstream, idx != PA_INVALID_INDEX || !name || !*name || pa_utf8_valid(name), tag, PA_ERR_INVALID);
+    CHECK_VALIDITY(c->pstream, !name || pa_namereg_is_valid_name(name), tag, PA_ERR_INVALID);
+    CHECK_VALIDITY(c->pstream, idx != PA_INVALID_INDEX || name, tag, PA_ERR_INVALID);
+    CHECK_VALIDITY(c->pstream, idx == PA_INVALID_INDEX || !name, tag, PA_ERR_INVALID);
+    CHECK_VALIDITY(c->pstream, !name || idx == PA_INVALID_INDEX, tag, PA_ERR_INVALID);
 
     if (command == PA_COMMAND_SUSPEND_SINK) {
 
@@ -3862,7 +3884,10 @@ static void command_extension(pa_pdispatch *pd, uint32_t command, uint32_t tag,
     }
 
     CHECK_VALIDITY(c->pstream, c->authorized, tag, PA_ERR_ACCESS);
-    CHECK_VALIDITY(c->pstream, idx != PA_INVALID_INDEX || !name || !*name || pa_utf8_valid(name), tag, PA_ERR_INVALID);
+    CHECK_VALIDITY(c->pstream, !name || pa_utf8_valid(name), tag, PA_ERR_INVALID);
+    CHECK_VALIDITY(c->pstream, idx != PA_INVALID_INDEX || name, tag, PA_ERR_INVALID);
+    CHECK_VALIDITY(c->pstream, idx == PA_INVALID_INDEX || !name, tag, PA_ERR_INVALID);
+    CHECK_VALIDITY(c->pstream, !name || idx == PA_INVALID_INDEX, tag, PA_ERR_INVALID);
 
     if (idx != PA_INVALID_INDEX)
         m = pa_idxset_get_by_index(c->protocol->core->modules, idx);

commit ec62596f49b6c7bede5e9b3057a58507db230f61
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Aug 18 17:49:18 2008 +0200

    allow clients to not specify the volume for their streams

diff --git a/PROTOCOL b/PROTOCOL
index 4885b3d..581eeef 100644
--- a/PROTOCOL
+++ b/PROTOCOL
@@ -140,3 +140,7 @@ new message:
 new message:
 
   PA_COMMAND_EXTENSION
+
+PA_COMMAND_CREATE_RECORD_STREAM, PA_COMMAND_CREATE_PLAYBACK_STREAM:
+
+  bool volume_set at the end
diff --git a/src/pulse/stream.c b/src/pulse/stream.c
index 82eff4a..6769fc0 100644
--- a/src/pulse/stream.c
+++ b/src/pulse/stream.c
@@ -865,6 +865,7 @@ static int create_stream(
 
     pa_tagstruct *t;
     uint32_t tag;
+    pa_bool_t volume_set = FALSE;
 
     pa_assert(s);
     pa_assert(PA_REFCNT_VALUE(s) >= 1);
@@ -957,6 +958,8 @@ static int create_stream(
                 PA_TAG_U32, s->syncid,
                 PA_TAG_INVALID);
 
+        volume_set = !!volume;
+
         if (!volume)
             volume = pa_cvolume_reset(&cv, s->sample_spec.channels);
 
@@ -994,6 +997,15 @@ static int create_stream(
             pa_tagstruct_putu32(t, s->direct_on_input);
     }
 
+    if (s->context->version >= 14 &&
+        s->direction == PA_STREAM_PLAYBACK) {
+
+        pa_tagstruct_put(
+                t,
+                PA_TAG_BOOLEAN, volume_set,
+                PA_TAG_INVALID);
+    }
+
     pa_pstream_send_tagstruct(s->context->pstream, t);
     pa_pdispatch_register_reply(s->context->pdispatch, tag, DEFAULT_TIMEOUT, pa_create_stream_callback, s, NULL);
 
diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c
index 3c54002..b746602 100644
--- a/src/pulsecore/protocol-native.c
+++ b/src/pulsecore/protocol-native.c
@@ -883,7 +883,6 @@ static playback_stream* playback_stream_new(
     pa_assert(tlength);
     pa_assert(prebuf);
     pa_assert(minreq);
-    pa_assert(volume);
     pa_assert(missing);
     pa_assert(p);
 
@@ -916,7 +915,8 @@ static playback_stream* playback_stream_new(
     data.sink = sink;
     pa_sink_input_new_data_set_sample_spec(&data, ss);
     pa_sink_input_new_data_set_channel_map(&data, map);
-    pa_sink_input_new_data_set_volume(&data, volume);
+    if (volume)
+        pa_sink_input_new_data_set_volume(&data, volume);
     pa_sink_input_new_data_set_muted(&data, muted);
     data.sync_base = ssync ? ssync->sink_input : NULL;
 
@@ -1596,6 +1596,7 @@ static void command_create_playback_stream(pa_pdispatch *pd, uint32_t command, u
 
     pa_sink_input_flags_t flags = 0;
     pa_proplist *p;
+    pa_bool_t volume_set = TRUE;
 
     pa_native_connection_assert_ref(c);
     pa_assert(t);
@@ -1662,6 +1663,15 @@ static void command_create_playback_stream(pa_pdispatch *pd, uint32_t command, u
         }
     }
 
+    if (c->version >= 14) {
+
+        if (pa_tagstruct_get_boolean(t, &volume_set) < 0) {
+            protocol_error(c);
+            pa_proplist_free(p);
+            return;
+        }
+    }
+
     if (!pa_tagstruct_eof(t)) {
         protocol_error(c);
         pa_proplist_free(p);
@@ -1695,7 +1705,7 @@ static void command_create_playback_stream(pa_pdispatch *pd, uint32_t command, u
         (no_move ?  PA_SINK_INPUT_DONT_MOVE : 0) |
         (variable_rate ?  PA_SINK_INPUT_VARIABLE_RATE : 0);
 
-    s = playback_stream_new(c, sink, &ss, &map, &maxlength, &tlength, &prebuf, &minreq, &volume, muted, syncid, &missing, flags, p, adjust_latency);
+    s = playback_stream_new(c, sink, &ss, &map, &maxlength, &tlength, &prebuf, &minreq, volume_set ? &volume : NULL, muted, syncid, &missing, flags, p, adjust_latency);
     pa_proplist_free(p);
 
     CHECK_VALIDITY(c->pstream, s, tag, PA_ERR_INVALID);

commit b8ba2de7ddfea2b0fa53dc7e8614d16b16ec1915
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Aug 18 17:49:47 2008 +0200

    restore volume/device for streams only when it wasn't set before

diff --git a/src/modules/module-stream-restore.c b/src/modules/module-stream-restore.c
index 73b3250..7bbb47d 100644
--- a/src/modules/module-stream-restore.c
+++ b/src/modules/module-stream-restore.c
@@ -306,8 +306,11 @@ static pa_hook_result_t sink_input_new_hook_callback(pa_core *c, pa_sink_input_n
         if (u->restore_device &&
             (s = pa_namereg_get(c, e->device, PA_NAMEREG_SINK, TRUE))) {
 
-            pa_log_info("Restoring device for stream %s.", name);
-            new_data->sink = s;
+            if (!new_data->sink) {
+                pa_log_info("Restoring device for stream %s.", name);
+                new_data->sink = s;
+            } else
+                pa_log_info("Not restore device for stream %s, because already set.", name);
         }
 
         pa_xfree(e);
@@ -330,13 +333,20 @@ 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) {
-            pa_log_info("Restoring volume for sink input %s.", name);
-            pa_sink_input_new_data_set_volume(new_data, pa_cvolume_remap(&e->volume, &e->channel_map, &new_data->channel_map));
+
+            if (!new_data->volume_is_set) {
+                pa_log_info("Restoring volume for sink input %s.", name);
+                pa_sink_input_new_data_set_volume(new_data, pa_cvolume_remap(&e->volume, &e->channel_map, &new_data->channel_map));
+            } else
+                pa_log_debug("Not restoring volume for sink input %s, because already set.", name);
         }
 
         if (u->restore_muted) {
-            pa_log_info("Restoring mute state for sink input %s.", name);
-            pa_sink_input_new_data_set_muted(new_data, e->muted);
+            if (!new_data->muted_is_set) {
+                pa_log_info("Restoring mute state for sink input %s.", name);
+                pa_sink_input_new_data_set_muted(new_data, e->muted);
+            } else
+                pa_log_debug("Not restoring mute state for sink input %s, because already set.", name);
         }
 
         pa_xfree(e);
@@ -363,8 +373,11 @@ static pa_hook_result_t source_output_new_hook_callback(pa_core *c, pa_source_ou
             !new_data->direct_on_input &&
             (s = pa_namereg_get(c, e->device, PA_NAMEREG_SOURCE, TRUE))) {
 
-            pa_log_info("Restoring device for stream %s.", name);
-            new_data->source = s;
+            if (!new_data->source) {
+                pa_log_info("Restoring device for stream %s.", name);
+                new_data->source = s;
+            } else
+                pa_log_info("Not restroing device for stream %s, because already set", name);
         }
 
         pa_xfree(e);

-- 
hooks/post-receive
PulseAudio Sound Server



More information about the pulseaudio-commits mailing list