[yast-commit] r56515 - in /trunk/sound: agent-audio/src/AlsaAudio.cc package/yast2-sound.changes
Author: lslezak Date: Tue Mar 31 19:03:28 2009 New Revision: 56515 URL: http://svn.opensuse.org/viewcvs/yast?rev=56515&view=rev Log: - improved logging in alsa-agent when a requested volume setting failed due to an unsupported operation (e.g. missing mute switch) Modified: trunk/sound/agent-audio/src/AlsaAudio.cc trunk/sound/package/yast2-sound.changes Modified: trunk/sound/agent-audio/src/AlsaAudio.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/sound/agent-audio/src/AlsaAudio.cc?rev=56515&r1=56514&r2=56515&view=diff ============================================================================== --- trunk/sound/agent-audio/src/AlsaAudio.cc (original) +++ trunk/sound/agent-audio/src/AlsaAudio.cc Tue Mar 31 19:03:28 2009 @@ -77,18 +77,30 @@ // is it the required channel? if (snd_mixer_selem_id_get_name(sid) == channel - && snd_mixer_selem_get_index(elem) == ch_index - && snd_mixer_selem_is_active(elem) - && snd_mixer_selem_has_playback_volume(elem)) + && snd_mixer_selem_get_index(elem) == ch_index) { + if (!snd_mixer_selem_is_active(elem)) + { + y2warning("Channel %s is not active", channel_name.c_str()); + snd_mixer_close(handle); + return YCPBoolean(false); + } + + if (!snd_mixer_selem_has_playback_volume(elem)) + { + y2warning("Channel %s has no volume control", channel_name.c_str()); + snd_mixer_close(handle); + return YCPBoolean(false); + } + snd_mixer_selem_get_playback_volume_range(elem, &from, &to); for (chn = (snd_mixer_selem_channel_id_t)0; - chn <= SND_MIXER_SCHN_LAST; - chn=(snd_mixer_selem_channel_id_t)((int)chn+(snd_mixer_selem_channel_id_t)1)) - { + chn <= SND_MIXER_SCHN_LAST; + chn=(snd_mixer_selem_channel_id_t)((int)chn+(snd_mixer_selem_channel_id_t)1)) + { if (!snd_mixer_selem_has_playback_channel(elem, chn)) - continue; - snd_mixer_selem_get_playback_volume(elem, chn, &left); + continue; + snd_mixer_selem_get_playback_volume(elem, chn, &left); if (to - from == 0) { @@ -98,7 +110,7 @@ value = (long long)(100.0 * ((double)(left - from) / (double)(to - from))); snd_mixer_close(handle); return YCPInteger(value); - } + } } } @@ -126,20 +138,31 @@ { snd_mixer_selem_get_id(elem, sid); if (snd_mixer_selem_id_get_name(sid) == channel - && snd_mixer_selem_get_index(elem) == ch_index - && snd_mixer_selem_is_active(elem) - && snd_mixer_selem_has_playback_switch(elem)) + && snd_mixer_selem_get_index(elem) == ch_index) { - for (chn = (snd_mixer_selem_channel_id_t)0; - chn <= SND_MIXER_SCHN_LAST; - chn=(snd_mixer_selem_channel_id_t)((int)chn+(snd_mixer_selem_channel_id_t)1)) - { - // if ( - snd_mixer_selem_get_playback_switch(elem, chn, &left); + if (!snd_mixer_selem_is_active(elem)) + { + y2warning("Channel %s is not active", channel_name.c_str()); + snd_mixer_close(handle); + return YCPBoolean(false); + } + + if (!snd_mixer_selem_has_playback_switch(elem)) + { + y2warning("Channel %s has no mute switch", channel_name.c_str()); + snd_mixer_close(handle); + return YCPBoolean(false); + } + + for (chn = (snd_mixer_selem_channel_id_t)0; + chn <= SND_MIXER_SCHN_LAST; + chn=(snd_mixer_selem_channel_id_t)((int)chn+(snd_mixer_selem_channel_id_t)1)) + { + snd_mixer_selem_get_playback_switch(elem, chn, &left); snd_mixer_close(handle); - return left ? YCPBoolean(false) : YCPBoolean(true); - } + return left ? YCPBoolean(false) : YCPBoolean(true); + } } } @@ -165,11 +188,23 @@ { snd_mixer_selem_get_id(elem, sid); if (snd_mixer_selem_id_get_name(sid) == channel - && snd_mixer_selem_get_index(elem) == ch_index - && snd_mixer_selem_is_active(elem) - && snd_mixer_selem_has_playback_volume(elem)) + && snd_mixer_selem_get_index(elem) == ch_index) { - snd_mixer_selem_get_playback_volume_range(elem, &from, &to); + if (!snd_mixer_selem_is_active(elem)) + { + y2warning("Channel %s is not active", channel_name.c_str()); + snd_mixer_close(handle); + return YCPBoolean(false); + } + + if (!snd_mixer_selem_has_playback_volume(elem)) + { + y2warning("Channel %s has no volume control", channel_name.c_str()); + snd_mixer_close(handle); + return YCPBoolean(false); + } + + snd_mixer_selem_get_playback_volume_range(elem, &from, &to); val = (long)( (double)(value * (to - from)) / 100.0 ); @@ -200,14 +235,26 @@ { snd_mixer_selem_get_id(elem, sid); if (snd_mixer_selem_id_get_name(sid) == channel - && snd_mixer_selem_get_index(elem) == ch_index - && snd_mixer_selem_is_active(elem) - && snd_mixer_selem_has_playback_switch(elem)) - { + && snd_mixer_selem_get_index(elem) == ch_index) + { + if (!snd_mixer_selem_is_active(elem)) + { + y2warning("Channel %s is not active", channel_name.c_str()); + snd_mixer_close(handle); + return YCPBoolean(false); + } + + if (!snd_mixer_selem_has_playback_switch(elem)) + { + y2warning("Channel %s has no mute switch", channel_name.c_str()); + snd_mixer_close(handle); + return YCPBoolean(false); + } + snd_mixer_selem_set_playback_switch_all(elem, value ? 0 : 1); snd_mixer_close(handle); return YCPBoolean(true); - } + } } y2warning("Card %d: channel '%s' not found", card_id, channel_name.c_str()); Modified: trunk/sound/package/yast2-sound.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/sound/package/yast2-sound.changes?rev=56515&r1=56514&r2=56515&view=diff ============================================================================== --- trunk/sound/package/yast2-sound.changes (original) +++ trunk/sound/package/yast2-sound.changes Tue Mar 31 19:03:28 2009 @@ -1,4 +1,11 @@ ------------------------------------------------------------------- +Tue Mar 31 19:00:20 CEST 2009 - lslezak@suse.cz + +- improved logging in alsa-agent when a requested volume + setting failed due to an unsupported operation + (e.g. missing mute switch) + +------------------------------------------------------------------- Thu Mar 26 12:54:41 CET 2009 - lslezak@suse.cz - Use /etc/modprobe.d/50-sound.conf config file instead of -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
lslezak@svn.opensuse.org