From 321f753675254b409a1ec3e578da0ae1940c4805 Mon Sep 17 00:00:00 2001 Message-Id: <321f753675254b409a1ec3e578da0ae1940c4805.1714127002.git.mdw@distorted.org.uk> From: Mark Wooding Date: Sun, 11 Nov 2007 19:24:07 +0000 Subject: [PATCH] disobedience volume control is local if rtp play Organization: Straylight/Edgeware From: Richard Kettlewell --- disobedience/control.c | 14 ++++++++++---- disobedience/disobedience.c | 35 ++++++++++++++++++----------------- disobedience/log.c | 2 +- lib/configuration.c | 2 ++ 4 files changed, 31 insertions(+), 22 deletions(-) diff --git a/disobedience/control.c b/disobedience/control.c index 1468168..ecdc1a6 100644 --- a/disobedience/control.c +++ b/disobedience/control.c @@ -22,6 +22,7 @@ */ #include "disobedience.h" +#include "mixer.h" /* Forward declarations ---------------------------------------------------- */ @@ -440,10 +441,15 @@ static void volume_adjusted(GtkAdjustment attribute((unused)) *a, b = nearbyint(5 * b) / 5; /* Set the volume. We don't want a reply, we'll get the actual new volume * from the log. */ - disorder_eclient_volume(client, 0, - nearbyint(left(v, b) * 100), - nearbyint(right(v, b) * 100), - 0); + if(rtp_supported) { + int l = nearbyint(left(v, b) * 100), r = nearbyint(right(v, b) * 100); + mixer_control(&l, &r, 1); + } else + /* We don't want a reply, we'll get the actual new volume from the log. */ + disorder_eclient_volume(client, 0, + nearbyint(left(v, b) * 100), + nearbyint(right(v, b) * 100), + 0); } /** @brief Formats the volume value */ diff --git a/disobedience/disobedience.c b/disobedience/disobedience.c index 9ae8eff..0b3408b 100644 --- a/disobedience/disobedience.c +++ b/disobedience/disobedience.c @@ -22,6 +22,7 @@ */ #include "disobedience.h" +#include "mixer.h" #include #include @@ -274,8 +275,8 @@ static const GMemVTable glib_memvtable = { }; #endif -/** @brief Called once every 10 minutes */ -static gboolean periodic(gpointer attribute((unused)) data) { +/** @brief Called occasionally */ +static gboolean periodic_slow(gpointer attribute((unused)) data) { D(("periodic")); /* Expire cached data */ cache_expire(); @@ -292,11 +293,9 @@ static gboolean periodic(gpointer attribute((unused)) data) { return TRUE; /* don't remove me */ } -/** @brief Called from time to time - * - * Used for debugging purposes - */ -static gboolean heartbeat(gpointer attribute((unused)) data) { +/** @brief Called frequently */ +static gboolean periodic_fast(gpointer attribute((unused)) data) { +#if 0 /* debugging hack */ static struct timeval last; struct timeval now; double delta; @@ -311,6 +310,15 @@ static gboolean heartbeat(gpointer attribute((unused)) data) { delta); } last = now; +#endif + if(rtp_supported) { + int nl, nr; + if(!mixer_control(&nl, &nr, 0) && (nl != volume_l || nr != volume_r)) { + volume_l = nl; + volume_r = nr; + volume_update(); + } + } return TRUE; } @@ -459,16 +467,9 @@ int main(int argc, char **argv) { if(!(client = gtkclient()) || !(logclient = gtkclient())) return 1; /* already reported an error */ - /* periodic operations (e.g. expiring the cache) */ -#if MDEBUG || MTRACK - g_timeout_add(5000/*milliseconds*/, periodic, 0); -#else - g_timeout_add(600000/*milliseconds*/, periodic, 0); -#endif - /* The point of this is to try and get a handle on mysterious - * unresponsiveness. It's not very useful in production use. */ - if(0) - g_timeout_add(1000/*milliseconds*/, heartbeat, 0); + /* periodic operations (e.g. expiring the cache, checking local volume) */ + g_timeout_add(600000/*milliseconds*/, periodic_slow, 0); + g_timeout_add(1000/*milliseconds*/, periodic_fast, 0); /* global tooltips */ tips = gtk_tooltips_new(); make_toplevel_window(); diff --git a/disobedience/log.c b/disobedience/log.c index 83aa582..af38643 100644 --- a/disobedience/log.c +++ b/disobedience/log.c @@ -187,7 +187,7 @@ static void log_state(void attribute((unused)) *v, /** @brief Called when volume changes */ static void log_volume(void attribute((unused)) *v, int l, int r) { - if(volume_l != l || volume_r != r) { + if(!rtp_supported && (volume_l != l || volume_r != r)) { volume_l = l; volume_r = r; volume_update(); diff --git a/lib/configuration.c b/lib/configuration.c index 3ca9a73..35ed090 100644 --- a/lib/configuration.c +++ b/lib/configuration.c @@ -1037,6 +1037,8 @@ static struct config *config_default(void) { c->authorization_algorithm = xstrdup("sha1"); c->noticed_history = 31; c->short_display = 32; + c->mixer = xstrdup("/dev/mixer"); + c->channel = xstrdup("pcm"); return c; } -- [mdw]