diff options
author | Lennart Poettering <lennart@poettering.net> | 2008-05-03 01:32:57 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2008-05-03 01:32:57 +0000 |
commit | d2da344fee54f759501952685102f5606d3e2aaa (patch) | |
tree | dcb0215818dd77a718104e2629286a16c209690e | |
parent | d2be471ed241273cd1b41c64946d8f0ac47f88ab (diff) |
send PA_SINK_MESSAGE_REMOVE_INPUT only when an asyncmsgq is available, reset resampler only when we really need to
git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/glitch-free@2354 fefdeb5f-60dc-0310-8127-8f9354f1896f
-rw-r--r-- | src/pulsecore/sink-input.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c index bb377c44..317693df 100644 --- a/src/pulsecore/sink-input.c +++ b/src/pulsecore/sink-input.c @@ -349,7 +349,8 @@ void pa_sink_input_unlink(pa_sink_input *i) { i->state = PA_SINK_INPUT_UNLINKED; if (linked) - pa_asyncmsgq_send(i->sink->asyncmsgq, PA_MSGOBJECT(i->sink), PA_SINK_MESSAGE_REMOVE_INPUT, i, 0, NULL); + if (i->sink->asyncmsgq) + pa_asyncmsgq_send(i->sink->asyncmsgq, PA_MSGOBJECT(i->sink), PA_SINK_MESSAGE_REMOVE_INPUT, i, 0, NULL); reset_callbacks(i); @@ -639,7 +640,7 @@ void pa_sink_input_process_rewind(pa_sink_input *i, size_t nbytes /* in sink sam max_rewrite = pa_resampler_request(i->thread_info.resampler, max_rewrite); /* Calculate how much of the rewinded data should actually be rewritten */ - amount = PA_MIN(max_rewrite, i->thread_info.rewrite_nbytes); + amount = PA_MIN(i->thread_info.rewrite_nbytes, max_rewrite); /* Convert back to to sink domain */ r = i->thread_info.resampler ? pa_resampler_result(i->thread_info.resampler, amount) : amount; @@ -648,17 +649,17 @@ void pa_sink_input_process_rewind(pa_sink_input *i, size_t nbytes /* in sink sam /* Ok, now update the write pointer */ pa_memblockq_seek(i->thread_info.render_memblockq, -r, PA_SEEK_RELATIVE); - if (amount) { + if (amount > 0) { pa_log_debug("Have to rewind %lu bytes on implementor.", (unsigned long) amount); /* Tell the implementor */ if (i->process_rewind) i->process_rewind(i, amount); - } - /* And reset the resampler */ - if (i->thread_info.resampler) - pa_resampler_reset(i->thread_info.resampler); + /* And reset the resampler */ + if (i->thread_info.resampler) + pa_resampler_reset(i->thread_info.resampler); + } } i->thread_info.rewrite_nbytes = 0; |