diff options
author | Arun Raghavan <arun.raghavan@collabora.co.uk> | 2011-02-25 12:35:14 +0530 |
---|---|---|
committer | Arun Raghavan <arun.raghavan@collabora.co.uk> | 2011-05-02 10:17:20 +0530 |
commit | c3839c76377ea7662f29364ae66718e8ac6233af (patch) | |
tree | 567b85df3a7e10a5710456231711b8f43f954eab /src/pulsecore | |
parent | 802c8b6fcc9349505d00c1f6f6132dd513904b68 (diff) |
core: Add a pa_format_info structure
This will be used to represent the format of data provided by the client
for both compressed and PCM formats in a new extended API.
Diffstat (limited to 'src/pulsecore')
-rw-r--r-- | src/pulsecore/tagstruct.c | 42 | ||||
-rw-r--r-- | src/pulsecore/tagstruct.h | 6 |
2 files changed, 47 insertions, 1 deletions
diff --git a/src/pulsecore/tagstruct.c b/src/pulsecore/tagstruct.c index 804b9f90..5694a0da 100644 --- a/src/pulsecore/tagstruct.c +++ b/src/pulsecore/tagstruct.c @@ -291,6 +291,17 @@ void pa_tagstruct_put_proplist(pa_tagstruct *t, pa_proplist *p) { pa_tagstruct_puts(t, NULL); } +void pa_tagstruct_put_format_info(pa_tagstruct *t, pa_format_info *f) { + pa_assert(t); + pa_assert(f); + + extend(t, 1); + + t->data[t->length++] = PA_TAG_FORMAT_INFO; + pa_tagstruct_putu8(t, (uint8_t) f->encoding); + pa_tagstruct_put_proplist(t, f->plist); +} + int pa_tagstruct_gets(pa_tagstruct*t, const char **s) { int error = 0; size_t n; @@ -631,6 +642,37 @@ fail: return -1; } +int pa_tagstruct_get_format_info(pa_tagstruct *t, pa_format_info *f) { + size_t saved_rindex; + uint8_t encoding; + + pa_assert(t); + pa_assert(f); + + if (t->rindex+1 > t->length) + return -1; + + if (t->data[t->rindex] != PA_TAG_FORMAT_INFO) + return -1; + + saved_rindex = t->rindex; + t->rindex++; + + if (pa_tagstruct_getu8(t, &encoding) < 0) + goto fail; + + f->encoding = encoding; + + if (pa_tagstruct_get_proplist(t, f->plist) < 0) + goto fail; + + return 0; + +fail: + t->rindex = saved_rindex; + return -1; +} + void pa_tagstruct_put(pa_tagstruct *t, ...) { va_list va; pa_assert(t); diff --git a/src/pulsecore/tagstruct.h b/src/pulsecore/tagstruct.h index b6553ada..0091eeb9 100644 --- a/src/pulsecore/tagstruct.h +++ b/src/pulsecore/tagstruct.h @@ -27,6 +27,7 @@ #include <sys/time.h> #include <pulse/sample.h> +#include <pulse/format.h> #include <pulse/channelmap.h> #include <pulse/volume.h> #include <pulse/proplist.h> @@ -58,7 +59,8 @@ enum { PA_TAG_CHANNEL_MAP = 'm', PA_TAG_CVOLUME = 'v', PA_TAG_PROPLIST = 'P', - PA_TAG_VOLUME = 'V' + PA_TAG_VOLUME = 'V', + PA_TAG_FORMAT_INFO = 'f', }; pa_tagstruct *pa_tagstruct_new(const uint8_t* data, size_t length); @@ -84,6 +86,7 @@ void pa_tagstruct_put_channel_map(pa_tagstruct *t, const pa_channel_map *map); void pa_tagstruct_put_cvolume(pa_tagstruct *t, const pa_cvolume *cvolume); void pa_tagstruct_put_proplist(pa_tagstruct *t, pa_proplist *p); void pa_tagstruct_put_volume(pa_tagstruct *t, pa_volume_t volume); +void pa_tagstruct_put_format_info(pa_tagstruct *t, pa_format_info *f); int pa_tagstruct_get(pa_tagstruct *t, ...); @@ -101,5 +104,6 @@ int pa_tagstruct_get_channel_map(pa_tagstruct *t, pa_channel_map *map); int pa_tagstruct_get_cvolume(pa_tagstruct *t, pa_cvolume *v); int pa_tagstruct_get_proplist(pa_tagstruct *t, pa_proplist *p); int pa_tagstruct_get_volume(pa_tagstruct *t, pa_volume_t *v); +int pa_tagstruct_get_format_info(pa_tagstruct *t, pa_format_info *f); #endif |