mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-02 09:01:46 -05:00
protocol changes for new latency API (partial!)
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@616 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
76f56ab462
commit
8cf9b972e2
4 changed files with 39 additions and 9 deletions
|
|
@ -547,7 +547,6 @@ void pa_memblockq_flush(pa_memblockq *bq) {
|
|||
drop_block(bq, bq->blocks);
|
||||
|
||||
assert(bq->n_blocks == 0);
|
||||
bq->write_index = bq->read_index;
|
||||
|
||||
pa_memblockq_prebuf_force(bq);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1031,13 +1031,11 @@ static void command_get_playback_latency(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_
|
|||
pa_tagstruct *reply;
|
||||
struct playback_stream *s;
|
||||
struct timeval tv, now;
|
||||
uint64_t counter;
|
||||
uint32_t idx;
|
||||
assert(c && t);
|
||||
|
||||
if (pa_tagstruct_getu32(t, &idx) < 0 ||
|
||||
pa_tagstruct_get_timeval(t, &tv) < 0 ||
|
||||
pa_tagstruct_getu64(t, &counter) < 0 ||
|
||||
!pa_tagstruct_eof(t)) {
|
||||
protocol_error(c);
|
||||
return;
|
||||
|
|
@ -1057,7 +1055,8 @@ static void command_get_playback_latency(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_
|
|||
pa_tagstruct_put_timeval(reply, &tv);
|
||||
pa_gettimeofday(&now);
|
||||
pa_tagstruct_put_timeval(reply, &now);
|
||||
pa_tagstruct_putu64(reply, counter);
|
||||
pa_tagstruct_puts64(reply, pa_memblockq_get_write_index(s->memblockq));
|
||||
pa_tagstruct_puts64(reply, pa_memblockq_get_read_index(s->memblockq));
|
||||
pa_pstream_send_tagstruct(c->pstream, reply);
|
||||
}
|
||||
|
||||
|
|
@ -1066,13 +1065,11 @@ static void command_get_record_latency(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_UN
|
|||
pa_tagstruct *reply;
|
||||
struct record_stream *s;
|
||||
struct timeval tv, now;
|
||||
uint64_t counter;
|
||||
uint32_t idx;
|
||||
assert(c && t);
|
||||
|
||||
if (pa_tagstruct_getu32(t, &idx) < 0 ||
|
||||
pa_tagstruct_get_timeval(t, &tv) < 0 ||
|
||||
pa_tagstruct_getu64(t, &counter) < 0 ||
|
||||
!pa_tagstruct_eof(t)) {
|
||||
protocol_error(c);
|
||||
return;
|
||||
|
|
@ -1091,7 +1088,8 @@ static void command_get_record_latency(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_UN
|
|||
pa_tagstruct_put_timeval(reply, &tv);
|
||||
pa_gettimeofday(&now);
|
||||
pa_tagstruct_put_timeval(reply, &now);
|
||||
pa_tagstruct_putu64(reply, counter);
|
||||
pa_tagstruct_puts64(reply, pa_memblockq_get_write_index(s->memblockq));
|
||||
pa_tagstruct_puts64(reply, pa_memblockq_get_read_index(s->memblockq));
|
||||
pa_pstream_send_tagstruct(c->pstream, reply);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -189,6 +189,18 @@ void pa_tagstruct_putu64(pa_tagstruct*t, uint64_t u) {
|
|||
t->length += 9;
|
||||
}
|
||||
|
||||
void pa_tagstruct_puts64(pa_tagstruct*t, int64_t u) {
|
||||
uint32_t tmp;
|
||||
assert(t);
|
||||
extend(t, 9);
|
||||
t->data[t->length] = PA_TAG_S64;
|
||||
tmp = htonl((uint32_t) ((uint64_t) u >> 32));
|
||||
memcpy(t->data+t->length+1, &tmp, 4);
|
||||
tmp = htonl((uint32_t) ((uint64_t) u));
|
||||
memcpy(t->data+t->length+5, &tmp, 4);
|
||||
t->length += 9;
|
||||
}
|
||||
|
||||
void pa_tagstruct_put_channel_map(pa_tagstruct *t, const pa_channel_map *map) {
|
||||
unsigned i;
|
||||
|
||||
|
|
@ -399,9 +411,27 @@ int pa_tagstruct_getu64(pa_tagstruct*t, uint64_t *u) {
|
|||
return -1;
|
||||
|
||||
memcpy(&tmp, t->data+t->rindex+1, 4);
|
||||
*u = (pa_usec_t) ntohl(tmp) << 32;
|
||||
*u = (uint64_t) ntohl(tmp) << 32;
|
||||
memcpy(&tmp, t->data+t->rindex+5, 4);
|
||||
*u |= (pa_usec_t) ntohl(tmp);
|
||||
*u |= (uin64_t) ntohl(tmp);
|
||||
t->rindex +=9;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pa_tagstruct_gets64(pa_tagstruct*t, int64_t *u) {
|
||||
uint32_t tmp;
|
||||
assert(t && u);
|
||||
|
||||
if (t->rindex+9 > t->length)
|
||||
return -1;
|
||||
|
||||
if (t->data[t->rindex] != PA_TAG_S64)
|
||||
return -1;
|
||||
|
||||
memcpy(&tmp, t->data+t->rindex+1, 4);
|
||||
*u = (int64_t) ((uint64_t) ntohl(tmp) << 32);
|
||||
memcpy(&tmp, t->data+t->rindex+5, 4);
|
||||
*u |= (int64_t) ntohl(tmp);
|
||||
t->rindex +=9;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ enum {
|
|||
PA_TAG_U32 = 'L',
|
||||
PA_TAG_U8 = 'B',
|
||||
PA_TAG_U64 = 'R',
|
||||
PA_TAG_S64 = 'r',
|
||||
PA_TAG_SAMPLE_SPEC = 'a',
|
||||
PA_TAG_ARBITRARY = 'x',
|
||||
PA_TAG_BOOLEAN_TRUE = '1',
|
||||
|
|
@ -64,6 +65,7 @@ void pa_tagstruct_puts(pa_tagstruct*t, const char *s);
|
|||
void pa_tagstruct_putu8(pa_tagstruct*t, uint8_t c);
|
||||
void pa_tagstruct_putu32(pa_tagstruct*t, uint32_t i);
|
||||
void pa_tagstruct_putu64(pa_tagstruct*t, uint64_t i);
|
||||
void pa_tagstruct_puts64(pa_tagstruct*t, int64_t i);
|
||||
void pa_tagstruct_put_sample_spec(pa_tagstruct *t, const pa_sample_spec *ss);
|
||||
void pa_tagstruct_put_arbitrary(pa_tagstruct*t, const void *p, size_t length);
|
||||
void pa_tagstruct_put_boolean(pa_tagstruct*t, int b);
|
||||
|
|
@ -78,6 +80,7 @@ int pa_tagstruct_gets(pa_tagstruct*t, const char **s);
|
|||
int pa_tagstruct_getu8(pa_tagstruct*t, uint8_t *c);
|
||||
int pa_tagstruct_getu32(pa_tagstruct*t, uint32_t *i);
|
||||
int pa_tagstruct_getu64(pa_tagstruct*t, uint64_t *i);
|
||||
int pa_tagstruct_gets64(pa_tagstruct*t, int64_t *i);
|
||||
int pa_tagstruct_get_sample_spec(pa_tagstruct *t, pa_sample_spec *ss);
|
||||
int pa_tagstruct_get_arbitrary(pa_tagstruct *t, const void **p, size_t length);
|
||||
int pa_tagstruct_get_boolean(pa_tagstruct *t, int *b);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue