diff options
Diffstat (limited to 'polyp/tagstruct.c')
-rw-r--r-- | polyp/tagstruct.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/polyp/tagstruct.c b/polyp/tagstruct.c index bbebdab3..b9ab55f0 100644 --- a/polyp/tagstruct.c +++ b/polyp/tagstruct.c @@ -176,6 +176,15 @@ void pa_tagstruct_put_usec(struct pa_tagstruct*t, pa_usec_t u) { t->length += 9; } +void pa_tagstruct_putu64(struct pa_tagstruct*t, uint64_t u) { + assert(t); + extend(t, 9); + t->data[t->length] = TAG_U64; + *((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; @@ -332,3 +341,18 @@ int pa_tagstruct_get_usec(struct pa_tagstruct*t, pa_usec_t *u) { t->rindex +=9; return 0; } + +int pa_tagstruct_getu64(struct pa_tagstruct*t, uint64_t *u) { + assert(t && u); + + if (t->rindex+9 > t->length) + return -1; + + if (t->data[t->rindex] != TAG_U64) + return -1; + + *u = (uint64_t) ntohl(*((uint32_t*) (t->data+t->rindex+1))) << 32; + *u |= (uint64_t) ntohl(*((uint32_t*) (t->data+t->rindex+5))); + t->rindex +=9; + return 0; +} |