From: Lennart Poettering Date: Wed, 18 Jun 2008 21:44:26 +0000 (+0200) Subject: make user of pa_channel_map_init_extend() wherever it makes sense X-Git-Tag: 1.0_branch~2781 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c2fa11e179eb65b09eb1a7629f01d97fe44273aa;p=profile%2Fivi%2Fpulseaudio.git make user of pa_channel_map_init_extend() wherever it makes sense --- diff --git a/src/modules/alsa-util.c b/src/modules/alsa-util.c index 1fef6d6..5d52cbc 100644 --- a/src/modules/alsa-util.c +++ b/src/modules/alsa-util.c @@ -668,26 +668,8 @@ snd_pcm_t *pa_alsa_open_by_device_string( *dev = d; - if (ss->channels != map->channels) { - if (!pa_channel_map_init_auto(map, ss->channels, PA_CHANNEL_MAP_ALSA)) { - unsigned c; - pa_channel_position_t pos; - - pa_log_warn("Device has an unknown channel mapping. This is a limitation of ALSA. Synthesizing channel map."); - - for (c = ss->channels; c > 0; c--) - if (pa_channel_map_init_auto(map, c, PA_CHANNEL_MAP_ALSA)) - break; - - pa_assert(c > 0); - - pos = PA_CHANNEL_POSITION_AUX0; - for (; c < map->channels; c ++) - map->map[c] = pos++; - - map->channels = ss->channels; - } - } + if (ss->channels != map->channels) + pa_channel_map_init_extend(map, ss->channels, PA_CHANNEL_MAP_ALSA); return pcm_handle; } diff --git a/src/modules/module-jack-sink.c b/src/modules/module-jack-sink.c index 61ad79c..c4d47f8 100644 --- a/src/modules/module-jack-sink.c +++ b/src/modules/module-jack-sink.c @@ -330,8 +330,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); + pa_channel_map_init_extend(&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."); goto fail; diff --git a/src/modules/module-jack-source.c b/src/modules/module-jack-source.c index 880bb60..03f9d15 100644 --- a/src/modules/module-jack-source.c +++ b/src/modules/module-jack-source.c @@ -301,8 +301,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); + pa_channel_map_init_extend(&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."); goto fail; diff --git a/src/modules/module-zeroconf-discover.c b/src/modules/module-zeroconf-discover.c index c405773..2fc8137 100644 --- a/src/modules/module-zeroconf-discover.c +++ b/src/modules/module-zeroconf-discover.c @@ -162,8 +162,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); + pa_channel_map_init_extend(&cm, ss.channels, PA_CHANNEL_MAP_DEFAULT); for (l = txt; l; l = l->next) { char *key, *value; @@ -188,10 +187,8 @@ static void resolver_cb( avahi_free(value); } - 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 (!channel_map_set && cm.channels != ss.channels) + pa_channel_map_init_extend(&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/pulsecore/core-scache.c b/src/pulsecore/core-scache.c index ed3758f..75fa2ff 100644 --- a/src/pulsecore/core-scache.c +++ b/src/pulsecore/core-scache.c @@ -162,8 +162,7 @@ int pa_scache_add_item( 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; + pa_channel_map_init_extend(&tmap, ss->channels, PA_CHANNEL_MAP_DEFAULT); if (chunk && chunk->length > PA_SCACHE_ENTRY_SIZE_MAX) return -1; diff --git a/src/pulsecore/sound-file.c b/src/pulsecore/sound-file.c index 57c1776..3183ede 100644 --- a/src/pulsecore/sound-file.c +++ b/src/pulsecore/sound-file.c @@ -117,10 +117,7 @@ int pa_sound_file_load( } if (map) - if (!pa_channel_map_init_auto(map, ss->channels, PA_CHANNEL_MAP_DEFAULT)) { - pa_log("Unsupported channel map in file %s", fname); - goto finish; - } + pa_channel_map_init_extend(map, ss->channels, PA_CHANNEL_MAP_DEFAULT); if ((l = pa_frame_size(ss) * sfinfo.frames) > PA_SCACHE_ENTRY_SIZE_MAX) { pa_log("File too large");