X-Git-Url: https://code.delx.au/pulseaudio/blobdiff_plain/b118982674effa44aa1687e8bd0d2bc0eb6254b2..fa499dad06ba6558111cdef64c18f2401e803cff:/polyp/tagstruct.c diff --git a/polyp/tagstruct.c b/polyp/tagstruct.c index 39ae87b5..a6dad868 100644 --- a/polyp/tagstruct.c +++ b/polyp/tagstruct.c @@ -4,17 +4,17 @@ This file is part of polypaudio. polypaudio is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published - by the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. polypaudio is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. + Lesser General Public License for more details. - You should have received a copy of the GNU General Public License - along with polypaudio; if not, write to the Free Software + You should have received a copy of the GNU Lesser General Public + License along with polypaudio; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. ***/ @@ -25,6 +25,8 @@ #include #include +#include +#include #include #include @@ -174,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; @@ -330,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; +}