forked from len0rd/rockbox
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
This commit is contained in:
parent
37fa620807
commit
26d8dce20a
1 changed files with 21 additions and 13 deletions
|
|
@ -30,10 +30,7 @@ http://www.audioscrobbler.net/wiki/Portable_Player_Logging
|
||||||
#include "audio.h"
|
#include "audio.h"
|
||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
#include "ata_idle_notify.h"
|
||||||
#ifndef SIMULATOR
|
|
||||||
#include "ata.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_RTC
|
#ifdef CONFIG_RTC
|
||||||
#include "time.h"
|
#include "time.h"
|
||||||
|
|
@ -51,7 +48,6 @@ http://www.audioscrobbler.net/wiki/Portable_Player_Logging
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* increment this on any code change that effects output */
|
/* increment this on any code change that effects output */
|
||||||
/* replace with CVS Revision keyword? */
|
|
||||||
#define SCROBBLER_REVISION " $Revision$"
|
#define SCROBBLER_REVISION " $Revision$"
|
||||||
|
|
||||||
#define SCROBBLER_MAX_CACHE 32
|
#define SCROBBLER_MAX_CACHE 32
|
||||||
|
|
@ -65,6 +61,7 @@ static int cache_pos;
|
||||||
static struct mp3entry scrobbler_entry;
|
static struct mp3entry scrobbler_entry;
|
||||||
static bool pending = false;
|
static bool pending = false;
|
||||||
static bool scrobbler_initialised = false;
|
static bool scrobbler_initialised = false;
|
||||||
|
static bool scrobbler_ata_callback = false;
|
||||||
#ifdef CONFIG_RTC
|
#ifdef CONFIG_RTC
|
||||||
static time_t timestamp;
|
static time_t timestamp;
|
||||||
#else
|
#else
|
||||||
|
|
@ -83,6 +80,8 @@ static void write_cache(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
scrobbler_ata_callback = false;
|
||||||
|
|
||||||
/* If the file doesn't exist, create it.
|
/* If the file doesn't exist, create it.
|
||||||
Check at each write since file may be deleted at any time */
|
Check at each write since file may be deleted at any time */
|
||||||
scrobbler_fd = open(SCROBBLER_FILE, O_RDONLY);
|
scrobbler_fd = open(SCROBBLER_FILE, O_RDONLY);
|
||||||
|
|
@ -133,16 +132,16 @@ static void write_cache(void)
|
||||||
scrobbler_fd = -1;
|
scrobbler_fd = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool scrobbler_flush_callback(void)
|
||||||
|
{
|
||||||
|
if (scrobbler_initialised && cache_pos)
|
||||||
|
write_cache();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static void add_to_cache(void)
|
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 )
|
if ( cache_pos >= SCROBBLER_MAX_CACHE )
|
||||||
#else
|
|
||||||
if ( ( cache_pos >= SCROBBLER_MAX_CACHE ) || ( ata_disk_is_active() ) )
|
|
||||||
#endif
|
|
||||||
#endif /* !SIMULATOR */
|
|
||||||
write_cache();
|
write_cache();
|
||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
@ -182,8 +181,12 @@ static void add_to_cache(void)
|
||||||
{
|
{
|
||||||
logf("SCROBBLER: entry too long:");
|
logf("SCROBBLER: entry too long:");
|
||||||
logf("SCROBBLER: %s", scrobbler_entry.path);
|
logf("SCROBBLER: %s", scrobbler_entry.path);
|
||||||
} else
|
} else {
|
||||||
cache_pos++;
|
cache_pos++;
|
||||||
|
if (!scrobbler_ata_callback)
|
||||||
|
scrobbler_ata_callback = register_ata_idle_func(scrobbler_flush_callback);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void scrobbler_change_event(struct mp3entry *id)
|
void scrobbler_change_event(struct mp3entry *id)
|
||||||
|
|
@ -248,6 +251,11 @@ void scrobbler_flush_cache(void)
|
||||||
|
|
||||||
void scrobbler_shutdown(void)
|
void scrobbler_shutdown(void)
|
||||||
{
|
{
|
||||||
|
#ifndef SIMULATOR
|
||||||
|
if (scrobbler_ata_callback)
|
||||||
|
unregister_ata_idle_func(scrobbler_flush_callback, false);
|
||||||
|
#endif
|
||||||
|
|
||||||
scrobbler_flush_cache();
|
scrobbler_flush_cache();
|
||||||
|
|
||||||
if (scrobbler_initialised)
|
if (scrobbler_initialised)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue