summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2007-02-11 05:34:14 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2007-02-11 05:34:14 +0000
commit26d8dce20a619275844d92fbcee04cda9b5dea3a (patch)
tree9a24ac7a1589c2d51f59175ecb1b44e54fa4b0a3 /apps
parent37fa6208071dc46befce7440b756cbaf945e63bc (diff)
downloadrockbox-26d8dce20a619275844d92fbcee04cda9b5dea3a.zip
rockbox-26d8dce20a619275844d92fbcee04cda9b5dea3a.tar.gz
rockbox-26d8dce20a619275844d92fbcee04cda9b5dea3a.tar.bz2
rockbox-26d8dce20a619275844d92fbcee04cda9b5dea3a.tar.xz
Accept FS#6644 - use the ata_idle_nofity stuff for the last.fm logging
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12267 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/scrobbler.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/apps/scrobbler.c b/apps/scrobbler.c
index cc05e3e..a339429 100644
--- a/apps/scrobbler.c
+++ b/apps/scrobbler.c
@@ -30,10 +30,7 @@ http://www.audioscrobbler.net/wiki/Portable_Player_Logging
#include "audio.h"
#include "buffer.h"
#include "settings.h"
-
-#ifndef SIMULATOR
-#include "ata.h"
-#endif
+#include "ata_idle_notify.h"
#ifdef CONFIG_RTC
#include "time.h"
@@ -51,7 +48,6 @@ http://www.audioscrobbler.net/wiki/Portable_Player_Logging
#endif
/* increment this on any code change that effects output */
-/* replace with CVS Revision keyword? */
#define SCROBBLER_REVISION " $Revision$"
#define SCROBBLER_MAX_CACHE 32
@@ -65,6 +61,7 @@ static int cache_pos;
static struct mp3entry scrobbler_entry;
static bool pending = false;
static bool scrobbler_initialised = false;
+static bool scrobbler_ata_callback = false;
#ifdef CONFIG_RTC
static time_t timestamp;
#else
@@ -83,6 +80,8 @@ static void write_cache(void)
{
int i;
+ scrobbler_ata_callback = false;
+
/* If the file doesn't exist, create it.
Check at each write since file may be deleted at any time */
scrobbler_fd = open(SCROBBLER_FILE, O_RDONLY);
@@ -133,16 +132,16 @@ static void write_cache(void)
scrobbler_fd = -1;
}
+static bool scrobbler_flush_callback(void)
+{
+ if (scrobbler_initialised && cache_pos)
+ write_cache();
+ return true;
+}
+
static void add_to_cache(void)
{
-/* using HAVE_MMC to check for Ondios - anything better to use? */
-#ifndef SIMULATOR
-#if defined(IPOD_NANO) || defined(HAVE_MMC)
if ( cache_pos >= SCROBBLER_MAX_CACHE )
-#else
- if ( ( cache_pos >= SCROBBLER_MAX_CACHE ) || ( ata_disk_is_active() ) )
-#endif
-#endif /* !SIMULATOR */
write_cache();
int ret;
@@ -182,8 +181,12 @@ static void add_to_cache(void)
{
logf("SCROBBLER: entry too long:");
logf("SCROBBLER: %s", scrobbler_entry.path);
- } else
+ } else {
cache_pos++;
+ if (!scrobbler_ata_callback)
+ scrobbler_ata_callback = register_ata_idle_func(scrobbler_flush_callback);
+ }
+
}
void scrobbler_change_event(struct mp3entry *id)
@@ -248,6 +251,11 @@ void scrobbler_flush_cache(void)
void scrobbler_shutdown(void)
{
+#ifndef SIMULATOR
+ if (scrobbler_ata_callback)
+ unregister_ata_idle_func(scrobbler_flush_callback, false);
+#endif
+
scrobbler_flush_cache();
if (scrobbler_initialised)