summaryrefslogtreecommitdiffstats
path: root/apps/playlist.c
diff options
context:
space:
mode:
authorMiika Pekkarinen <miipekk@ihme.org>2011-06-21 17:42:31 +0000
committerMiika Pekkarinen <miipekk@ihme.org>2011-06-21 17:42:31 +0000
commit2bc133dce9271874433cbbaeb74667be4a7d5710 (patch)
tree10bd6700d2fc6c01d055c69c0a6502d4ae09d82b /apps/playlist.c
parentc4f6e340f8ea70ed88209783efb7fc61e69e6344 (diff)
downloadrockbox-2bc133dce9271874433cbbaeb74667be4a7d5710.tar.gz
rockbox-2bc133dce9271874433cbbaeb74667be4a7d5710.tar.bz2
rockbox-2bc133dce9271874433cbbaeb74667be4a7d5710.zip
Try to handle dircache rebuild event properly. Playlist should now
cache new pointers to dircache items when dircache goes offline and comes back onlineagain (during tagcache commit). This should prevent wrong filenames to appear in playlist. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30047 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/playlist.c')
-rw-r--r--apps/playlist.c33
1 files changed, 25 insertions, 8 deletions
diff --git a/apps/playlist.c b/apps/playlist.c
index ea183d7552..fc6b20307b 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -1244,7 +1244,12 @@ static void playlist_flush_callback(void *param)
sync_control(playlist, true);
}
}
-
+
+static bool is_dircache_pointers_intact(void)
+{
+ return dircache_get_appflag(DIRCACHE_APPFLAG_PLAYLIST) ? true : false;
+}
+
static void playlist_thread(void)
{
struct queue_event ev;
@@ -1277,6 +1282,7 @@ static void playlist_thread(void)
/* Start the background scanning after either the disk spindown
timeout or 5s, whichever is less */
case SYS_TIMEOUT:
+ {
playlist = &current_playlist;
if (playlist->control_fd >= 0)
{
@@ -1284,11 +1290,14 @@ static void playlist_thread(void)
register_storage_idle_func(playlist_flush_callback);
}
- if (!dirty_pointers)
- break ;
-
if (!dircache_is_enabled() || !playlist->filenames
|| playlist->amount <= 0)
+ {
+ break ;
+ }
+
+ /* Check if previously loaded pointers are intact. */
+ if (is_dircache_pointers_intact() && !dirty_pointers)
break ;
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
@@ -1298,7 +1307,7 @@ static void playlist_thread(void)
&& queue_empty(&playlist_queue); index++)
{
/* Process only pointers that are not already loaded. */
- if (playlist->filenames[index] >= 0)
+ if (is_dircache_pointers_intact() && playlist->filenames[index] >= 0)
continue ;
control_file = playlist->indices[index] & PLAYLIST_INSERT_TYPE_MASK;
@@ -1307,7 +1316,9 @@ static void playlist_thread(void)
/* Load the filename from playlist file. */
if (get_filename(playlist, index, seek, control_file, tmp,
sizeof(tmp)) < 0)
+ {
break ;
+ }
/* Set the dircache entry pointer. */
playlist->filenames[index] = dircache_get_entry_id(tmp);
@@ -1315,12 +1326,18 @@ static void playlist_thread(void)
/* And be on background so user doesn't notice any delays. */
yield();
}
-
+
+ if (dircache_is_enabled())
+ dircache_set_appflag(DIRCACHE_APPFLAG_PLAYLIST);
+
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
cpu_boost(false);
#endif
- dirty_pointers = false;
+ if (index == playlist->amount)
+ dirty_pointers = false;
+
break ;
+ }
#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
case SYS_USB_CONNECTED:
@@ -1349,7 +1366,7 @@ static int get_filename(struct playlist_info* playlist, int index, int seek,
buf_length = MAX_PATH+1;
#ifdef HAVE_DIRCACHE
- if (dircache_is_enabled() && playlist->filenames)
+ if (is_dircache_pointers_intact() && playlist->filenames)
{
if (playlist->filenames[index] >= 0)
{