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
This commit is contained in:
Lennart Poettering 2006-08-19 23:06:45 +00:00
parent bf62e77f71
commit bffde5da05
2 changed files with 31 additions and 24 deletions

View file

@ -327,7 +327,7 @@ static int esd_proto_stream_play(struct connection *c, PA_GCC_UNUSED esd_proto_t
int32_t format, rate; int32_t format, rate;
pa_sample_spec ss; pa_sample_spec ss;
size_t l; size_t l;
pa_sink *sink; pa_sink *sink = NULL;
pa_sink_input_new_data sdata; pa_sink_input_new_data sdata;
assert(c && length == (sizeof(int32_t)*2+ESD_NAME_MAX)); 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); format_esd2native(format, c->swap_byte_order, &ss);
CHECK_VALIDITY(pa_sample_spec_valid(&ss), "Invalid sample specification"); 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)); strncpy(name, data, sizeof(name));
name[sizeof(name)-1] = 0; 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) { 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; char name[ESD_NAME_MAX], *utf8_name;
int32_t format, rate; int32_t format, rate;
pa_source *source; pa_source *source = NULL;
pa_sample_spec ss; pa_sample_spec ss;
size_t l; size_t l;
pa_source_output_new_data sdata; 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 { } else {
assert(request == ESD_PROTO_STREAM_REC); assert(request == ESD_PROTO_STREAM_REC);
if (!(source = pa_namereg_get(c->protocol->core, c->protocol->source_name, PA_NAMEREG_SOURCE, 1))) { if (c->protocol->source_name) {
pa_log("no such source."); if (!(source = pa_namereg_get(c->protocol->core, c->protocol->source_name, PA_NAMEREG_SOURCE, 1))) {
return -1; pa_log("no such source.");
return -1;
}
} }
} }

View file

@ -319,7 +319,7 @@ static struct record_stream* record_stream_new(
size_t base; size_t base;
pa_source_output_new_data data; pa_source_output_new_data data;
assert(c && source && ss && name && maxlength); assert(c && ss && name && maxlength);
pa_source_output_new_data_init(&data); pa_source_output_new_data_init(&data);
data.source = source; data.source = source;
@ -330,7 +330,7 @@ static struct record_stream* record_stream_new(
data.module = c->protocol->module; data.module = c->protocol->module;
data.client = c->client; 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; return NULL;
s = pa_xnew(struct record_stream, 1); s = pa_xnew(struct record_stream, 1);
@ -389,7 +389,7 @@ static struct playback_stream* playback_stream_new(
int64_t start_index; int64_t start_index;
pa_sink_input_new_data data; pa_sink_input_new_data data;
assert(c && sink && ss && name && maxlength); assert(c && ss && name && maxlength);
/* Find syncid group */ /* Find syncid group */
for (ssync = pa_idxset_first(c->output_streams, &idx); ssync; ssync = pa_idxset_next(c->output_streams, &idx)) { 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 */ /* Synced streams must connect to the same sink */
if (ssync && ssync->sink_input->sink != sink) if (ssync)
return NULL; sink = ssync->sink_input->sink;
pa_sink_input_new_data_init(&data); pa_sink_input_new_data_init(&data);
data.sink = sink; data.sink = sink;
@ -415,7 +415,7 @@ static struct playback_stream* playback_stream_new(
data.module = c->protocol->module; data.module = c->protocol->module;
data.client = c->client; 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; return NULL;
s = pa_xnew(struct playback_stream, 1); 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_sample_spec ss;
pa_channel_map map; pa_channel_map map;
pa_tagstruct *reply; pa_tagstruct *reply;
pa_sink *sink; pa_sink *sink = NULL;
pa_cvolume volume; pa_cvolume volume;
int corked; 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, 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); 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); 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); 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); s = playback_stream_new(c, sink, &ss, &map, name, maxlength, tlength, prebuf, minreq, &volume, syncid);
CHECK_VALIDITY(c->pstream, s, tag, PA_ERR_INVALID); 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_sample_spec ss;
pa_channel_map map; pa_channel_map map;
pa_tagstruct *reply; pa_tagstruct *reply;
pa_source *source; pa_source *source = NULL;
int corked; int corked;
assert(c && t && c->protocol && c->protocol->core); 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, map.channels == ss.channels, tag, PA_ERR_INVALID);
CHECK_VALIDITY(c->pstream, maxlength <= MAX_MEMBLOCKQ_LENGTH, 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); 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); 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); s = record_stream_new(c, source, &ss, &map, name, maxlength, fragment_size);
CHECK_VALIDITY(c->pstream, s, tag, PA_ERR_INVALID); CHECK_VALIDITY(c->pstream, s, tag, PA_ERR_INVALID);