mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
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.
This commit is contained in:
parent
edff1b2204
commit
eeec52caa0
2 changed files with 6 additions and 7 deletions
|
|
@ -840,6 +840,10 @@ size_t pa_memblockq_pop_missing(pa_memblockq *bq) {
|
||||||
if (bq->missing <= 0)
|
if (bq->missing <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
if (((size_t) bq->missing < bq->minreq) &&
|
||||||
|
!pa_memblockq_prebuf_active(bq))
|
||||||
|
return 0;
|
||||||
|
|
||||||
l = (size_t) bq->missing;
|
l = (size_t) bq->missing;
|
||||||
|
|
||||||
bq->requested += bq->missing;
|
bq->requested += bq->missing;
|
||||||
|
|
|
||||||
|
|
@ -1111,8 +1111,7 @@ out:
|
||||||
|
|
||||||
/* Called from IO context */
|
/* Called from IO context */
|
||||||
static void playback_stream_request_bytes(playback_stream *s) {
|
static void playback_stream_request_bytes(playback_stream *s) {
|
||||||
size_t m, minreq;
|
size_t m;
|
||||||
int previous_missing;
|
|
||||||
|
|
||||||
playback_stream_assert_ref(s);
|
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);
|
pa_log("request_bytes(%lu)", (unsigned long) m);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
previous_missing = pa_atomic_add(&s->missing, (int) m);
|
if (pa_atomic_add(&s->missing, (int) m) <= 0)
|
||||||
minreq = pa_memblockq_get_minreq(s->memblockq);
|
|
||||||
|
|
||||||
if (pa_memblockq_prebuf_active(s->memblockq) ||
|
|
||||||
(previous_missing < (int) minreq && previous_missing + (int) m >= (int) minreq))
|
|
||||||
pa_asyncmsgq_post(pa_thread_mq_get()->outq, PA_MSGOBJECT(s), PLAYBACK_STREAM_MESSAGE_REQUEST_DATA, NULL, 0, NULL, NULL);
|
pa_asyncmsgq_post(pa_thread_mq_get()->outq, PA_MSGOBJECT(s), PLAYBACK_STREAM_MESSAGE_REQUEST_DATA, NULL, 0, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue