mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-03 09:01:50 -05:00
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:
parent
8d356659e6
commit
3eed219a50
6 changed files with 24 additions and 6 deletions
|
|
@ -890,7 +890,7 @@ static struct output *output_new(struct userdata *u, pa_sink *sink) {
|
||||||
1,
|
1,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
NULL);
|
&u->sink->silence);
|
||||||
|
|
||||||
pa_assert_se(pa_idxset_put(u->outputs, o, NULL) == 0);
|
pa_assert_se(pa_idxset_put(u->outputs, o, NULL) == 0);
|
||||||
update_description(u);
|
update_description(u);
|
||||||
|
|
|
||||||
|
|
@ -476,6 +476,7 @@ int pa__init(pa_module*m) {
|
||||||
unsigned long input_port, output_port, p, j, n_control;
|
unsigned long input_port, output_port, p, j, n_control;
|
||||||
unsigned c;
|
unsigned c;
|
||||||
pa_bool_t *use_default = NULL;
|
pa_bool_t *use_default = NULL;
|
||||||
|
pa_memchunk silence;
|
||||||
|
|
||||||
pa_assert(m);
|
pa_assert(m);
|
||||||
|
|
||||||
|
|
@ -514,7 +515,10 @@ int pa__init(pa_module*m) {
|
||||||
u = pa_xnew0(struct userdata, 1);
|
u = pa_xnew0(struct userdata, 1);
|
||||||
u->module = m;
|
u->module = m;
|
||||||
m->userdata = u;
|
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")))
|
if (!(e = getenv("LADSPA_PATH")))
|
||||||
e = LADSPA_PATH;
|
e = LADSPA_PATH;
|
||||||
|
|
|
||||||
|
|
@ -47,12 +47,16 @@ int pa_play_memchunk(
|
||||||
|
|
||||||
pa_memblockq *q;
|
pa_memblockq *q;
|
||||||
int r;
|
int r;
|
||||||
|
pa_memchunk silence;
|
||||||
|
|
||||||
pa_assert(sink);
|
pa_assert(sink);
|
||||||
pa_assert(ss);
|
pa_assert(ss);
|
||||||
pa_assert(chunk);
|
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);
|
pa_assert_se(pa_memblockq_push(q, chunk) >= 0);
|
||||||
|
|
||||||
if ((r = pa_play_memblockq(sink, ss, map, q, volume, p, sink_input_index)) < 0) {
|
if ((r = pa_play_memblockq(sink, ss, map, q, volume, p, sink_input_index)) < 0) {
|
||||||
|
|
|
||||||
|
|
@ -389,6 +389,7 @@ static int esd_proto_stream_play(connection *c, esd_proto_t request, const void
|
||||||
size_t l;
|
size_t l;
|
||||||
pa_sink *sink = NULL;
|
pa_sink *sink = NULL;
|
||||||
pa_sink_input_new_data sdata;
|
pa_sink_input_new_data sdata;
|
||||||
|
pa_memchunk silence;
|
||||||
|
|
||||||
connection_assert_ref(c);
|
connection_assert_ref(c);
|
||||||
pa_assert(data);
|
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.");
|
CHECK_VALIDITY(c->sink_input, "Failed to create sink input.");
|
||||||
|
|
||||||
l = (size_t) ((double) pa_bytes_per_second(&ss)*PLAYBACK_BUFFER_SECONDS);
|
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(
|
c->input_memblockq = pa_memblockq_new(
|
||||||
0,
|
0,
|
||||||
l,
|
l,
|
||||||
|
|
@ -443,7 +445,8 @@ static int esd_proto_stream_play(connection *c, esd_proto_t request, const void
|
||||||
(size_t) -1,
|
(size_t) -1,
|
||||||
l/PLAYBACK_BUFFER_FRAGMENTS,
|
l/PLAYBACK_BUFFER_FRAGMENTS,
|
||||||
0,
|
0,
|
||||||
NULL);
|
&silence);
|
||||||
|
pa_memblock_unref(silence.memblock);
|
||||||
pa_iochannel_socket_set_rcvbuf(c->io, l);
|
pa_iochannel_socket_set_rcvbuf(c->io, l);
|
||||||
|
|
||||||
c->sink_input->parent.process_msg = sink_input_process_msg;
|
c->sink_input->parent.process_msg = sink_input_process_msg;
|
||||||
|
|
|
||||||
|
|
@ -525,6 +525,7 @@ void pa_simple_protocol_connect(pa_simple_protocol *p, pa_iochannel *io, pa_simp
|
||||||
|
|
||||||
if (o->playback) {
|
if (o->playback) {
|
||||||
pa_sink_input_new_data data;
|
pa_sink_input_new_data data;
|
||||||
|
pa_memchunk silence;
|
||||||
size_t l;
|
size_t l;
|
||||||
pa_sink *sink;
|
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);
|
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);
|
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(
|
c->input_memblockq = pa_memblockq_new(
|
||||||
0,
|
0,
|
||||||
l,
|
l,
|
||||||
|
|
@ -567,7 +569,9 @@ void pa_simple_protocol_connect(pa_simple_protocol *p, pa_iochannel *io, pa_simp
|
||||||
(size_t) -1,
|
(size_t) -1,
|
||||||
l/PLAYBACK_BUFFER_FRAGMENTS,
|
l/PLAYBACK_BUFFER_FRAGMENTS,
|
||||||
0,
|
0,
|
||||||
NULL);
|
&silence);
|
||||||
|
pa_memblock_unref(silence.memblock);
|
||||||
|
|
||||||
pa_iochannel_socket_set_rcvbuf(io, l);
|
pa_iochannel_socket_set_rcvbuf(io, l);
|
||||||
|
|
||||||
pa_atomic_store(&c->playback.missing, (int) pa_memblockq_missing(c->input_memblockq));
|
pa_atomic_store(&c->playback.missing, (int) pa_memblockq_missing(c->input_memblockq));
|
||||||
|
|
|
||||||
|
|
@ -239,6 +239,7 @@ int pa_play_file(
|
||||||
pa_sink_input_new_data data;
|
pa_sink_input_new_data data;
|
||||||
int fd;
|
int fd;
|
||||||
SF_INFO sfi;
|
SF_INFO sfi;
|
||||||
|
pa_memchunk silence;
|
||||||
|
|
||||||
pa_assert(sink);
|
pa_assert(sink);
|
||||||
pa_assert(fname);
|
pa_assert(fname);
|
||||||
|
|
@ -324,7 +325,9 @@ int pa_play_file(
|
||||||
u->sink_input->state_change = sink_input_state_change_cb;
|
u->sink_input->state_change = sink_input_state_change_cb;
|
||||||
u->sink_input->userdata = u;
|
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);
|
pa_sink_input_put(u->sink_input);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue