diff options
author | Jaska Uimonen <jaska.uimonen@intel.com> | 2013-03-04 09:24:37 +0200 |
---|---|---|
committer | Jaska Uimonen <jaska.uimonen@intel.com> | 2013-03-12 10:19:03 +0200 |
commit | 9d1c7716c0ade92634b41d1ec4bd49c3af177d41 (patch) | |
tree | 1435859c162d1b1be3a14ed338e3c9cf648e5566 | |
parent | f32c21290067405991e55e40f92f6b95025626e0 (diff) | |
download | pulseaudio-panda-9d1c7716c0ade92634b41d1ec4bd49c3af177d41.tar.gz pulseaudio-panda-9d1c7716c0ade92634b41d1ec4bd49c3af177d41.tar.bz2 pulseaudio-panda-9d1c7716c0ade92634b41d1ec4bd49c3af177d41.zip |
fix draining not to lose samples in pre buffer
-rw-r--r-- | src/pulsecore/memblockq.c | 13 | ||||
-rw-r--r-- | src/pulsecore/memblockq.h | 3 | ||||
-rw-r--r-- | src/pulsecore/protocol-native.c | 8 |
3 files changed, 23 insertions, 1 deletions
diff --git a/src/pulsecore/memblockq.c b/src/pulsecore/memblockq.c index 18066f77..2dd08bc7 100644 --- a/src/pulsecore/memblockq.c +++ b/src/pulsecore/memblockq.c @@ -814,6 +814,19 @@ void pa_memblockq_prebuf_disable(pa_memblockq *bq) { bq->in_prebuf = FALSE; } +void pa_memblockq_prebuf_disable_and_adjust(pa_memblockq *bq) { + size_t len; + + pa_assert(bq); + + bq->in_prebuf = FALSE; + + if (bq->prebuf > 0 && (len = pa_memblockq_get_length(bq)) > 0) { + pa_log("adjusting prebuf length to %u", len); + bq->prebuf = len; + } +} + void pa_memblockq_prebuf_force(pa_memblockq *bq) { pa_assert(bq); diff --git a/src/pulsecore/memblockq.h b/src/pulsecore/memblockq.h index 08c0bf04..0a7f9dfa 100644 --- a/src/pulsecore/memblockq.h +++ b/src/pulsecore/memblockq.h @@ -134,6 +134,9 @@ void pa_memblockq_flush_read(pa_memblockq *bq); /* Ignore prebuf for now */ void pa_memblockq_prebuf_disable(pa_memblockq *bq); +/* Ignore prebuf for now and adjust prebuf size to actual size */ +void pa_memblockq_prebuf_disable_and_adjust(pa_memblockq *bq); + /* Force prebuf */ void pa_memblockq_prebuf_force(pa_memblockq *bq); diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c index 41fc0a02..8c45a339 100644 --- a/src/pulsecore/protocol-native.c +++ b/src/pulsecore/protocol-native.c @@ -1487,8 +1487,14 @@ static int sink_input_process_msg(pa_msgobject *o, int code, void *userdata, int break; case SINK_INPUT_MESSAGE_DRAIN: + if (i->thread_info.state == PA_SINK_INPUT_CORKED) + func = pa_memblockq_prebuf_disable_and_adjust; + else + func = pa_memblockq_prebuf_disable; + break; + case SINK_INPUT_MESSAGE_TRIGGER: - func = pa_memblockq_prebuf_disable; + func = pa_memblockq_prebuf_disable; break; default: |