[pulseaudio-commits] r1303 - in /trunk/src/pulsecore: protocol-esound.c protocol-native.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Sat Aug 19 16:06:48 PDT 2006


Author: lennart
Date: Sun Aug 20 01:06:45 2006
New Revision: 1303

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=1303&root=pulseaudio&view=rev
Log:
If a client leaves the sink/source for a stream unspecified by passing NULL as
sink/source name sink/source we should pass NULL to
pa_sink_input_new()/pa_source_output_new() as too. This allows
hooks to change the sink/source device only if it is left unspecified by the client


Modified:
    trunk/src/pulsecore/protocol-esound.c
    trunk/src/pulsecore/protocol-native.c

Modified: trunk/src/pulsecore/protocol-esound.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/pulsecore/protocol-esound.c?rev=1303&root=pulseaudio&r1=1302&r2=1303&view=diff
==============================================================================
--- trunk/src/pulsecore/protocol-esound.c (original)
+++ trunk/src/pulsecore/protocol-esound.c Sun Aug 20 01:06:45 2006
@@ -327,7 +327,7 @@
     int32_t format, rate;
     pa_sample_spec ss;
     size_t l;
-    pa_sink *sink;
+    pa_sink *sink = NULL;
     pa_sink_input_new_data sdata;
 
     assert(c && length == (sizeof(int32_t)*2+ESD_NAME_MAX));
@@ -344,8 +344,11 @@
     format_esd2native(format, c->swap_byte_order, &ss);
 
     CHECK_VALIDITY(pa_sample_spec_valid(&ss), "Invalid sample specification");
-    sink = pa_namereg_get(c->protocol->core, c->protocol->sink_name, PA_NAMEREG_SINK, 1);
-    CHECK_VALIDITY(sink, "No such sink");
+
+    if (c->protocol->sink_name) {
+        sink = pa_namereg_get(c->protocol->core, c->protocol->sink_name, PA_NAMEREG_SINK, 1);
+        CHECK_VALIDITY(sink, "No such sink");
+    }
 
     strncpy(name, data, sizeof(name));
     name[sizeof(name)-1] = 0;
@@ -397,7 +400,7 @@
 static int esd_proto_stream_record(struct connection *c, esd_proto_t request, const void *data, size_t length) {
     char name[ESD_NAME_MAX], *utf8_name;
     int32_t format, rate;
-    pa_source *source;
+    pa_source *source = NULL;
     pa_sample_spec ss;
     size_t l;
     pa_source_output_new_data sdata;
@@ -431,10 +434,12 @@
         }
     } else {
         assert(request == ESD_PROTO_STREAM_REC);
-        
-        if (!(source = pa_namereg_get(c->protocol->core, c->protocol->source_name, PA_NAMEREG_SOURCE, 1))) {
-            pa_log("no such source.");
-            return -1;
+
+        if (c->protocol->source_name) {
+            if (!(source = pa_namereg_get(c->protocol->core, c->protocol->source_name, PA_NAMEREG_SOURCE, 1))) {
+                pa_log("no such source.");
+                return -1;
+            }
         }
     }
     

Modified: trunk/src/pulsecore/protocol-native.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/pulsecore/protocol-native.c?rev=1303&root=pulseaudio&r1=1302&r2=1303&view=diff
==============================================================================
--- trunk/src/pulsecore/protocol-native.c (original)
+++ trunk/src/pulsecore/protocol-native.c Sun Aug 20 01:06:45 2006
@@ -319,7 +319,7 @@
     size_t base;
     pa_source_output_new_data data;
     
-    assert(c && source && ss && name && maxlength);
+    assert(c && ss && name && maxlength);
 
     pa_source_output_new_data_init(&data);
     data.source = source;
@@ -330,7 +330,7 @@
     data.module = c->protocol->module;
     data.client = c->client;
     
-    if (!(source_output = pa_source_output_new(source->core, &data, 0)))
+    if (!(source_output = pa_source_output_new(c->protocol->core, &data, 0)))
         return NULL;
 
     s = pa_xnew(struct record_stream, 1);
@@ -389,7 +389,7 @@
     int64_t start_index;
     pa_sink_input_new_data data;
     
-    assert(c && sink && ss && name && maxlength);
+    assert(c && ss && name && maxlength);
 
     /* Find syncid group */
     for (ssync = pa_idxset_first(c->output_streams, &idx); ssync; ssync = pa_idxset_next(c->output_streams, &idx)) {
@@ -402,8 +402,8 @@
     }
 
     /* Synced streams must connect to the same sink */
-    if (ssync && ssync->sink_input->sink != sink)
-        return NULL;
+    if (ssync)
+        sink = ssync->sink_input->sink;
 
     pa_sink_input_new_data_init(&data);
     data.sink = sink;
@@ -415,7 +415,7 @@
     data.module = c->protocol->module;
     data.client = c->client;
 
-    if (!(sink_input = pa_sink_input_new(sink->core, &data, 0)))
+    if (!(sink_input = pa_sink_input_new(c->protocol->core, &data, 0)))
         return NULL;
     
     s = pa_xnew(struct playback_stream, 1);
@@ -725,7 +725,7 @@
     pa_sample_spec ss;
     pa_channel_map map;
     pa_tagstruct *reply;
-    pa_sink *sink;
+    pa_sink *sink = NULL;
     pa_cvolume volume;
     int corked;
     
@@ -761,12 +761,13 @@
     CHECK_VALIDITY(c->pstream, map.channels == ss.channels && volume.channels == ss.channels, tag, PA_ERR_INVALID);
     CHECK_VALIDITY(c->pstream, maxlength > 0 && maxlength <= MAX_MEMBLOCKQ_LENGTH, tag, PA_ERR_INVALID);
 
-    if (sink_index != PA_INVALID_INDEX)
+    if (sink_index != PA_INVALID_INDEX) {
         sink = pa_idxset_get_by_index(c->protocol->core->sinks, sink_index);
-    else
+        CHECK_VALIDITY(c->pstream, sink, tag, PA_ERR_NOENTITY);
+    } else if (sink_name) {
         sink = pa_namereg_get(c->protocol->core, sink_name, PA_NAMEREG_SINK, 1);
-
-    CHECK_VALIDITY(c->pstream, sink, tag, PA_ERR_NOENTITY);
+        CHECK_VALIDITY(c->pstream, sink, tag, PA_ERR_NOENTITY);
+    }
 
     s = playback_stream_new(c, sink, &ss, &map, name, maxlength, tlength, prebuf, minreq, &volume, syncid);
     CHECK_VALIDITY(c->pstream, s, tag, PA_ERR_INVALID);
@@ -844,7 +845,7 @@
     pa_sample_spec ss;
     pa_channel_map map;
     pa_tagstruct *reply;
-    pa_source *source;
+    pa_source *source = NULL;
     int corked;
     assert(c && t && c->protocol && c->protocol->core);
     
@@ -869,12 +870,13 @@
     CHECK_VALIDITY(c->pstream, map.channels == ss.channels, tag, PA_ERR_INVALID);
     CHECK_VALIDITY(c->pstream, maxlength <= MAX_MEMBLOCKQ_LENGTH, tag, PA_ERR_INVALID);
 
-    if (source_index != PA_INVALID_INDEX)
+    if (source_index != PA_INVALID_INDEX) {
         source = pa_idxset_get_by_index(c->protocol->core->sources, source_index);
-    else
+        CHECK_VALIDITY(c->pstream, source, tag, PA_ERR_NOENTITY);
+    } else if (source_name) {
         source = pa_namereg_get(c->protocol->core, source_name, PA_NAMEREG_SOURCE, 1);
-
-    CHECK_VALIDITY(c->pstream, source, tag, PA_ERR_NOENTITY);
+        CHECK_VALIDITY(c->pstream, source, tag, PA_ERR_NOENTITY);
+    } 
     
     s = record_stream_new(c, source, &ss, &map, name, maxlength, fragment_size);
     CHECK_VALIDITY(c->pstream, s, tag, PA_ERR_INVALID);




More information about the pulseaudio-commits mailing list