From 7f762a5cec9b4547182b13e577f5f8e48be46a8e Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 27 Mar 2009 16:44:37 +0100 Subject: [PATCH] pulse_mixer: return if mixer is offline Eliminate one indent level. Also remove several debug useless debug messages. --- src/mixer/pulse_mixer.c | 62 ++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/src/mixer/pulse_mixer.c b/src/mixer/pulse_mixer.c index f6b9acd40..1f077e2b7 100644 --- a/src/mixer/pulse_mixer.c +++ b/src/mixer/pulse_mixer.c @@ -314,49 +314,47 @@ pulse_mixer_get_volume(struct mixer *mixer) int ret; pa_operation *o; - g_debug("get_volume %s", - pm->online == TRUE ? "online" : "offline"); - if (pm->online) { - o = pa_context_get_sink_input_info(pm->context, pm->index, - sink_input_vol, pm); - if (o == NULL) { - g_debug("pa_context_get_sink_input_info() failed"); - return false; - } - - if (!pulse_wait_for_operation(pm->mainloop, o)) - return false; - - ret = (int)((100*(pa_cvolume_avg(&pm->volume)+1))/PA_VOLUME_NORM); - g_debug("volume %d", ret); - return ret; + if (!pm->online) { + return false; } - return false; + o = pa_context_get_sink_input_info(pm->context, pm->index, + sink_input_vol, pm); + if (o == NULL) { + g_debug("pa_context_get_sink_input_info() failed"); + return false; + } + + if (!pulse_wait_for_operation(pm->mainloop, o)) + return false; + + ret = (int)((100*(pa_cvolume_avg(&pm->volume)+1))/PA_VOLUME_NORM); + return ret; } static bool pulse_mixer_set_volume(struct mixer *mixer, unsigned volume) { struct pulse_mixer *pm = (struct pulse_mixer *) mixer; + struct pa_cvolume cvolume; + pa_operation *o; - if (pm->online) { - pa_operation *o; - struct pa_cvolume cvolume; - - pa_cvolume_set(&cvolume, pm->volume.channels, - (pa_volume_t)volume * PA_VOLUME_NORM / 100 + 0.5); - - o = pa_context_set_sink_input_volume(pm->context, pm->index, - &cvolume, NULL, NULL); - if (o == NULL) { - g_debug("pa_context_set_sink_input_volume() failed"); - return false; - } - - pa_operation_unref(o); + if (!pm->online) { + return false; } + pa_cvolume_set(&cvolume, pm->volume.channels, + (pa_volume_t)volume * PA_VOLUME_NORM / 100 + 0.5); + + o = pa_context_set_sink_input_volume(pm->context, pm->index, + &cvolume, NULL, NULL); + if (o == NULL) { + g_debug("pa_context_set_sink_input_volume() failed"); + return false; + } + + pa_operation_unref(o); + return true; }