summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/modules/alsa-util.c4
-rw-r--r--src/modules/module-combine.c4
-rw-r--r--src/modules/module-jack-sink.c1
-rw-r--r--src/modules/module-jack-source.c1
-rw-r--r--src/modules/module-zeroconf-discover.c5
-rw-r--r--src/pulse/stream.c10
-rw-r--r--src/pulsecore/core-scache.c11
-rw-r--r--src/pulsecore/resampler.c8
-rw-r--r--src/pulsecore/sink-input.c2
-rw-r--r--src/pulsecore/sink.c2
-rw-r--r--src/pulsecore/sound-file.c5
-rw-r--r--src/pulsecore/source-output.c2
-rw-r--r--src/pulsecore/source.c2
13 files changed, 39 insertions, 18 deletions
diff --git a/src/modules/alsa-util.c b/src/modules/alsa-util.c
index 40170e9c..6afec3bc 100644
--- a/src/modules/alsa-util.c
+++ b/src/modules/alsa-util.c
@@ -615,8 +615,10 @@ snd_pcm_t *pa_alsa_open_by_device_string(
*dev = d;
- if (ss->channels != map->channels)
+ if (ss->channels != map->channels) {
+ pa_assert_se(pa_channel_map_init_auto(map, ss->channels, PA_CHANNEL_MAP_AUX));
pa_channel_map_init_auto(map, ss->channels, PA_CHANNEL_MAP_ALSA);
+ }
return pcm_handle;
}
diff --git a/src/modules/module-combine.c b/src/modules/module-combine.c
index dd81653c..996cd4f6 100644
--- a/src/modules/module-combine.c
+++ b/src/modules/module-combine.c
@@ -988,8 +988,10 @@ int pa__init(pa_module*m) {
if (master_sink && ss.channels == master_sink->sample_spec.channels)
map = master_sink->channel_map;
- else
+ else {
+ pa_assert_se(pa_channel_map_init_auto(&map, ss.channels, PA_CHANNEL_MAP_AUX));
pa_channel_map_init_auto(&map, ss.channels, PA_CHANNEL_MAP_DEFAULT);
+ }
if ((pa_modargs_get_channel_map(ma, NULL, &map) < 0)) {
pa_log("Invalid channel map.");
diff --git a/src/modules/module-jack-sink.c b/src/modules/module-jack-sink.c
index 46e128c9..a42aa9ef 100644
--- a/src/modules/module-jack-sink.c
+++ b/src/modules/module-jack-sink.c
@@ -333,6 +333,7 @@ int pa__init(pa_module*m) {
goto fail;
}
+ pa_assert_se(pa_channel_map_init_auto(&map, channels, PA_CHANNEL_MAP_AUX));
pa_channel_map_init_auto(&map, channels, PA_CHANNEL_MAP_ALSA);
if (pa_modargs_get_channel_map(ma, NULL, &map) < 0 || map.channels != channels) {
pa_log("Failed to parse channel_map= argument.");
diff --git a/src/modules/module-jack-source.c b/src/modules/module-jack-source.c
index f81c719a..4ee08bf1 100644
--- a/src/modules/module-jack-source.c
+++ b/src/modules/module-jack-source.c
@@ -304,6 +304,7 @@ int pa__init(pa_module*m) {
goto fail;
}
+ pa_assert_se(pa_channel_map_init_auto(&map, channels, PA_CHANNEL_MAP_AUX));
pa_channel_map_init_auto(&map, channels, PA_CHANNEL_MAP_ALSA);
if (pa_modargs_get_channel_map(ma, NULL, &map) < 0 || map.channels != channels) {
pa_log("failed to parse channel_map= argument.");
diff --git a/src/modules/module-zeroconf-discover.c b/src/modules/module-zeroconf-discover.c
index 061560c8..4e76f448 100644
--- a/src/modules/module-zeroconf-discover.c
+++ b/src/modules/module-zeroconf-discover.c
@@ -164,6 +164,7 @@ static void resolver_cb(
pa_module *m;
ss = u->core->default_sample_spec;
+ pa_assert_se(pa_channel_map_init_auto(&cm, ss.channels, PA_CHANNEL_MAP_AUX));
pa_channel_map_init_auto(&cm, ss.channels, PA_CHANNEL_MAP_DEFAULT);
for (l = txt; l; l = l->next) {
@@ -189,8 +190,10 @@ static void resolver_cb(
avahi_free(value);
}
- if (!channel_map_set && cm.channels != ss.channels)
+ if (!channel_map_set && cm.channels != ss.channels) {
+ pa_assert_se(pa_channel_map_init_auto(&cm, ss.channels, PA_CHANNEL_MAP_AUX));
pa_channel_map_init_auto(&cm, ss.channels, PA_CHANNEL_MAP_DEFAULT);
+ }
if (!pa_sample_spec_valid(&ss)) {
pa_log("Service '%s' contains an invalid sample specification.", name);
diff --git a/src/pulse/stream.c b/src/pulse/stream.c
index cd70cdcb..c44323fc 100644
--- a/src/pulse/stream.c
+++ b/src/pulse/stream.c
@@ -46,6 +46,7 @@
pa_stream *pa_stream_new(pa_context *c, const char *name, const pa_sample_spec *ss, const pa_channel_map *map) {
pa_stream *s;
int i;
+ pa_channel_map tmap;
pa_assert(c);
pa_assert(PA_REFCNT_VALUE(c) >= 1);
@@ -54,6 +55,9 @@ pa_stream *pa_stream_new(pa_context *c, const char *name, const pa_sample_spec *
PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 12 || (ss->format != PA_SAMPLE_S32LE || ss->format != PA_SAMPLE_S32NE), PA_ERR_NOTSUPPORTED);
PA_CHECK_VALIDITY_RETURN_NULL(c, !map || (pa_channel_map_valid(map) && map->channels == ss->channels), PA_ERR_INVALID);
+ if (!map)
+ PA_CHECK_VALIDITY_RETURN_NULL(c, map = pa_channel_map_init_auto(&tmap, ss->channels, PA_CHANNEL_MAP_DEFAULT), PA_ERR_INVALID);
+
s = pa_xnew(pa_stream, 1);
PA_REFCNT_INIT(s);
s->context = c;
@@ -81,13 +85,9 @@ pa_stream *pa_stream_new(pa_context *c, const char *name, const pa_sample_spec *
s->direction = PA_STREAM_NODIRECTION;
s->name = pa_xstrdup(name);
s->sample_spec = *ss;
+ s->channel_map = *map;
s->flags = 0;
- if (map)
- s->channel_map = *map;
- else
- pa_channel_map_init_auto(&s->channel_map, ss->channels, PA_CHANNEL_MAP_DEFAULT);
-
s->channel = 0;
s->channel_valid = 0;
s->syncid = c->csyncid++;
diff --git a/src/pulsecore/core-scache.c b/src/pulsecore/core-scache.c
index 732d90dd..46444a90 100644
--- a/src/pulsecore/core-scache.c
+++ b/src/pulsecore/core-scache.c
@@ -145,9 +145,16 @@ static pa_scache_entry* scache_add_item(pa_core *c, const char *name) {
int pa_scache_add_item(pa_core *c, const char *name, const pa_sample_spec *ss, const pa_channel_map *map, const pa_memchunk *chunk, uint32_t *idx) {
pa_scache_entry *e;
char st[PA_SAMPLE_SPEC_SNPRINT_MAX];
+ pa_channel_map tmap;
pa_assert(c);
pa_assert(name);
+ pa_assert(!ss || pa_sample_spec_valid(ss));
+ pa_assert(!map || (pa_channel_map_valid(map) && ss && ss->channels == map->channels));
+
+ if (ss && !map)
+ if (!(map = pa_channel_map_init_auto(&tmap, ss->channels, PA_CHANNEL_MAP_DEFAULT)))
+ return -1;
if (chunk && chunk->length > PA_SCACHE_ENTRY_SIZE_MAX)
return -1;
@@ -155,9 +162,11 @@ int pa_scache_add_item(pa_core *c, const char *name, const pa_sample_spec *ss, c
if (!(e = scache_add_item(c, name)))
return -1;
+ memset(&e->sample_spec, 0, sizeof(e->sample_spec));
+ pa_channel_map_init(&e->channel_map);
+
if (ss) {
e->sample_spec = *ss;
- pa_channel_map_init_auto(&e->channel_map, ss->channels, PA_CHANNEL_MAP_DEFAULT);
e->volume.channels = e->sample_spec.channels;
}
diff --git a/src/pulsecore/resampler.c b/src/pulsecore/resampler.c
index 40fc2800..fe7f1ad2 100644
--- a/src/pulsecore/resampler.c
+++ b/src/pulsecore/resampler.c
@@ -217,13 +217,13 @@ pa_resampler* pa_resampler_new(
if (am)
r->i_cm = *am;
- else
- pa_channel_map_init_auto(&r->i_cm, r->i_ss.channels, PA_CHANNEL_MAP_DEFAULT);
+ else if (!pa_channel_map_init_auto(&r->i_cm, r->i_ss.channels, PA_CHANNEL_MAP_DEFAULT))
+ goto fail;
if (bm)
r->o_cm = *bm;
- else
- pa_channel_map_init_auto(&r->o_cm, r->o_ss.channels, PA_CHANNEL_MAP_DEFAULT);
+ else if (!pa_channel_map_init_auto(&r->o_cm, r->o_ss.channels, PA_CHANNEL_MAP_DEFAULT))
+ goto fail;
r->i_fz = pa_frame_size(a);
r->o_fz = pa_frame_size(b);
diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index ec0914ec..07ddb83a 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -120,7 +120,7 @@ pa_sink_input* pa_sink_input_new(
if (data->sink->channel_map.channels == data->sample_spec.channels)
data->channel_map = data->sink->channel_map;
else
- pa_channel_map_init_auto(&data->channel_map, data->sample_spec.channels, PA_CHANNEL_MAP_DEFAULT);
+ pa_return_null_if_fail(pa_channel_map_init_auto(&data->channel_map, data->sample_spec.channels, PA_CHANNEL_MAP_DEFAULT));
}
pa_return_null_if_fail(pa_channel_map_valid(&data->channel_map));
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index fcc91cb1..9adb6097 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -73,7 +73,7 @@ pa_sink* pa_sink_new(
pa_return_null_if_fail(pa_sample_spec_valid(spec));
if (!map)
- map = pa_channel_map_init_auto(&tmap, spec->channels, PA_CHANNEL_MAP_DEFAULT);
+ pa_return_null_if_fail((map = pa_channel_map_init_auto(&tmap, spec->channels, PA_CHANNEL_MAP_DEFAULT)));
pa_return_null_if_fail(map && pa_channel_map_valid(map));
pa_return_null_if_fail(map->channels == spec->channels);
diff --git a/src/pulsecore/sound-file.c b/src/pulsecore/sound-file.c
index 7e88734c..3e6f683d 100644
--- a/src/pulsecore/sound-file.c
+++ b/src/pulsecore/sound-file.c
@@ -119,7 +119,10 @@ int pa_sound_file_load(
}
if (map)
- pa_channel_map_init_auto(map, ss->channels, PA_CHANNEL_MAP_DEFAULT);
+ if (!pa_channel_map_init_auto(map, ss->channels, PA_CHANNEL_MAP_DEFAULT)) {
+ pa_log("Unsupported channel map in file %s", fname);
+ goto finish;
+ }
if ((l = pa_frame_size(ss) * sfinfo.frames) > PA_SCACHE_ENTRY_SIZE_MAX) {
pa_log("File too large");
diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c
index 576ddcf2..88c11469 100644
--- a/src/pulsecore/source-output.c
+++ b/src/pulsecore/source-output.c
@@ -97,7 +97,7 @@ pa_source_output* pa_source_output_new(
if (data->source->channel_map.channels == data->sample_spec.channels)
data->channel_map = data->source->channel_map;
else
- pa_channel_map_init_auto(&data->channel_map, data->sample_spec.channels, PA_CHANNEL_MAP_DEFAULT);
+ pa_return_null_if_fail(pa_channel_map_init_auto(&data->channel_map, data->sample_spec.channels, PA_CHANNEL_MAP_DEFAULT));
}
pa_return_null_if_fail(pa_channel_map_valid(&data->channel_map));
diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
index 5fd65cef..d707ad86 100644
--- a/src/pulsecore/source.c
+++ b/src/pulsecore/source.c
@@ -64,7 +64,7 @@ pa_source* pa_source_new(
pa_return_null_if_fail(pa_sample_spec_valid(spec));
if (!map)
- map = pa_channel_map_init_auto(&tmap, spec->channels, PA_CHANNEL_MAP_DEFAULT);
+ pa_return_null_if_fail(map = pa_channel_map_init_auto(&tmap, spec->channels, PA_CHANNEL_MAP_DEFAULT));
pa_return_null_if_fail(map && pa_channel_map_valid(map));
pa_return_null_if_fail(map->channels == spec->channels);