From b8ccc885c883a24265cd49de385b61d368a1b66f Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 21 Oct 2009 09:48:37 +0200 Subject: [PATCH] volume: added PIPE_EVENT_MIXER Flush the hardware volume cache, and send the MIXER idle event. This allows mixer plugins to detect volume changes. --- src/event_pipe.h | 3 +++ src/volume.c | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/event_pipe.h b/src/event_pipe.h index 33f92d440..4614ef25c 100644 --- a/src/event_pipe.h +++ b/src/event_pipe.h @@ -41,6 +41,9 @@ enum pipe_event { /** SIGHUP received: reload configuration, roll log file */ PIPE_EVENT_RELOAD, + /** a hardware mixer plugin has detected a change */ + PIPE_EVENT_MIXER, + PIPE_EVENT_MAX }; diff --git a/src/volume.c b/src/volume.c index 8b33f592d..1be0705af 100644 --- a/src/volume.c +++ b/src/volume.c @@ -27,6 +27,7 @@ #include "mixer_control.h" #include "mixer_all.h" #include "mixer_type.h" +#include "event_pipe.h" #include @@ -47,6 +48,19 @@ static int last_hardware_volume = -1; /** the age of #last_hardware_volume */ static GTimer *hardware_volume_timer; +/** + * Handler for #PIPE_EVENT_MIXER. + */ +static void +mixer_event_callback(void) +{ + /* flush the hardware volume cache */ + last_hardware_volume = -1; + + /* notify clients */ + idle_add(IDLE_MIXER); +} + void volume_finish(void) { g_timer_destroy(hardware_volume_timer); @@ -55,6 +69,8 @@ void volume_finish(void) void volume_init(void) { hardware_volume_timer = g_timer_new(); + + event_pipe_register(PIPE_EVENT_MIXER, mixer_event_callback); } int volume_level_get(void)