summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2008-06-18 23:42:14 +0200
committerLennart Poettering <lennart@poettering.net>2008-06-18 23:42:14 +0200
commit132e73b2efbda60919db355d6baa3d9687103e0f (patch)
tree5df6888cf5eac237f2250feb3960fe35dd1af41e /src
parentb95cf5203050d9af1aa44aff2edad9650ee0ff9a (diff)
add new API pa_channel_map_init_extend() to synthesize a channel map if noone is known
Diffstat (limited to 'src')
-rw-r--r--src/map-file1
-rw-r--r--src/pulse/channelmap.c28
-rw-r--r--src/pulse/channelmap.h12
-rw-r--r--src/tests/channelmap-test.c5
4 files changed, 43 insertions, 3 deletions
diff --git a/src/map-file b/src/map-file
index c3fb0882..8d1c582e 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 55fc5ee6..7348b32e 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 5812cf14..2551eae9 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 1eef86d0..9c234602 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;
}