mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-08 13:29:59 -05:00
update native protocol to make use of pa_memblockq_pop_missing
git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/lennart@1924 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
2e780e88c2
commit
7c1768d4d1
1 changed files with 89 additions and 88 deletions
|
|
@ -104,7 +104,7 @@ typedef struct playback_stream {
|
|||
int underrun;
|
||||
|
||||
pa_atomic_t missing;
|
||||
size_t last_missing;
|
||||
size_t minreq;
|
||||
|
||||
/* Only updated after SINK_INPUT_MESSAGE_UPDATE_LATENCY */
|
||||
int64_t read_index, write_index;
|
||||
|
|
@ -535,7 +535,7 @@ static int playback_stream_process_msg(pa_msgobject *o, int code, void*userdata,
|
|||
switch (code) {
|
||||
case PLAYBACK_STREAM_MESSAGE_REQUEST_DATA: {
|
||||
pa_tagstruct *t;
|
||||
int32_t l = 0;
|
||||
uint32_t l = 0;
|
||||
|
||||
for (;;) {
|
||||
int32_t k;
|
||||
|
|
@ -545,11 +545,14 @@ static int playback_stream_process_msg(pa_msgobject *o, int code, void*userdata,
|
|||
|
||||
l += k;
|
||||
|
||||
if (l < s->minreq)
|
||||
break;
|
||||
|
||||
if (pa_atomic_sub(&s->missing, k) <= k)
|
||||
break;
|
||||
}
|
||||
|
||||
if (l <= 0)
|
||||
if (l < s->minreq)
|
||||
break;
|
||||
|
||||
t = pa_tagstruct_new(NULL, 0);
|
||||
|
|
@ -689,10 +692,10 @@ static playback_stream* playback_stream_new(
|
|||
*tlength = (uint32_t) pa_memblockq_get_tlength(s->memblockq);
|
||||
*prebuf = (uint32_t) pa_memblockq_get_prebuf(s->memblockq);
|
||||
*minreq = (uint32_t) pa_memblockq_get_minreq(s->memblockq);
|
||||
*missing = (uint32_t) pa_memblockq_missing(s->memblockq);
|
||||
*missing = (uint32_t) pa_memblockq_pop_missing(s->memblockq);
|
||||
|
||||
s->minreq = pa_memblockq_get_minreq(s->memblockq);
|
||||
pa_atomic_store(&s->missing, 0);
|
||||
s->last_missing = *missing;
|
||||
s->drain_request = 0;
|
||||
|
||||
pa_idxset_put(c->output_streams, s, &s->index);
|
||||
|
|
@ -776,23 +779,19 @@ static void connection_free(pa_object *o) {
|
|||
|
||||
/* Called from thread context */
|
||||
static void request_bytes(playback_stream *s) {
|
||||
size_t new_missing, delta, previous_missing;
|
||||
size_t minreq;
|
||||
size_t m, previous_missing;
|
||||
|
||||
playback_stream_assert_ref(s);
|
||||
|
||||
new_missing = pa_memblockq_missing(s->memblockq);
|
||||
delta = new_missing > s->last_missing ? new_missing - s->last_missing : 0;
|
||||
s->last_missing = new_missing;
|
||||
m = pa_memblockq_pop_missing(s->memblockq);
|
||||
|
||||
if (delta <= 0)
|
||||
if (m <= 0)
|
||||
return;
|
||||
|
||||
/* pa_log("request_bytes(%u)", delta); */
|
||||
minreq = pa_memblockq_get_minreq(s->memblockq);
|
||||
/* pa_log("request_bytes(%u)", m); */
|
||||
|
||||
previous_missing = pa_atomic_add(&s->missing, delta);
|
||||
if (previous_missing < minreq && previous_missing+delta >= minreq) {
|
||||
previous_missing = pa_atomic_add(&s->missing, m);
|
||||
if (previous_missing < s->minreq && previous_missing+m >= s->minreq) {
|
||||
pa_assert(pa_thread_mq_get());
|
||||
pa_asyncmsgq_post(pa_thread_mq_get()->outq, PA_MSGOBJECT(s), PLAYBACK_STREAM_MESSAGE_REQUEST_DATA, NULL, 0, NULL, NULL);
|
||||
}
|
||||
|
|
@ -873,6 +872,8 @@ static int sink_input_process_msg(pa_msgobject *o, int code, void *userdata, int
|
|||
case SINK_INPUT_MESSAGE_POST_DATA: {
|
||||
pa_assert(chunk);
|
||||
|
||||
/* pa_log("sink input post: %u", chunk->length); */
|
||||
|
||||
if (pa_memblockq_push_align(s->memblockq, chunk) < 0) {
|
||||
|
||||
pa_log_warn("Failed to push data into queue");
|
||||
|
|
@ -993,7 +994,7 @@ static int sink_input_peek_cb(pa_sink_input *i, size_t length, pa_memchunk *chun
|
|||
return -1;
|
||||
}
|
||||
|
||||
/* pa_log("peek: %u", chunk->length); */
|
||||
/* pa_log("peek: %u", chunk->length); */
|
||||
|
||||
request_bytes(s);
|
||||
|
||||
|
|
@ -1018,7 +1019,7 @@ static void sink_input_drop_cb(pa_sink_input *i, size_t length) {
|
|||
|
||||
request_bytes(s);
|
||||
|
||||
/* pa_log("after_drop: %u %u", pa_memblockq_get_length(s->memblockq), pa_memblockq_is_readable(s->memblockq)); */
|
||||
/* pa_log("after_drop: %u %u", pa_memblockq_get_length(s->memblockq), pa_memblockq_is_readable(s->memblockq)); */
|
||||
}
|
||||
|
||||
static void sink_input_kill_cb(pa_sink_input *i) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue