summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2022-04-02 08:00:31 -0400
committerWilliam Wilgus <wilgus.william@gmail.com>2022-04-02 08:05:37 -0400
commitbf3e67204c6ceb26acba33df529d3d986e736d6c (patch)
tree8adafd9ddec3a3ce62039ef361bd598da244c3aa
parent43abe2d820d6725a9e8a248233539a6ffdc2d712 (diff)
downloadrockbox-bf3e67204c6ceb26acba33df529d3d986e736d6c.tar.gz
rockbox-bf3e67204c6ceb26acba33df529d3d986e736d6c.zip
lastfm_scrobbler check for back to back repeat entriesbootloader_shanlingq1_v2bootloader_fiiom3k_v3
if you skip a track after the halfway point the scrobbler may double post with slightly different timestamps but the same track info take a crc of the non-unique part and check against the previously written track Change-Id: I676342c4cd76f632131d9cb6d9f7d2f59df357e6
-rw-r--r--apps/plugins/lastfm_scrobbler.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/apps/plugins/lastfm_scrobbler.c b/apps/plugins/lastfm_scrobbler.c
index 7f424d8aca..4d4940945d 100644
--- a/apps/plugins/lastfm_scrobbler.c
+++ b/apps/plugins/lastfm_scrobbler.c
@@ -27,6 +27,10 @@ http://www.audioscrobbler.net/wiki/Portable_Player_Logging
#include "plugin.h"
+#ifndef UNTAGGED
+ #define UNTAGGED "<UNTAGGED>"
+#endif
+
#ifdef ROCKBOX_HAS_LOGF
#define logf rb->logf
#else
@@ -324,6 +328,9 @@ static inline char* str_chk_valid(char *s, char *alt)
static void scrobbler_add_to_cache(const struct mp3entry *id)
{
+ static uint32_t last_crc = 0;
+ int trk_info_len = 0;
+
if ( gCache.pos >= SCROBBLER_MAX_CACHE )
scrobbler_write_cache();
@@ -344,13 +351,14 @@ static void scrobbler_add_to_cache(const struct mp3entry *id)
int ret = rb->snprintf(&scrobbler_buf[(SCROBBLER_CACHE_LEN*gCache.pos)],
SCROBBLER_CACHE_LEN,
- "%s\t%s\t%s\t%s\t%d\t%c\t%ld\t%s\n",
+ "%s\t%s\t%s\t%s\t%d\t%c%n\t%ld\t%s\n",
str_chk_valid(artist, UNTAGGED),
str_chk_valid(id->album, ""),
str_chk_valid(id->title, ""),
tracknum,
(int)(id->length / 1000),
rating,
+ &trk_info_len,
get_timestamp(),
str_chk_valid(id->mb_track_id, ""));
@@ -361,11 +369,19 @@ static void scrobbler_add_to_cache(const struct mp3entry *id)
}
else
{
- logf("Added %s", scrobbler_buf);
- gCache.pos++;
+ uint32_t crc = rb->crc_32(&scrobbler_buf[(SCROBBLER_CACHE_LEN*gCache.pos)],
+ trk_info_len, 0xFFFFFFFF);
+ if (crc != last_crc)
+ {
+ last_crc = crc;
+ logf("Added %s", scrobbler_buf);
+ gCache.pos++;
#if USING_STORAGE_CALLBACK
- rb->register_storage_idle_func(scrobbler_flush_callback);
+ rb->register_storage_idle_func(scrobbler_flush_callback);
#endif
+ }
+ else
+ logf("SCROBBLER: skipping repeat entry: %s", id->path);
}
}