Author: lslezak Date: Wed Apr 1 14:25:30 2009 New Revision: 56535 URL: http://svn.opensuse.org/viewcvs/yast?rev=56535&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: branches/SuSE-Code-11-Branch/sound/agent-audio/src/AlsaAudio.cc Modified: branches/SuSE-Code-11-Branch/sound/agent-audio/src/AlsaAudio.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/sound/agent-audio/src/AlsaAudio.cc?rev=56535&r1=56534&r2=56535&view=diff ============================================================================== --- branches/SuSE-Code-11-Branch/sound/agent-audio/src/AlsaAudio.cc (original) +++ branches/SuSE-Code-11-Branch/sound/agent-audio/src/AlsaAudio.cc Wed Apr 1 14:25:30 2009 @@ -80,18 +80,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) { @@ -101,7 +113,7 @@ value = (long long)(100.0 * ((double)(left - from) / (double)(to - from))); snd_mixer_close(handle); return YCPInteger(value); - } + } } } @@ -129,20 +141,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); + } } } @@ -168,11 +191,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 ); @@ -203,14 +238,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()); -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org