]> code.delx.au - pulseaudio/blobdiff - polyp/tagstruct.c
Make the whole stuff LGPL only
[pulseaudio] / polyp / tagstruct.c
index 39ae87b53c789752e725c15b932c4cad4028b433..a6dad868c87ae8504190ac735bbc0b55fccdba6a 100644 (file)
@@ -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 <stdlib.h>
 #include <string.h>
+#include <unistd.h>
+#include <sys/time.h>
 #include <netinet/in.h>
 #include <assert.h>
 
@@ -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;
+}