summaryrefslogtreecommitdiffstats
path: root/src/tagstruct.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2004-07-06 00:08:44 +0000
committerLennart Poettering <lennart@poettering.net>2004-07-06 00:08:44 +0000
commitf8cbde54dab2783e2c6ba699dfaee9ef51b1e098 (patch)
tree7bdcc21f3b25d521207d19c8ca26eb26229b6bb7 /src/tagstruct.c
parent722c2c8c8785d215ec3ec8757168b82c9600f4a3 (diff)
auth support in esound and native
AUTH and SET_NAME operatins in native simple library git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@51 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src/tagstruct.c')
-rw-r--r--src/tagstruct.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/tagstruct.c b/src/tagstruct.c
index 67f52461..e57e755c 100644
--- a/src/tagstruct.c
+++ b/src/tagstruct.c
@@ -13,7 +13,8 @@ enum tags {
TAG_S16 = 's',
TAG_U8 = 'B',
TAG_S8 = 'b',
- TAG_SAMPLE_SPEC = 'a'
+ TAG_SAMPLE_SPEC = 'a',
+ TAG_ARBITRARY = 'x'
};
struct pa_tagstruct {
@@ -100,6 +101,18 @@ void pa_tagstruct_put_sample_spec(struct pa_tagstruct *t, const struct pa_sample
t->length += 7;
}
+
+void pa_tagstruct_put_arbitrary(struct pa_tagstruct *t, const void *p, size_t length) {
+ assert(t && p);
+
+ extend(t, 5+length);
+ t->data[t->length] = TAG_ARBITRARY;
+ *((uint32_t*) (t->data+t->length+1)) = htonl(length);
+ if (length)
+ memcpy(t->data+t->length+5, p, length);
+ t->length += 5+length;
+}
+
int pa_tagstruct_gets(struct pa_tagstruct*t, const char **s) {
int error = 0;
size_t n;
@@ -173,6 +186,22 @@ int pa_tagstruct_get_sample_spec(struct pa_tagstruct *t, struct pa_sample_spec *
return 0;
}
+int pa_tagstruct_get_arbitrary(struct pa_tagstruct *t, const void **p, size_t length) {
+ assert(t && p);
+
+ if (t->rindex+5+length > t->length)
+ return -1;
+
+ if (t->data[t->rindex] != TAG_ARBITRARY)
+ return -1;
+
+ if (ntohl(*((uint32_t*) (t->data+t->rindex+1))) != length)
+ return -1;
+
+ *p = t->data+t->rindex+5;
+ t->rindex += 5+length;
+ return 0;
+}
int pa_tagstruct_eof(struct pa_tagstruct*t) {
assert(t);