core: make sure we always return a valid memblock in sink_input_pop() callbacks

https://bugzilla.redhat.com/show_bug.cgi?id=553607
This commit is contained in:
Lennart Poettering 2010-01-08 21:51:30 +01:00 committed by Colin Guthrie
parent 699233fb47
commit 345547853b
6 changed files with 24 additions and 6 deletions

View file

@ -890,7 +890,7 @@ static struct output *output_new(struct userdata *u, pa_sink *sink) {
1,
0,
0,
NULL);
&u->sink->silence);
pa_assert_se(pa_idxset_put(u->outputs, o, NULL) == 0);
update_description(u);

View file

@ -476,6 +476,7 @@ int pa__init(pa_module*m) {
unsigned long input_port, output_port, p, j, n_control;
unsigned c;
pa_bool_t *use_default = NULL;
pa_memchunk silence;
pa_assert(m);
@ -514,7 +515,10 @@ int pa__init(pa_module*m) {
u = pa_xnew0(struct userdata, 1);
u->module = m;
m->userdata = u;
u->memblockq = pa_memblockq_new(0, MEMBLOCKQ_MAXLENGTH, 0, pa_frame_size(&ss), 1, 1, 0, NULL);
pa_silence_memchunk_get(&m->core->silence_cache, m->core->mempool, &silence, &ss, 0);
u->memblockq = pa_memblockq_new(0, MEMBLOCKQ_MAXLENGTH, 0, pa_frame_size(&ss), 1, 1, 0, &silence);
pa_memblock_unref(silence.memblock);
if (!(e = getenv("LADSPA_PATH")))
e = LADSPA_PATH;

View file

@ -47,12 +47,16 @@ int pa_play_memchunk(
pa_memblockq *q;
int r;
pa_memchunk silence;
pa_assert(sink);
pa_assert(ss);
pa_assert(chunk);
q = pa_memblockq_new(0, chunk->length, 0, pa_frame_size(ss), 1, 1, 0, NULL);
pa_silence_memchunk_get(&sink->core->silence_cache, sink->core->mempool, &silence, ss, 0);
q = pa_memblockq_new(0, chunk->length, 0, pa_frame_size(ss), 1, 1, 0, &silence);
pa_memblock_unref(silence.memblock);
pa_assert_se(pa_memblockq_push(q, chunk) >= 0);
if ((r = pa_play_memblockq(sink, ss, map, q, volume, p, sink_input_index)) < 0) {

View file

@ -389,6 +389,7 @@ static int esd_proto_stream_play(connection *c, esd_proto_t request, const void
size_t l;
pa_sink *sink = NULL;
pa_sink_input_new_data sdata;
pa_memchunk silence;
connection_assert_ref(c);
pa_assert(data);
@ -435,6 +436,7 @@ static int esd_proto_stream_play(connection *c, esd_proto_t request, const void
CHECK_VALIDITY(c->sink_input, "Failed to create sink input.");
l = (size_t) ((double) pa_bytes_per_second(&ss)*PLAYBACK_BUFFER_SECONDS);
pa_sink_input_get_silence(c->sink_input, &silence);
c->input_memblockq = pa_memblockq_new(
0,
l,
@ -443,7 +445,8 @@ static int esd_proto_stream_play(connection *c, esd_proto_t request, const void
(size_t) -1,
l/PLAYBACK_BUFFER_FRAGMENTS,
0,
NULL);
&silence);
pa_memblock_unref(silence.memblock);
pa_iochannel_socket_set_rcvbuf(c->io, l);
c->sink_input->parent.process_msg = sink_input_process_msg;

View file

@ -525,6 +525,7 @@ void pa_simple_protocol_connect(pa_simple_protocol *p, pa_iochannel *io, pa_simp
if (o->playback) {
pa_sink_input_new_data data;
pa_memchunk silence;
size_t l;
pa_sink *sink;
@ -559,6 +560,7 @@ void pa_simple_protocol_connect(pa_simple_protocol *p, pa_iochannel *io, pa_simp
pa_sink_input_set_requested_latency(c->sink_input, DEFAULT_SINK_LATENCY);
l = (size_t) ((double) pa_bytes_per_second(&o->sample_spec)*PLAYBACK_BUFFER_SECONDS);
pa_sink_input_get_silence(c->sink_input, &silence);
c->input_memblockq = pa_memblockq_new(
0,
l,
@ -567,7 +569,9 @@ void pa_simple_protocol_connect(pa_simple_protocol *p, pa_iochannel *io, pa_simp
(size_t) -1,
l/PLAYBACK_BUFFER_FRAGMENTS,
0,
NULL);
&silence);
pa_memblock_unref(silence.memblock);
pa_iochannel_socket_set_rcvbuf(io, l);
pa_atomic_store(&c->playback.missing, (int) pa_memblockq_missing(c->input_memblockq));

View file

@ -239,6 +239,7 @@ int pa_play_file(
pa_sink_input_new_data data;
int fd;
SF_INFO sfi;
pa_memchunk silence;
pa_assert(sink);
pa_assert(fname);
@ -320,7 +321,9 @@ int pa_play_file(
u->sink_input->state_change = sink_input_state_change_cb;
u->sink_input->userdata = u;
u->memblockq = pa_memblockq_new(0, MEMBLOCKQ_MAXLENGTH, 0, pa_frame_size(&ss), 1, 1, 0, NULL);
pa_sink_input_get_silence(u->sink_input, &silence);
u->memblockq = pa_memblockq_new(0, MEMBLOCKQ_MAXLENGTH, 0, pa_frame_size(&ss), 1, 1, 0, &silence);
pa_memblock_unref(silence.memblock);
pa_sink_input_put(u->sink_input);