diff options
author | Lennart Poettering <lennart@poettering.net> | 2004-09-12 13:14:49 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2004-09-12 13:14:49 +0000 |
commit | f05a4ac806d8d44ab1377ea2069abb1da7ab9d16 (patch) | |
tree | 4de3d0fa9b1fdbfc9ecaa53455324a8933b2b5df /polyp/tagstruct.c | |
parent | a9ca9c4a3bd8c3c03fe5d30cd2694cf891f5bbc1 (diff) |
extend pa_usec_t to 64 bit
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@192 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'polyp/tagstruct.c')
-rw-r--r-- | polyp/tagstruct.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/polyp/tagstruct.c b/polyp/tagstruct.c index 55132cae..52db0fe3 100644 --- a/polyp/tagstruct.c +++ b/polyp/tagstruct.c @@ -39,11 +39,14 @@ enum tags { TAG_S16 = 's', TAG_U8 = 'B', TAG_S8 = 'b', + TAG_U64 = 'R', + TAG_S64 = 'r', TAG_SAMPLE_SPEC = 'a', TAG_ARBITRARY = 'x', TAG_BOOLEAN_TRUE = '1', TAG_BOOLEAN_FALSE = '0', TAG_TIMEVAL = 'T', + TAG_USEC = 'U', /* 64bit unsigned */ }; struct pa_tagstruct { @@ -155,6 +158,15 @@ void pa_tagstruct_put_timeval(struct pa_tagstruct*t, const struct timeval *tv) { t->length += 9; } +void pa_tagstruct_put_usec(struct pa_tagstruct*t, pa_usec_t u) { + assert(t); + extend(t, 9); + t->data[t->length] = TAG_USEC; + *((uint32_t*) (t->data+t->length+1)) = htonl((uint32_t) (u >> 32)); + *((uint32_t*) (t->data+t->length+5)) = htonl((uint32_t) u); + t->length += 9; +} + int pa_tagstruct_gets(struct pa_tagstruct*t, const char **s) { int error = 0; size_t n; @@ -288,3 +300,17 @@ int pa_tagstruct_get_timeval(struct pa_tagstruct*t, struct timeval *tv) { } +int pa_tagstruct_get_usec(struct pa_tagstruct*t, pa_usec_t *u) { + assert(t && u); + + if (t->rindex+9 > t->length) + return -1; + + if (t->data[t->rindex] != TAG_USEC) + return -1; + + *u = (pa_usec_t) ntohl(*((uint32_t*) (t->data+t->rindex+1))) << 32; + *u |= (pa_usec_t) ntohl(*((uint32_t*) (t->data+t->rindex+5))); + t->rindex +=9; + return 0; +} |