Specifying ALSA mixer control

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
This commit is contained in:
Kyle Cronan 2009-03-30 12:49:37 -05:00 committed by Lennart Poettering
parent facc46d5bf
commit 92ae5f1a74
6 changed files with 19 additions and 8 deletions

View 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 */ /* ALSA might tweak the sample spec, so recalculate the frame size */
frame_size = pa_frame_size(&ss); 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); pa_sink_new_data_init(&data);
data.driver = driver; data.driver = driver;

View 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 */ /* ALSA might tweak the sample spec, so recalculate the frame size */
frame_size = pa_frame_size(&ss); 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); pa_source_new_data_init(&data);
data.driver = driver; data.driver = driver;

View file

@ -1094,7 +1094,8 @@ success:
int pa_alsa_find_mixer_and_elem( int pa_alsa_find_mixer_and_elem(
snd_pcm_t *pcm, snd_pcm_t *pcm,
snd_mixer_t **_m, snd_mixer_t **_m,
snd_mixer_elem_t **_e) { snd_mixer_elem_t **_e,
const char *control_name) {
int err; int err;
snd_mixer_t *m; snd_mixer_t *m;
@ -1146,11 +1147,17 @@ int pa_alsa_find_mixer_and_elem(
switch (snd_pcm_stream(pcm)) { switch (snd_pcm_stream(pcm)) {
case SND_PCM_STREAM_PLAYBACK: 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; break;
case SND_PCM_STREAM_CAPTURE: 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; break;
default: default:

View 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); 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); 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 { typedef struct pa_alsa_profile_info {
pa_channel_map map; pa_channel_map map;

View file

@ -52,7 +52,8 @@ PA_MODULE_USAGE(
"tsched=<enable system timer based scheduling mode?> " "tsched=<enable system timer based scheduling mode?> "
"tsched_buffer_size=<buffer size when using timer based scheduling> " "tsched_buffer_size=<buffer size when using timer based scheduling> "
"tsched_buffer_watermark=<lower fill watermark> " "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[] = { static const char* const valid_modargs[] = {
"name", "name",
@ -70,6 +71,7 @@ static const char* const valid_modargs[] = {
"tsched_buffer_size", "tsched_buffer_size",
"tsched_buffer_watermark", "tsched_buffer_watermark",
"ignore_dB", "ignore_dB",
"control",
NULL NULL
}; };

View file

@ -76,7 +76,8 @@ PA_MODULE_USAGE(
"tsched=<enable system timer based scheduling mode?> " "tsched=<enable system timer based scheduling mode?> "
"tsched_buffer_size=<buffer size when using timer based scheduling> " "tsched_buffer_size=<buffer size when using timer based scheduling> "
"tsched_buffer_watermark=<upper fill watermark> " "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[] = { static const char* const valid_modargs[] = {
"name", "name",
@ -94,6 +95,7 @@ static const char* const valid_modargs[] = {
"tsched_buffer_size", "tsched_buffer_size",
"tsched_buffer_watermark", "tsched_buffer_watermark",
"ignore_dB", "ignore_dB",
"control",
NULL NULL
}; };