X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/blobdiff_plain/219dc95cf771d5ba07aa19a3b33002a649682060..0a4af69255e6fee5274e645e96eee16b6c67a70c:/disobedience/log.c diff --git a/disobedience/log.c b/disobedience/log.c index d8dbe35..b0aaace 100644 --- a/disobedience/log.c +++ b/disobedience/log.c @@ -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,10 +83,12 @@ static struct monitor *monitors; /** @brief Update everything */ void all_update(void) { - playing_update(); + ++suppress_actions; queue_update(); recent_update(); volume_update(); + added_update(); + --suppress_actions; } /** @brief Called when the client connects @@ -105,16 +109,12 @@ static void log_connected(void attribute((unused)) *v) { /** @brief Called when the current track finishes playing */ static void log_completed(void attribute((unused)) *v, const char attribute((unused)) *track) { - playing = 0; - playing_update(); } /** @brief Called when the current track fails */ static void log_failed(void attribute((unused)) *v, const char attribute((unused)) *track, const char attribute((unused)) *status) { - playing = 0; - playing_update(); } /** @brief Called when some track is moved within the queue */ @@ -126,10 +126,6 @@ static void log_moved(void attribute((unused)) *v, static void log_playing(void attribute((unused)) *v, const char attribute((unused)) *track, const char attribute((unused)) *user) { - playing = 1; - playing_update(); - /* we get a log_removed() anyway so we don't need to update_queue() from - * here */ } /** @brief Called when a track is added to the queue */ @@ -157,6 +153,7 @@ static void log_recent_removed(void attribute((unused)) *v, static void log_removed(void attribute((unused)) *v, const char attribute((unused)) *id, const char attribute((unused)) *user) { + queue_update(); } @@ -164,8 +161,6 @@ static void log_removed(void attribute((unused)) *v, static void log_scratched(void attribute((unused)) *v, const char attribute((unused)) *track, const char attribute((unused)) *user) { - playing = 0; - playing_update(); } /** @brief Called when a state change occurs */ @@ -174,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; @@ -189,23 +185,33 @@ static void log_state(void attribute((unused)) *v, if(changes & m->mask) m->callback(m->u); } - /* If the track is paused or resume then the currently playing track is - * refetched so that we can continue to correctly calculate the played so-far - * field */ - playing_update(); + --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 Add a monitor to the list */ +/** @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 + * @param mask Mask of flags that @p callback cares about + * + * Pass @p mask as -1UL to match all flags. + */ void register_monitor(monitor_callback *callback, void *u, unsigned long mask) {