summaryrefslogtreecommitdiffstats
path: root/src/modules/alsa/alsa-sink.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2009-02-14 00:21:36 +0100
committerLennart Poettering <lennart@poettering.net>2009-02-14 00:21:36 +0100
commit6790c03f91708540da284c80d0cb72cacf41c83d (patch)
treeda625b3e5cc69b3d3712a8c488ca2e7348312913 /src/modules/alsa/alsa-sink.c
parent023998e3c84c3158ab9f02e26949dbcd3e048886 (diff)
unify ALSA mixer initialization
Diffstat (limited to 'src/modules/alsa/alsa-sink.c')
-rw-r--r--src/modules/alsa/alsa-sink.c38
1 files changed, 1 insertions, 37 deletions
diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
index c56614c8..1474cfee 100644
--- a/src/modules/alsa/alsa-sink.c
+++ b/src/modules/alsa/alsa-sink.c
@@ -1386,43 +1386,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);
- if ((err = snd_mixer_open(&u->mixer_handle, 0)) < 0)
- pa_log_warn("Error opening mixer: %s", snd_strerror(err));
- else {
- pa_bool_t found = FALSE;
-
- if (pa_alsa_prepare_mixer(u->mixer_handle, u->device_name) >= 0)
- found = TRUE;
- else {
- snd_pcm_info_t *info;
-
- snd_pcm_info_alloca(&info);
-
- if (snd_pcm_info(u->pcm_handle, info) >= 0) {
- char *md;
- int card_idx;
-
- if ((card_idx = snd_pcm_info_get_card(info)) >= 0) {
-
- md = pa_sprintf_malloc("hw:%i", card_idx);
-
- if (strcmp(u->device_name, md))
- if (pa_alsa_prepare_mixer(u->mixer_handle, md) >= 0)
- found = TRUE;
- pa_xfree(md);
- }
- }
- }
-
- if (found)
- if (!(u->mixer_elem = pa_alsa_find_elem(u->mixer_handle, "Master", "PCM", TRUE)))
- found = FALSE;
-
- if (!found) {
- snd_mixer_close(u->mixer_handle);
- u->mixer_handle = NULL;
- }
- }
+ pa_alsa_find_mixer_and_elem(u->pcm_handle, &u->mixer_handle, &u->mixer_elem);
pa_sink_new_data_init(&data);
data.driver = driver;