diff options
author | Lennart Poettering <lennart@poettering.net> | 2006-05-16 23:47:38 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2006-05-16 23:47:38 +0000 |
commit | 4b6ab291a787ff597c938842b569a35434ab11d8 (patch) | |
tree | 2cecfeceebbb509ed2f32d94c0f489ed3c5654bb /src/polypcore/sink.c | |
parent | c63cc7bb79fb60b6493c3e80648501fbe8a83963 (diff) |
* modify pa_channel_map_init_auto() to take an extra argument specifying the standard to use (ALSA, AIFF, ...)
* add some more validity checks to pa_source_new(),pa_sink_new(),pa_sink_input_new(),pa_source_output_new()
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@888 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src/polypcore/sink.c')
-rw-r--r-- | src/polypcore/sink.c | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/src/polypcore/sink.c b/src/polypcore/sink.c index 17294059..b59f1eaa 100644 --- a/src/polypcore/sink.c +++ b/src/polypcore/sink.c @@ -29,6 +29,7 @@ #include <stdio.h> #include <polyp/introspect.h> + #include <polypcore/sink-input.h> #include <polypcore/namereg.h> #include <polypcore/util.h> @@ -36,29 +37,46 @@ #include <polypcore/xmalloc.h> #include <polypcore/core-subscribe.h> #include <polypcore/log.h> +#include <polypcore/utf8.h> #include "sink.h" #define MAX_MIX_CHANNELS 32 +#define CHECK_VALIDITY_RETURN_NULL(condition) \ +do {\ +if (!(condition)) \ + return NULL; \ +} while (0) + pa_sink* pa_sink_new( - pa_core *core, - const char *driver, - const char *name, - int fail, - const pa_sample_spec *spec, - const pa_channel_map *map) { + pa_core *core, + const char *driver, + const char *name, + int fail, + const pa_sample_spec *spec, + const pa_channel_map *map) { pa_sink *s; char *n = NULL; char st[256]; int r; + pa_channel_map tmap; assert(core); assert(name); - assert(*name); assert(spec); + CHECK_VALIDITY_RETURN_NULL(pa_sample_spec_valid(spec)); + + if (!map) + map = pa_channel_map_init_auto(&tmap, spec->channels, PA_CHANNEL_MAP_DEFAULT); + + CHECK_VALIDITY_RETURN_NULL(map && pa_channel_map_valid(map)); + CHECK_VALIDITY_RETURN_NULL(map->channels == spec->channels); + CHECK_VALIDITY_RETURN_NULL(!driver || pa_utf8_valid(driver)); + CHECK_VALIDITY_RETURN_NULL(pa_utf8_valid(name) && *name); + s = pa_xnew(pa_sink, 1); if (!(name = pa_namereg_register(core, name, PA_NAMEREG_SINK, s, fail))) { @@ -75,10 +93,7 @@ pa_sink* pa_sink_new( s->owner = NULL; s->sample_spec = *spec; - if (map) - s->channel_map = *map; - else - pa_channel_map_init_auto(&s->channel_map, spec->channels); + s->channel_map = *map; s->inputs = pa_idxset_new(NULL, NULL); |