chiark / gitweb /
exercise the C client a bit from tests
[disorder] / disobedience / log.c
index 83db82e1396256416bc6c6fbea46577ef28213e9..b0aaace133ef1795dff00ed9ab1df1df64a9f324 100644 (file)
@@ -41,6 +41,7 @@ static void log_removed(void *v, const char *id, const char *user);
 static void log_scratched(void *v, const char *track, const char *user);
 static void log_state(void *v, unsigned long state);
 static void log_volume(void *v, int l, int r);
+static void log_rescanned(void *v);
 
 /** @brief Callbacks for server state monitoring */
 const disorder_eclient_log_callbacks log_callbacks = {
@@ -55,7 +56,8 @@ const disorder_eclient_log_callbacks log_callbacks = {
   log_removed,
   log_scratched,
   log_state,
-  log_volume
+  log_volume,
+  log_rescanned
 };
 
 /** @brief State monitor
@@ -81,9 +83,12 @@ static struct monitor *monitors;
 
 /** @brief Update everything */
 void all_update(void) {
+  ++suppress_actions;
   queue_update();
   recent_update();
   volume_update();
+  added_update();
+  --suppress_actions;
 }
 
 /** @brief Called when the client connects
@@ -164,7 +169,8 @@ static void log_state(void attribute((unused)) *v,
   const struct monitor *m;
   unsigned long changes = state ^ last_state;
   static int first = 1;
-  
+
+  ++suppress_actions;
   if(first) {
     changes = -1UL;
     first = 0;
@@ -179,18 +185,26 @@ static void log_state(void attribute((unused)) *v,
     if(changes & m->mask)
       m->callback(m->u);
   }
+  --suppress_actions;
 }
 
 /** @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;
+    ++suppress_actions;
     volume_update();
+    --suppress_actions;
   }
 }
 
+/** @brief Called when a rescan completes */
+static void log_rescanned(void attribute((unused)) *v) {
+  added_update();
+}
+
 /** @brief Add a monitor to the list
  * @param callback Function to call
  * @param u User data to pass to @p callback