[polypaudio-commits] r851 - in /trunk/src/modules: alsa-util.c alsa-util.h module-alsa-sink.c module-alsa-source.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Sat May 13 13:29:33 PDT 2006


Author: lennart
Date: Sat May 13 22:29:32 2006
New Revision: 851

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=851&root=polypaudio&view=rev
Log:
use default alsa channel map for alsa devices

Modified:
    trunk/src/modules/alsa-util.c
    trunk/src/modules/alsa-util.h
    trunk/src/modules/module-alsa-sink.c
    trunk/src/modules/module-alsa-source.c

Modified: trunk/src/modules/alsa-util.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/modules/alsa-util.c?rev=851&root=polypaudio&r1=850&r2=851&view=diff
==============================================================================
--- trunk/src/modules/alsa-util.c (original)
+++ trunk/src/modules/alsa-util.c Sat May 13 22:29:32 2006
@@ -340,3 +340,47 @@
 
     return elem;
 }
+
+pa_channel_map* pa_alsa_channel_map_init_auto(pa_channel_map *m, unsigned channels) {
+    assert(m);
+    assert(channels > 0);
+    assert(channels <= PA_CHANNELS_MAX);
+
+    pa_channel_map_init(m);
+
+    m->channels = channels;
+
+    /* The standard ALSA channel order */
+    
+    switch (channels) {
+        case 1:
+            m->map[0] = PA_CHANNEL_POSITION_MONO;
+            return m;
+
+        case 8:
+            m->map[6] = PA_CHANNEL_POSITION_SIDE_LEFT;
+            m->map[7] = PA_CHANNEL_POSITION_SIDE_RIGHT;
+            /* Fall through */
+
+        case 6:
+            m->map[5] = PA_CHANNEL_POSITION_LFE;
+            /* Fall through */
+            
+        case 5:
+            m->map[4] = PA_CHANNEL_POSITION_FRONT_CENTER;
+            /* Fall through */
+            
+        case 4:
+            m->map[2] = PA_CHANNEL_POSITION_REAR_LEFT;
+            m->map[3] = PA_CHANNEL_POSITION_REAR_RIGHT;
+            /* Fall through */
+            
+        case 2:
+            m->map[0] = PA_CHANNEL_POSITION_FRONT_LEFT;
+            m->map[1] = PA_CHANNEL_POSITION_FRONT_RIGHT;
+            return m;
+
+        default:
+            return NULL;
+    }
+}

Modified: trunk/src/modules/alsa-util.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/modules/alsa-util.h?rev=851&root=polypaudio&r1=850&r2=851&view=diff
==============================================================================
--- trunk/src/modules/alsa-util.h (original)
+++ trunk/src/modules/alsa-util.h Sat May 13 22:29:32 2006
@@ -27,6 +27,8 @@
 #include <polyp/sample.h>
 #include <polyp/mainloop-api.h>
 
+#include <polyp/channelmap.h>
+
 struct pa_alsa_fdlist;
 
 struct pa_alsa_fdlist *pa_alsa_fdlist_new(void);
@@ -40,4 +42,6 @@
 int pa_alsa_prepare_mixer(snd_mixer_t *mixer, const char *dev);
 snd_mixer_elem_t *pa_alsa_find_elem(snd_mixer_t *mixer, const char *name);
 
+pa_channel_map* pa_alsa_channel_map_init_auto(pa_channel_map *m, unsigned channels);
+
 #endif

Modified: trunk/src/modules/module-alsa-sink.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/modules/module-alsa-sink.c?rev=851&root=polypaudio&r1=850&r2=851&view=diff
==============================================================================
--- trunk/src/modules/module-alsa-sink.c (original)
+++ trunk/src/modules/module-alsa-sink.c Sat May 13 22:29:32 2006
@@ -324,10 +324,22 @@
     }
 
     ss = c->default_sample_spec;
-    if (pa_modargs_get_sample_spec_and_channel_map(ma, &ss, &map) < 0) {
+    if (pa_modargs_get_sample_spec(ma, &ss) < 0) {
         pa_log(__FILE__": failed to parse sample specification");
         goto fail;
     }
+
+    pa_alsa_channel_map_init_auto(&map, ss.channels);
+    if ((pa_modargs_get_channel_map(ma, &map) < 0)) {
+        pa_log(__FILE__": invalid channel map.");
+        goto fail;
+    }
+
+    if (ss.channels != map.channels) {
+        pa_log(__FILE__": channel map and sample specification don't match.");
+        goto fail;
+    }
+
     frame_size = pa_frame_size(&ss);
     
     periods = 8;

Modified: trunk/src/modules/module-alsa-source.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/modules/module-alsa-source.c?rev=851&root=polypaudio&r1=850&r2=851&view=diff
==============================================================================
--- trunk/src/modules/module-alsa-source.c (original)
+++ trunk/src/modules/module-alsa-source.c Sat May 13 22:29:32 2006
@@ -312,10 +312,22 @@
     }
 
     ss = c->default_sample_spec;
-    if (pa_modargs_get_sample_spec_and_channel_map(ma, &ss, &map) < 0) {
+    if (pa_modargs_get_sample_spec(ma, &ss) < 0) {
         pa_log(__FILE__": failed to parse sample specification");
         goto fail;
     }
+
+    pa_alsa_channel_map_init_auto(&map, ss.channels);
+    if ((pa_modargs_get_channel_map(ma, &map) < 0)) {
+        pa_log(__FILE__": invalid channel map.");
+        goto fail;
+    }
+
+    if (ss.channels != map.channels) {
+        pa_log(__FILE__": channel map and sample specification don't match.");
+        goto fail;
+    }
+
     frame_size = pa_frame_size(&ss);
     
     periods = 12;




More information about the pulseaudio-commits mailing list