summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2016-05-19 15:26:08 +0200
committerArun Raghavan <arun@arunraghavan.net>2016-07-22 14:44:35 +0530
commiteeec52caa0622504f7a0d065dd61db1dbf5a9569 (patch)
treef4912aefbd0094a0798551335e0d75fdd1ed8ba2 /src
parentedff1b2204587925178ffd00736afdbcdfb8778f (diff)
memblockq: move minreq handling in to memblockq
Having it handled in the callers proved to be a poor fit as it became difficult to handle a shrinking minreq sanely. It could end up in a state where the request was never sent downstream to the client.
Diffstat (limited to 'src')
-rw-r--r--src/pulsecore/memblockq.c4
-rw-r--r--src/pulsecore/protocol-native.c9
2 files changed, 6 insertions, 7 deletions
diff --git a/src/pulsecore/memblockq.c b/src/pulsecore/memblockq.c
index d283ed255..f660ffaed 100644
--- a/src/pulsecore/memblockq.c
+++ b/src/pulsecore/memblockq.c
@@ -840,6 +840,10 @@ size_t pa_memblockq_pop_missing(pa_memblockq *bq) {
if (bq->missing <= 0)
return 0;
+ if (((size_t) bq->missing < bq->minreq) &&
+ !pa_memblockq_prebuf_active(bq))
+ return 0;
+
l = (size_t) bq->missing;
bq->requested += bq->missing;
diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c
index c468edca8..0f86bd269 100644
--- a/src/pulsecore/protocol-native.c
+++ b/src/pulsecore/protocol-native.c
@@ -1111,8 +1111,7 @@ out:
/* Called from IO context */
static void playback_stream_request_bytes(playback_stream *s) {
- size_t m, minreq;
- int previous_missing;
+ size_t m;
playback_stream_assert_ref(s);
@@ -1132,11 +1131,7 @@ static void playback_stream_request_bytes(playback_stream *s) {
pa_log("request_bytes(%lu)", (unsigned long) m);
#endif
- previous_missing = pa_atomic_add(&s->missing, (int) m);
- minreq = pa_memblockq_get_minreq(s->memblockq);
-
- if (pa_memblockq_prebuf_active(s->memblockq) ||
- (previous_missing < (int) minreq && previous_missing + (int) m >= (int) minreq))
+ if (pa_atomic_add(&s->missing, (int) m) <= 0)
pa_asyncmsgq_post(pa_thread_mq_get()->outq, PA_MSGOBJECT(s), PLAYBACK_STREAM_MESSAGE_REQUEST_DATA, NULL, 0, NULL, NULL);
}