]> code.delx.au - pulseaudio/commitdiff
Specifying ALSA mixer control
authorKyle Cronan <kyle@pbx.org>
Mon, 30 Mar 2009 17:49:37 +0000 (12:49 -0500)
committerLennart Poettering <lennart@poettering.net>
Mon, 30 Mar 2009 22:56:41 +0000 (00:56 +0200)
On Fri, Mar 27, 2009 at 7:21 AM, Lennart Poettering <lennart@poettering.net> wrote:

>> I tried installing the latest git sources on my Ubuntu Jaunty box but
>> it just broke sound in all my applications.  For my own purposes, I'm
>> going to need to start with the Ubuntu-patched 0.9.14.  However, if
>> you are willing to accept this patch I will forward port it so that it
>> applies to the latest sources.  It's a completely harmless change, so
>> why not apply it?
>
> Yes, I am happy to apply it. Could you please update it for current git?
>

Great.  An updated patch is attached.  For symmetry, I added this
option to the alsa source module as well.

The Ubuntu folks have customized pulse so much that it is difficult
for me to get this version working on my system.  For this patch I
have only made sure that it compiles.  But it does pretty much the
same thing as the one for 0.9.14, which is working great for me.

Thanks,
Kyle

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

index 0296f64e6091bf2f3205b0de707cb60de32a8f75..0dc0e2b3d3eff7a0f8db046f1526a930ada10e1f 100644 (file)
@@ -1644,7 +1644,7 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca
     /* ALSA might tweak the sample spec, so recalculate the frame size */
     frame_size = pa_frame_size(&ss);
 
-    pa_alsa_find_mixer_and_elem(u->pcm_handle, &u->mixer_handle, &u->mixer_elem);
+    pa_alsa_find_mixer_and_elem(u->pcm_handle, &u->mixer_handle, &u->mixer_elem, pa_modargs_get_value(ma, "control", NULL));
 
     pa_sink_new_data_init(&data);
     data.driver = driver;
index ef365a21de0967cd5fe6d5f12f30d48d2f4be7d5..348cd0822e88702e9751eea63e584022585b1b55 100644 (file)
@@ -1496,7 +1496,7 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p
     /* ALSA might tweak the sample spec, so recalculate the frame size */
     frame_size = pa_frame_size(&ss);
 
-    pa_alsa_find_mixer_and_elem(u->pcm_handle, &u->mixer_handle, &u->mixer_elem);
+    pa_alsa_find_mixer_and_elem(u->pcm_handle, &u->mixer_handle, &u->mixer_elem, pa_modargs_get_value(ma, "control", NULL));
 
     pa_source_new_data_init(&data);
     data.driver = driver;
index 2d0ca1072fae9281a9b9bfadf6ee050aa1aa4098..5b5270b8ce9c2f8bf1c1cc87b0721fa5b9991d0e 100644 (file)
@@ -1094,7 +1094,8 @@ success:
 int pa_alsa_find_mixer_and_elem(
         snd_pcm_t *pcm,
         snd_mixer_t **_m,
-        snd_mixer_elem_t **_e) {
+        snd_mixer_elem_t **_e,
+        const char *control_name) {
 
     int err;
     snd_mixer_t *m;
@@ -1146,11 +1147,17 @@ int pa_alsa_find_mixer_and_elem(
     switch (snd_pcm_stream(pcm)) {
 
         case SND_PCM_STREAM_PLAYBACK:
-            e = pa_alsa_find_elem(m, "Master", "PCM", TRUE);
+            if (control_name)
+                e = pa_alsa_find_elem(m, control_name, NULL, TRUE);
+            else
+                e = pa_alsa_find_elem(m, "Master", "PCM", TRUE);
             break;
 
         case SND_PCM_STREAM_CAPTURE:
-            e = pa_alsa_find_elem(m, "Capture", "Mic", FALSE);
+            if (control_name)
+                e = pa_alsa_find_elem(m, control_name, NULL, FALSE);
+            else
+                e = pa_alsa_find_elem(m, "Capture", "Mic", FALSE);
             break;
 
         default:
index 68496d510c81fc2f15a54b10fff4d8cf4dc2a25c..5cad2958ac1d9ad0b8e890a19acb314ce0d00ee6 100644 (file)
@@ -54,7 +54,7 @@ int pa_alsa_set_sw_params(snd_pcm_t *pcm, snd_pcm_uframes_t avail_min);
 
 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, const char *fallback, pa_bool_t playback);
-int pa_alsa_find_mixer_and_elem(snd_pcm_t *pcm, snd_mixer_t **_m, snd_mixer_elem_t **_e);
+int pa_alsa_find_mixer_and_elem(snd_pcm_t *pcm, snd_mixer_t **_m, snd_mixer_elem_t **_e, const char *control_name);
 
 typedef struct pa_alsa_profile_info {
     pa_channel_map map;
index c728a4464c217b5598afdc970a1dd74a6b376579..8e600ab870242aac7e9177d6f70efa20585a1d13 100644 (file)
@@ -52,7 +52,8 @@ PA_MODULE_USAGE(
         "tsched=<enable system timer based scheduling mode?> "
         "tsched_buffer_size=<buffer size when using timer based scheduling> "
         "tsched_buffer_watermark=<lower fill watermark> "
-        "ignore_dB=<ignore dB information from the device?>");
+        "ignore_dB=<ignore dB information from the device?> "
+        "control=<name of mixer control>");
 
 static const char* const valid_modargs[] = {
     "name",
@@ -70,6 +71,7 @@ static const char* const valid_modargs[] = {
     "tsched_buffer_size",
     "tsched_buffer_watermark",
     "ignore_dB",
+    "control",
     NULL
 };
 
index 6188019f3ceca10f75bf90647c8eda132974216f..e6b27b3dce947af8a71a72f2ee02d278de33226a 100644 (file)
@@ -76,7 +76,8 @@ PA_MODULE_USAGE(
         "tsched=<enable system timer based scheduling mode?> "
         "tsched_buffer_size=<buffer size when using timer based scheduling> "
         "tsched_buffer_watermark=<upper fill watermark> "
-        "ignore_dB=<ignore dB information from the device?>");
+        "ignore_dB=<ignore dB information from the device?> "
+        "control=<name of mixer control>");
 
 static const char* const valid_modargs[] = {
     "name",
@@ -94,6 +95,7 @@ static const char* const valid_modargs[] = {
     "tsched_buffer_size",
     "tsched_buffer_watermark",
     "ignore_dB",
+    "control",
     NULL
 };