summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorNils Wallménius <nils@rockbox.org>2008-04-15 18:10:22 +0000
committerNils Wallménius <nils@rockbox.org>2008-04-15 18:10:22 +0000
commitfd1e1b7706c47c2c1dff29819bad73118818a512 (patch)
tree4486dbe32530fc3ba9fdc8bb45366174fb6c293b /apps
parentba58dd8d3556acaec364b600dc93d0a48d2dc548 (diff)
downloadrockbox-fd1e1b7706c47c2c1dff29819bad73118818a512.tar.gz
rockbox-fd1e1b7706c47c2c1dff29819bad73118818a512.zip
Slight clean up and binsize save
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17122 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/scrobbler.c34
1 files changed, 15 insertions, 19 deletions
diff --git a/apps/scrobbler.c b/apps/scrobbler.c
index 85285cb911..f05bbdb1f4 100644
--- a/apps/scrobbler.c
+++ b/apps/scrobbler.c
@@ -31,6 +31,7 @@ http://www.audioscrobbler.net/wiki/Portable_Player_Logging
#include "buffer.h"
#include "settings.h"
#include "ata_idle_notify.h"
+#include "misc.h"
#if CONFIG_RTC
#include "time.h"
@@ -56,7 +57,6 @@ http://www.audioscrobbler.net/wiki/Portable_Player_Logging
static char* scrobbler_cache;
-static int scrobbler_fd = -1;
static int cache_pos;
static struct mp3entry scrobbler_entry;
static bool pending = false;
@@ -79,48 +79,45 @@ unsigned long audio_prev_elapsed(void)
static void write_cache(void)
{
int i;
+ int fd;
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);
- if(scrobbler_fd < 0)
+ if(!file_exists(SCROBBLER_FILE))
{
- scrobbler_fd = open(SCROBBLER_FILE, O_RDWR | O_CREAT);
- if(scrobbler_fd >= 0)
+ fd = open(SCROBBLER_FILE, O_RDWR | O_CREAT);
+ if(fd >= 0)
{
- fdprintf(scrobbler_fd, "#AUDIOSCROBBLER/%s\n", SCROBBLER_VERSION);
- fdprintf(scrobbler_fd, "#TZ/UNKNOWN\n");
+ fdprintf(fd, "#AUDIOSCROBBLER/" SCROBBLER_VERSION "\n"
+ "#TZ/UNKNOWN\n"
#if CONFIG_RTC
- fdprintf(scrobbler_fd,
- "#CLIENT/Rockbox " TARGET_NAME SCROBBLER_REVISION "\n");
+ "#CLIENT/Rockbox " TARGET_NAME SCROBBLER_REVISION "\n");
#else
- fdprintf(scrobbler_fd,
- "#CLIENT/Rockbox " TARGET_NAME SCROBBLER_REVISION " Timeless\n");
+ "#CLIENT/Rockbox " TARGET_NAME SCROBBLER_REVISION " Timeless\n");
#endif
- close(scrobbler_fd);
+
+ close(fd);
}
else
{
logf("SCROBBLER: cannot create log file");
}
}
- close(scrobbler_fd);
- scrobbler_fd = -1;
/* write the cache entries */
- scrobbler_fd = open(SCROBBLER_FILE, O_WRONLY | O_APPEND);
- if(scrobbler_fd >= 0)
+ fd = open(SCROBBLER_FILE, O_WRONLY | O_APPEND);
+ if(fd >= 0)
{
logf("SCROBBLER: writing %d entries", cache_pos);
for ( i=0; i < cache_pos; i++ )
{
logf("SCROBBLER: write %d", i);
- fdprintf(scrobbler_fd, "%s", scrobbler_cache+(SCROBBLER_CACHE_LEN*i));
+ fdprintf(fd, "%s", scrobbler_cache+(SCROBBLER_CACHE_LEN*i));
}
- close(scrobbler_fd);
+ close(fd);
}
else
{
@@ -129,7 +126,6 @@ static void write_cache(void)
/* clear even if unsuccessful - don't want to overflow the buffer */
cache_pos = 0;
- scrobbler_fd = -1;
}
static bool scrobbler_flush_callback(void)