From 57e473b61cf373f8d9befb03d359b999eca4262b Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sat, 4 Sep 2004 00:27:36 +0000 Subject: add support for automatic termination of the daemon after the last client quit remove all gcc warnings add boolean types for tagstruct and modargs git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@178 fefdeb5f-60dc-0310-8127-8f9354f1896f --- polyp/tagstruct.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'polyp/tagstruct.c') diff --git a/polyp/tagstruct.c b/polyp/tagstruct.c index 742f6b9c..5aa79e6c 100644 --- a/polyp/tagstruct.c +++ b/polyp/tagstruct.c @@ -40,7 +40,9 @@ enum tags { TAG_U8 = 'B', TAG_S8 = 'b', TAG_SAMPLE_SPEC = 'a', - TAG_ARBITRARY = 'x' + TAG_ARBITRARY = 'x', + TAG_BOOLEAN_TRUE = '1', + TAG_BOOLEAN_FALSE = '0', }; struct pa_tagstruct { @@ -125,7 +127,6 @@ 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); @@ -137,6 +138,13 @@ void pa_tagstruct_put_arbitrary(struct pa_tagstruct *t, const void *p, size_t le t->length += 5+length; } +void pa_tagstruct_put_boolean(struct pa_tagstruct*t, int b) { + assert(t); + extend(t, 1); + t->data[t->length] = b ? TAG_BOOLEAN_TRUE : TAG_BOOLEAN_FALSE; + t->length += 1; +} + int pa_tagstruct_gets(struct pa_tagstruct*t, const char **s) { int error = 0; size_t n; @@ -238,3 +246,21 @@ const uint8_t* pa_tagstruct_data(struct pa_tagstruct*t, size_t *l) { return t->data; } +int pa_tagstruct_get_boolean(struct pa_tagstruct*t, int *b) { + assert(t && b); + + if (t->rindex+1 > t->length) + return -1; + + if (t->data[t->rindex] == TAG_BOOLEAN_TRUE) + *b = 1; + else if (t->data[t->rindex] == TAG_BOOLEAN_FALSE) + *b = 0; + else + return -1; + + t->rindex +=1; + return 0; +} + + -- cgit