aboutsummaryrefslogtreecommitdiffstats
path: root/src/Volume.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-11-24 20:20:57 +0100
committerMax Kellermann <max@duempel.org>2013-11-25 22:09:46 +0100
commit51de8fd10a98e6ed9a2ac10a796236c5b3fe2bf8 (patch)
tree2d908b259fa90cafd765566cbf24ef7f325fca93 /src/Volume.cxx
parent2ef6052536b91d9312191ca91de663b73249aea5 (diff)
downloadmpd-51de8fd10a98e6ed9a2ac10a796236c5b3fe2bf8.tar.gz
mpd-51de8fd10a98e6ed9a2ac10a796236c5b3fe2bf8.tar.xz
mpd-51de8fd10a98e6ed9a2ac10a796236c5b3fe2bf8.zip
Volume, Output: use new class PeriodClock instead of GTimer
Diffstat (limited to '')
-rw-r--r--src/Volume.cxx15
1 files changed, 3 insertions, 12 deletions
diff --git a/src/Volume.cxx b/src/Volume.cxx
index 6c5f8dc4d..3f7210f6c 100644
--- a/src/Volume.cxx
+++ b/src/Volume.cxx
@@ -23,6 +23,7 @@
#include "Idle.hxx"
#include "GlobalEvents.hxx"
#include "util/Domain.hxx"
+#include "system/PeriodClock.hxx"
#include "Log.hxx"
#include <glib.h>
@@ -39,7 +40,7 @@ static unsigned volume_software_set = 100;
/** the cached hardware mixer value; invalid if negative */
static int last_hardware_volume = -1;
/** the age of #last_hardware_volume */
-static GTimer *hardware_volume_timer;
+static PeriodClock hardware_volume_clock;
/**
* Handler for #GlobalEvents::MIXER.
@@ -54,29 +55,19 @@ mixer_event_callback(void)
idle_add(IDLE_MIXER);
}
-void volume_finish(void)
-{
- g_timer_destroy(hardware_volume_timer);
-}
-
void volume_init(void)
{
- hardware_volume_timer = g_timer_new();
-
GlobalEvents::Register(GlobalEvents::MIXER, mixer_event_callback);
}
int volume_level_get(void)
{
- assert(hardware_volume_timer != nullptr);
-
if (last_hardware_volume >= 0 &&
- g_timer_elapsed(hardware_volume_timer, nullptr) < 1.0)
+ !hardware_volume_clock.CheckUpdate(1000))
/* throttle access to hardware mixers */
return last_hardware_volume;
last_hardware_volume = mixer_all_get_volume();
- g_timer_start(hardware_volume_timer);
return last_hardware_volume;
}