aboutsummaryrefslogtreecommitdiffstats
path: root/src/mixer/pulse_mixer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mixer/pulse_mixer.c')
-rw-r--r--src/mixer/pulse_mixer.c56
1 files changed, 27 insertions, 29 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;
+ if (!pm->online) {
+ return false;
+ }
- ret = (int)((100*(pa_cvolume_avg(&pm->volume)+1))/PA_VOLUME_NORM);
- g_debug("volume %d", ret);
- return ret;
+ 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;
}
- 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);
+ if (!pm->online) {
+ return false;
+ }
- 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_cvolume_set(&cvolume, pm->volume.channels,
+ (pa_volume_t)volume * PA_VOLUME_NORM / 100 + 0.5);
- pa_operation_unref(o);
+ 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;
}