From c4f60d596083158334498dedb9f9e3021c67ae65 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 27 May 2008 22:08:42 +0000 Subject: never hand out more data from a sink input than requested. Otherwise the resampler might run for too long and we get a heavy delay/underrun git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@2490 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/modules/module-ladspa-sink.c | 1 + src/pulsecore/play-memblockq.c | 1 + src/pulsecore/protocol-simple.c | 2 ++ src/pulsecore/sound-file-stream.c | 12 +++++------- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/modules/module-ladspa-sink.c b/src/modules/module-ladspa-sink.c index 6033f710..9a54202c 100644 --- a/src/modules/module-ladspa-sink.c +++ b/src/modules/module-ladspa-sink.c @@ -185,6 +185,7 @@ static int sink_input_pop_cb(pa_sink_input *i, size_t nbytes, pa_memchunk *chunk pa_memblock_unref(nchunk.memblock); } + tchunk.length = PA_MIN(nbytes, tchunk.length); pa_assert(tchunk.length > 0); fs = pa_frame_size(&i->sample_spec); diff --git a/src/pulsecore/play-memblockq.c b/src/pulsecore/play-memblockq.c index 2688f923..c2039ec0 100644 --- a/src/pulsecore/play-memblockq.c +++ b/src/pulsecore/play-memblockq.c @@ -138,6 +138,7 @@ static int sink_input_pop_cb(pa_sink_input *i, size_t nbytes, pa_memchunk *chunk return -1; } + chunk->length = PA_MIN(chunk->length, nbytes); pa_memblockq_drop(u->memblockq, chunk->length); return 0; diff --git a/src/pulsecore/protocol-simple.c b/src/pulsecore/protocol-simple.c index cbe48440..e1534277 100644 --- a/src/pulsecore/protocol-simple.c +++ b/src/pulsecore/protocol-simple.c @@ -374,6 +374,8 @@ static int sink_input_pop_cb(pa_sink_input *i, size_t length, pa_memchunk *chunk } else { size_t m; + chunk->length = PA_MIN(length, chunk->length); + c->playback.underrun = FALSE; pa_memblockq_drop(c->input_memblockq, chunk->length); diff --git a/src/pulsecore/sound-file-stream.c b/src/pulsecore/sound-file-stream.c index e209676f..dd4af012 100644 --- a/src/pulsecore/sound-file-stream.c +++ b/src/pulsecore/sound-file-stream.c @@ -35,6 +35,7 @@ #include #include +#include #include #include @@ -149,8 +150,6 @@ static int sink_input_pop_cb(pa_sink_input *i, size_t length, pa_memchunk *chunk if (!u->memblockq) return -1; - pa_log_debug("pop: %lu", (unsigned long) length); - for (;;) { pa_memchunk tchunk; size_t fs; @@ -158,6 +157,7 @@ static int sink_input_pop_cb(pa_sink_input *i, size_t length, pa_memchunk *chunk sf_count_t n; if (pa_memblockq_peek(u->memblockq, chunk) >= 0) { + chunk->length = PA_MIN(chunk->length, length); pa_memblockq_drop(u->memblockq, chunk->length); return 0; } @@ -194,11 +194,7 @@ static int sink_input_pop_cb(pa_sink_input *i, size_t length, pa_memchunk *chunk pa_memblock_unref(tchunk.memblock); } - pa_log_debug("peek fail"); - if (pa_sink_input_safe_to_remove(i)) { - pa_log_debug("completed to play"); - pa_memblockq_free(u->memblockq); u->memblockq = NULL; @@ -216,6 +212,8 @@ static void sink_input_process_rewind_cb(pa_sink_input *i, size_t nbytes) { u = FILE_STREAM(i->userdata); file_stream_assert_ref(u); + pa_log("backwards %lu", (unsigned long) nbytes); + if (!u->memblockq) return; @@ -330,7 +328,7 @@ int pa_play_file( data.driver = __FILE__; pa_sink_input_new_data_set_sample_spec(&data, &ss); pa_sink_input_new_data_set_volume(&data, volume); - pa_proplist_sets(data.proplist, PA_PROP_MEDIA_NAME, fname); + pa_proplist_sets(data.proplist, PA_PROP_MEDIA_NAME, pa_path_get_filename(fname)); pa_proplist_sets(data.proplist, PA_PROP_MEDIA_FILENAME, fname); u->sink_input = pa_sink_input_new(sink->core, &data, 0); -- cgit