diff options
Diffstat (limited to 'src/pulsecore')
-rw-r--r-- | src/pulsecore/play-memblockq.c | 31 | ||||
-rw-r--r-- | src/pulsecore/play-memchunk.c | 4 |
2 files changed, 23 insertions, 12 deletions
diff --git a/src/pulsecore/play-memblockq.c b/src/pulsecore/play-memblockq.c index 99b59134..2688f923 100644 --- a/src/pulsecore/play-memblockq.c +++ b/src/pulsecore/play-memblockq.c @@ -3,7 +3,7 @@ /*** This file is part of PulseAudio. - Copyright 2006 Lennart Poettering + Copyright 2006-2008 Lennart Poettering PulseAudio is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published @@ -99,6 +99,21 @@ static void sink_input_kill_cb(pa_sink_input *i) { memblockq_stream_unlink(u); } +/* Called from IO thread context */ +static void sink_input_state_change_cb(pa_sink_input *i, pa_sink_input_state_t state) { + memblockq_stream *u; + + pa_sink_input_assert_ref(i); + u = MEMBLOCKQ_STREAM(i->userdata); + memblockq_stream_assert_ref(u); + + /* If we are added for the first time, ask for a rewinding so that + * we are heard right-away. */ + if (PA_SINK_INPUT_IS_LINKED(state) && + i->thread_info.state == PA_SINK_INPUT_INIT) + pa_sink_input_request_rewind(i, 0, FALSE, TRUE); +} + static int sink_input_pop_cb(pa_sink_input *i, size_t nbytes, pa_memchunk *chunk) { memblockq_stream *u; @@ -116,6 +131,7 @@ static int sink_input_pop_cb(pa_sink_input *i, size_t nbytes, pa_memchunk *chunk pa_memblockq_free(u->memblockq); u->memblockq = NULL; + pa_asyncmsgq_post(pa_thread_mq_get()->outq, PA_MSGOBJECT(u), MEMBLOCKQ_STREAM_MESSAGE_UNLINK, NULL, 0, NULL, NULL); } @@ -141,7 +157,7 @@ static void sink_input_process_rewind_cb(pa_sink_input *i, size_t nbytes) { pa_memblockq_rewind(u->memblockq, nbytes); } -static void sink_input_update_max_rewind(pa_sink_input *i, size_t nbytes) { +static void sink_input_update_max_rewind_cb(pa_sink_input *i, size_t nbytes) { memblockq_stream *u; pa_sink_input_assert_ref(i); @@ -194,8 +210,9 @@ pa_sink_input* pa_memblockq_sink_input_new( u->sink_input->pop = sink_input_pop_cb; u->sink_input->process_rewind = sink_input_process_rewind_cb; - u->sink_input->update_max_rewind = sink_input_update_max_rewind; + u->sink_input->update_max_rewind = sink_input_update_max_rewind_cb; u->sink_input->kill = sink_input_kill_cb; + u->sink_input->state_change = sink_input_state_change_cb; u->sink_input->userdata = u; if (q) @@ -255,14 +272,8 @@ void pa_memblockq_sink_input_set_queue(pa_sink_input *i, pa_memblockq *q) { pa_memblockq_free(u->memblockq); if ((u->memblockq = q)) { - pa_memchunk silence; - pa_memblockq_set_prebuf(q, 0); - - pa_sink_input_get_silence(i, &silence); - pa_memblockq_set_silence(q, &silence); - pa_memblock_unref(silence.memblock); - + pa_memblockq_set_silence(q, NULL); pa_memblockq_willneed(q); } } diff --git a/src/pulsecore/play-memchunk.c b/src/pulsecore/play-memchunk.c index e4d24a99..67a92138 100644 --- a/src/pulsecore/play-memchunk.c +++ b/src/pulsecore/play-memchunk.c @@ -3,7 +3,7 @@ /*** This file is part of PulseAudio. - Copyright 2004-2006 Lennart Poettering + Copyright 2004-2008 Lennart Poettering PulseAudio is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published @@ -54,7 +54,7 @@ int pa_play_memchunk( pa_assert(ss); pa_assert(chunk); - q = pa_memblockq_new(0, chunk->length, 0, pa_frame_size(ss), 0, 0, 0, NULL); + q = pa_memblockq_new(0, chunk->length, 0, pa_frame_size(ss), 1, 1, 0, NULL); pa_assert_se(pa_memblockq_push(q, chunk) >= 0); if ((r = pa_play_memblockq(sink, ss, map, q, volume, p, sink_input_index)) < 0) { |