chiark / gitweb /
disobedience volume control is local if rtp play
authorRichard Kettlewell <rjk@greenend.org.uk>
Sun, 11 Nov 2007 19:24:07 +0000 (19:24 +0000)
committerRichard Kettlewell <rjk@greenend.org.uk>
Sun, 11 Nov 2007 19:24:07 +0000 (19:24 +0000)
disobedience/control.c
disobedience/disobedience.c
disobedience/log.c
lib/configuration.c

index 146816874a78dac8083d566aef3659ddd0ed018f..ecdc1a6bb9f6ba8da2dfd0c8e4637511b662a3f0 100644 (file)
@@ -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 */
index 9ae8effd6fcb14a5307939936653fe8b5a5ce0ff..0b3408b897d75a638b6fc7954a2e620fe7c72b74 100644 (file)
@@ -22,6 +22,7 @@
  */
 
 #include "disobedience.h"
+#include "mixer.h"
 
 #include <getopt.h>
 #include <locale.h>
@@ -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();
index 83aa5826b92323021848a64de7390bc88b11ff2a..af386431f0fb66b2ff1af6a049f608aa5e43f994 100644 (file)
@@ -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();
index 3ca9a737775cd7973f95a66e91866e132db4f378..35ed090a012e6bd97e2153fe529d037d70e28422 100644 (file)
@@ -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;
 }