[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. c2fa11e179eb65b09eb1a7629f01d97fe44273aa
Lennart Poettering
gitmailer-noreply at 0pointer.de
Wed Jun 18 14:44:47 PDT 2008
This is an automated email from the git hooks/post-receive script. It was
generated because of a push to the "PulseAudio Sound Server" repository.
The master branch has been updated
from 822366a653edc3273ad458bbe4881961f1386632 (commit)
- Log -----------------------------------------------------------------
c2fa11e... make user of pa_channel_map_init_extend() wherever it makes sense
132e73b... add new API pa_channel_map_init_extend() to synthesize a channel map if noone is known
b95cf52... ignore tarballs
-----------------------------------------------------------------------
Summary of changes:
.gitignore | 1 +
src/map-file | 1 +
src/modules/alsa-util.c | 22 ++--------------------
src/modules/module-jack-sink.c | 3 +--
src/modules/module-jack-source.c | 3 +--
src/modules/module-zeroconf-discover.c | 9 +++------
src/pulse/channelmap.c | 28 ++++++++++++++++++++++++++++
src/pulse/channelmap.h | 12 ++++++++++--
src/pulsecore/core-scache.c | 3 +--
src/pulsecore/sound-file.c | 5 +----
src/tests/channelmap-test.c | 5 ++++-
11 files changed, 53 insertions(+), 39 deletions(-)
-----------------------------------------------------------------------
commit b95cf5203050d9af1aa44aff2edad9650ee0ff9a
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Jun 18 23:07:40 2008 +0200
ignore tarballs
diff --git a/.gitignore b/.gitignore
index 36bf02b..cadee1c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+*.tar.gz
*.pc
Makefile
Makefile.in
commit 132e73b2efbda60919db355d6baa3d9687103e0f
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Jun 18 23:42:14 2008 +0200
add new API pa_channel_map_init_extend() to synthesize a channel map if noone is known
diff --git a/src/map-file b/src/map-file
index c3fb088..8d1c582 100644
--- a/src/map-file
+++ b/src/map-file
@@ -12,6 +12,7 @@ pa_bytes_to_usec;
pa_channel_map_equal;
pa_channel_map_init;
pa_channel_map_init_auto;
+pa_channel_map_init_extend;
pa_channel_map_init_mono;
pa_channel_map_init_stereo;
pa_channel_map_parse;
diff --git a/src/pulse/channelmap.c b/src/pulse/channelmap.c
index 55fc5ee..7348b32 100644
--- a/src/pulse/channelmap.c
+++ b/src/pulse/channelmap.c
@@ -394,6 +394,34 @@ pa_channel_map* pa_channel_map_init_auto(pa_channel_map *m, unsigned channels, p
}
}
+pa_channel_map* pa_channel_map_init_extend(pa_channel_map *m, unsigned channels, pa_channel_map_def_t def) {
+ unsigned c;
+
+ pa_assert(m);
+ pa_assert(channels > 0);
+ pa_assert(channels <= PA_CHANNELS_MAX);
+
+ pa_channel_map_init(m);
+
+ for (c = channels; c > 0; c--) {
+
+ if (pa_channel_map_init_auto(m, c, def)) {
+ unsigned i = 0;
+
+ for (; c < channels; c++) {
+
+ m->map[c] = PA_CHANNEL_POSITION_AUX0 + i;
+ i++;
+ }
+
+ m->channels = channels;
+
+ return m;
+ }
+ }
+
+ return NULL;
+}
const char* pa_channel_position_to_string(pa_channel_position_t pos) {
diff --git a/src/pulse/channelmap.h b/src/pulse/channelmap.h
index 5812cf1..2551eae 100644
--- a/src/pulse/channelmap.h
+++ b/src/pulse/channelmap.h
@@ -166,10 +166,18 @@ pa_channel_map* pa_channel_map_init_mono(pa_channel_map *m);
/** Initialize the specified channel map for stereophonic audio and return a pointer to it */
pa_channel_map* pa_channel_map_init_stereo(pa_channel_map *m);
-/** Initialize the specified channel map for the specified number
- * of channels using default labels and return a pointer to it. */
+/** Initialize the specified channel map for the specified number of
+ * channels using default labels and return a pointer to it. This call
+ * will fail (return NULL) if there is no default channel map known for this
+ * specific number of channels and mapping. */
pa_channel_map* pa_channel_map_init_auto(pa_channel_map *m, unsigned channels, pa_channel_map_def_t def);
+/** Similar to pa_channel_map_init_auto() but instead of failing if no
+ * default mapping is known with the specified parameters it will
+ * synthesize a mapping based on a known mapping with fewer channels
+ * and fill up the rest with AUX0...AUX31 channels \since 0.9.11 */
+pa_channel_map* pa_channel_map_init_extend(pa_channel_map *m, unsigned channels, pa_channel_map_def_t def);
+
/** Return a text label for the specified channel position */
const char* pa_channel_position_to_string(pa_channel_position_t pos) PA_GCC_PURE;
diff --git a/src/tests/channelmap-test.c b/src/tests/channelmap-test.c
index 1eef86d..9c23460 100644
--- a/src/tests/channelmap-test.c
+++ b/src/tests/channelmap-test.c
@@ -20,12 +20,15 @@ int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char *argv[]) {
fprintf(stderr, "map: <%s>\n", pa_channel_map_snprint(cm, sizeof(cm), &map));
+ pa_channel_map_init_extend(&map, 14, PA_CHANNEL_MAP_ALSA);
+
+ fprintf(stderr, "map: <%s>\n", pa_channel_map_snprint(cm, sizeof(cm), &map));
+
pa_channel_map_parse(&map2, cm);
assert(pa_channel_map_equal(&map, &map2));
pa_channel_map_parse(&map2, "left,test");
-
return 0;
}
commit c2fa11e179eb65b09eb1a7629f01d97fe44273aa
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Jun 18 23:44:26 2008 +0200
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");
--
hooks/post-receive
PulseAudio Sound Server
More information about the pulseaudio-commits
mailing list