Author: dannym Date: 2007-04-24 21:36:07 +0000 (Tue, 24 Apr 2007) New Revision: 25632
Modified: xfce4-mixer/trunk/lib/vc_alsa.c Log: remove magic Master selection, an artifact from the past (since everywhere, the master control can be chosen now, might as well leave the user guessing which it is) Modified: xfce4-mixer/trunk/lib/vc_alsa.c =================================================================== --- xfce4-mixer/trunk/lib/vc_alsa.c 2007-04-24 10:38:25 UTC (rev 25631) +++ xfce4-mixer/trunk/lib/vc_alsa.c 2007-04-24 21:36:07 UTC (rev 25632) @@ -65,7 +65,6 @@ #endif static snd_mixer_t *handle = NULL; -static snd_mixer_elem_t *elem = NULL; static char card[64] = "default"; #define MAX_MASTERS 10 @@ -125,14 +124,12 @@ snd_mixer_selem_id_t* master_selectors[MAX_MASTERS] = { NULL }; - elem = NULL; - if (handle != NULL) { snd_mixer_close(handle); handle = NULL; } - if ((err = snd_mixer_open(&handle, 0)) < 0 || !handle) { + if ((err = snd_mixer_open(&handle, 0)) < 0 || handle == NULL) { error(_("alsa: Mixer %s open error: %s\n"), card, snd_strerror(err)); return; } @@ -141,7 +138,6 @@ error(_("alsa: Mixer attach %s error: %s\n"), card, snd_strerror(err)); snd_mixer_close(handle); /* <-- alsa 0.9.3a fails assert(hctl) if I do that... weeeeird... */ handle = NULL; - elem = NULL; /* just to be sure */ return; } if ((err = snd_mixer_selem_register(handle, NULL, NULL)) < 0) { @@ -161,38 +157,6 @@ handle = NULL; return; } - - - for (i = 0; elem == NULL && i < MAX_MASTERS && master_ids[i] != NULL; i++) { - snd_mixer_selem_id_alloca(&master_selectors[i]); - snd_mixer_selem_id_set_index(master_selectors[i], 0); - snd_mixer_selem_id_set_name(master_selectors[i], master_ids[i]); - - elem = snd_mixer_find_selem(handle, master_selectors[i]); - - if (elem != NULL) { - if (!snd_mixer_selem_has_common_volume(elem) - && !snd_mixer_selem_has_playback_volume(elem) - ) { /* no playback device */ - elem = NULL; - } - } - - - -#ifdef TRACE - error(_("alsa: Unable to find simple control '%s',%i\n"), - snd_mixer_selem_id_get_name(master_selectors[i]), snd_mixer_selem_id_get_index(master_selectors[i])); -#endif - } - - if (elem == NULL) { - show_developer_hint (); - - snd_mixer_close(handle); - handle = NULL; - return; - } } static void vc_set_device(char const *name) @@ -214,7 +178,9 @@ static int vc_reinit_device(void) { find_master(); - if (!elem) return -1; + if (handle == NULL) { + return -1; + } return 0; } @@ -284,11 +250,7 @@ return 0; } - if (which != NULL) { - xelem = find_control (which); - } else { - xelem = elem; - } + xelem = (which != NULL) ? find_control (which) : NULL; if (xelem == NULL) { return 0; @@ -365,11 +327,7 @@ return; } - if (which != NULL) { - xelem = find_control (which); - } else { - xelem = elem; - } + xelem = (which != NULL) ? find_control (which) : NULL; if (xelem == NULL) { return; @@ -466,7 +424,7 @@ if (!g) return NULL; #endif - if (!handle) { + if (handle == NULL) { return NULL; } @@ -539,7 +497,9 @@ { /* supports 1 (ONE) callback */ - if (!handle) return; + if (handle == NULL) { + return; + } mycb = cb; mydata = data; @@ -550,12 +510,12 @@ static void vc_close_device() { - if (!handle) return; + if (handle == NULL) { + return; + } snd_mixer_close (handle); /* FIXME does this close all related stuff? */ handle = NULL; - - elem = NULL; } static GList *vc_get_device_list() @@ -630,15 +590,16 @@ gint i; gchar *s; snd_mixer_elem_t *xelem = NULL; - if (!handle) return; - if (which) { - xelem = find_control (which); - } else { - xelem = elem; + + if (handle == NULL) { + return; } - if (!xelem) return; + xelem = (which != NULL) ? find_control (which) : NULL; + if (xelem == NULL) { + return; + } g = vc_get_choices (xelem); if (!g || !v) @@ -663,14 +624,15 @@ GList *g; gchar *s; snd_mixer_elem_t *xelem = NULL; - if (!handle) return NULL; - if (which) { - xelem = find_control (which); - } else { - xelem = elem; + if (handle == NULL) { + return NULL; } + + xelem = (which != NULL) ? find_control (which) : NULL; - if (!xelem) return NULL; + if (xelem == NULL) { + return NULL; + } if (snd_mixer_selem_get_enum_item(xelem, SND_MIXER_SCHN_MONO, &jj) < 0) return NULL; @@ -694,14 +656,16 @@ static void vc_set_switch(char const *which, gboolean v) { snd_mixer_elem_t *xelem = NULL; - if (!handle) return; - if (which) { - xelem = find_control (which); - } else { - xelem = elem; + + if (handle == NULL) { + return; } + + xelem = (which != NULL) ? find_control (which) : NULL; - if (!xelem) return; + if (xelem == NULL) { + return; + } /* && (snd_mixer_selem_has_common_switch(i) || snd_mixer_selem_has_playback_switch(i) @@ -719,13 +683,11 @@ if (!handle) return FALSE; - if (which) { - xelem = find_control (which); - } else { - xelem = elem; - } + xelem = (which != NULL) ? find_control (which) : NULL; - if (!xelem) return FALSE; + if (xelem == NULL) { + return FALSE; + } chn = SND_MIXER_SCHN_MONO; _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org http://foo-projects.org/mailman/listinfo/xfce4-commits