]> Untitled Git - mpdstream/commitdiff
Monitor state changes
authorHugo Villeneuve <hvilleneuve@dimonoff.com>
Tue, 31 Mar 2026 18:55:46 +0000 (14:55 -0400)
committerHugo Villeneuve <hvilleneuve@dimonoff.com>
Tue, 31 Mar 2026 20:34:21 +0000 (16:34 -0400)
Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
src/main.c

index 817c9ba8dc063c1b1929fd63438ad3dc4303f032..9e21a5b4b35b36c802634d14e6c6b7db06f61110 100644 (file)
@@ -147,6 +147,7 @@ int mpd_check_abnormal_stop(struct mpd_status *status)
 int
 main(int argc, char **argv)
 {
+       enum mpd_state last_state;
        int rc;
 
        openlog(PACKAGE_NAME, 0, LOG_USER);
@@ -168,6 +169,7 @@ main(int argc, char **argv)
 
        is_stream = false;
        song_id = -1;
+       last_state = -1;
 
        while (true) {
                struct mpd_status *status;
@@ -190,6 +192,8 @@ main(int argc, char **argv)
                        continue;
 
                state = mpd_status_get_state(status);
+               if (state == last_state)
+                       continue;
 
                switch (state) {
                case MPD_STATE_PLAY: