1
0
mirror of https://github.com/SuperBFG7/ympd synced 2025-02-11 16:40:12 +00:00

Fix: handle duplicate idle player events for playCount updates

This commit is contained in:
jcorporation 2018-08-24 11:19:59 +01:00
parent a640b9010d
commit a9aa5a6741
3 changed files with 6 additions and 1 deletions

View File

@ -562,9 +562,10 @@ void mympd_parse_idle(struct mg_mgr *s, int idle_bitmask) {
break; break;
case MPD_IDLE_PLAYER: case MPD_IDLE_PLAYER:
len = mympd_put_state(mpd.buf, &mpd.song_id, &mpd.next_song_id, &mpd.last_song_id, &mpd.queue_version, &mpd.queue_length); len = mympd_put_state(mpd.buf, &mpd.song_id, &mpd.next_song_id, &mpd.last_song_id, &mpd.queue_version, &mpd.queue_length);
if (config.stickers && mpd.song_id != mpd.last_song_id) { if (config.stickers && mpd.song_id != mpd.last_song_id && mpd.last_update_sticker_song_id != mpd.song_id) {
mympd_count_song_id(mpd.song_id, "playCount", 1); mympd_count_song_id(mpd.song_id, "playCount", 1);
mympd_last_played_song_id(mpd.song_id); mympd_last_played_song_id(mpd.song_id);
mpd.last_update_sticker_song_id = mpd.song_id;
} }
break; break;
case MPD_IDLE_MIXER: case MPD_IDLE_MIXER:

View File

@ -127,6 +127,8 @@ struct t_mpd {
unsigned queue_version; unsigned queue_version;
unsigned queue_length; unsigned queue_length;
int timeout; int timeout;
int last_update_sticker_song_id;
} mpd; } mpd;
typedef struct { typedef struct {

View File

@ -183,6 +183,8 @@ int main(int argc, char **argv) {
config.mixramp = true; config.mixramp = true;
mpd.timeout = 3000; mpd.timeout = 3000;
mpd.last_update_sticker_song_id = -1;
mpd.last_song_id = -1;
if (argc == 2) { if (argc == 2) {
printf("Parsing config file: %s\n", argv[1]); printf("Parsing config file: %s\n", argv[1]);