summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2006-08-19 23:06:45 +0000
committerLennart Poettering <lennart@poettering.net>2006-08-19 23:06:45 +0000
commitbffde5da05806ed1801b29b0440e9f542b3a6017 (patch)
tree0cacafba7b2ba230892cd3e7a0c9c7c304d24e59
parentbf62e77f71733cd458df6fc02c6d9eda82a8e0c4 (diff)
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 git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1303 fefdeb5f-60dc-0310-8127-8f9354f1896f
-rw-r--r--src/pulsecore/protocol-esound.c21
-rw-r--r--src/pulsecore/protocol-native.c34
2 files changed, 31 insertions, 24 deletions
diff --git a/src/pulsecore/protocol-esound.c b/src/pulsecore/protocol-esound.c
index c96a98b9..80aeb27b 100644
--- a/src/pulsecore/protocol-esound.c
+++ b/src/pulsecore/protocol-esound.c
@@ -327,7 +327,7 @@ static int esd_proto_stream_play(struct connection *c, PA_GCC_UNUSED esd_proto_t
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 @@ static int esd_proto_stream_play(struct connection *c, PA_GCC_UNUSED esd_proto_t
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_play(struct connection *c, PA_GCC_UNUSED esd_proto_t
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 @@ static int esd_proto_stream_record(struct connection *c, esd_proto_t request, co
}
} 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;
+ }
}
}
diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c
index 40a83973..0f015071 100644
--- a/src/pulsecore/protocol-native.c
+++ b/src/pulsecore/protocol-native.c
@@ -319,7 +319,7 @@ static struct record_stream* record_stream_new(
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 @@ static struct record_stream* record_stream_new(
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 @@ static struct playback_stream* playback_stream_new(
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 @@ static struct playback_stream* playback_stream_new(
}
/* 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 @@ static struct playback_stream* playback_stream_new(
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 @@ static void command_create_playback_stream(PA_GCC_UNUSED pa_pdispatch *pd, PA_GC
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 @@ static void command_create_playback_stream(PA_GCC_UNUSED pa_pdispatch *pd, PA_GC
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 @@ static void command_create_record_stream(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_
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 @@ static void command_create_record_stream(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_
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);