summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHardeep Sidhu <dyp@pobox.com>2005-07-08 00:52:54 +0000
committerHardeep Sidhu <dyp@pobox.com>2005-07-08 00:52:54 +0000
commit348d8f6bab492f46235d10eb905f724770c2f763 (patch)
tree2fde5d934810b73238bf33817fb0cdfa9a85209d
parenta6abe760a9c34893135b6d5a46cfb82623e881fb (diff)
downloadrockbox-348d8f6bab492f46235d10eb905f724770c2f763.tar.gz
rockbox-348d8f6bab492f46235d10eb905f724770c2f763.tar.bz2
rockbox-348d8f6bab492f46235d10eb905f724770c2f763.zip
A couple of bug fixes: 1. Take mutex before all playlist control file operations including fsync. 2. Don't flush and reload tracks if nothing is playing.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7060 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/playlist.c38
1 files changed, 29 insertions, 9 deletions
diff --git a/apps/playlist.c b/apps/playlist.c
index 91ca1f640a..9a22addbc3 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -651,7 +651,8 @@ static int add_directory_to_playlist(struct playlist_info* playlist,
{
display_playlist_count(*count, count_str);
- if (*count == PLAYLIST_DISPLAY_COUNT)
+ if (*count == PLAYLIST_DISPLAY_COUNT &&
+ (audio_status() & AUDIO_STATUS_PLAY))
audio_flush_and_reload_tracks();
}
@@ -2196,8 +2197,12 @@ int playlist_insert_track(struct playlist_info* playlist,
if (result != -1)
{
+ mutex_lock(&playlist->control_mutex);
fsync(playlist->control_fd);
- audio_flush_and_reload_tracks();
+ mutex_unlock(&playlist->control_mutex);
+
+ if (audio_status() & AUDIO_STATUS_PLAY)
+ audio_flush_and_reload_tracks();
}
return result;
@@ -2232,10 +2237,15 @@ int playlist_insert_directory(struct playlist_info* playlist,
result = add_directory_to_playlist(playlist, dirname, &position, queue,
&count, recurse);
+
+ mutex_lock(&playlist->control_mutex);
fsync(playlist->control_fd);
+ mutex_unlock(&playlist->control_mutex);
display_playlist_count(count, count_str);
- audio_flush_and_reload_tracks();
+
+ if (audio_status() & AUDIO_STATUS_PLAY)
+ audio_flush_and_reload_tracks();
return result;
}
@@ -2327,7 +2337,8 @@ int playlist_insert_playlist(struct playlist_info* playlist, char *filename,
{
display_playlist_count(count, count_str);
- if (count == PLAYLIST_DISPLAY_COUNT)
+ if (count == PLAYLIST_DISPLAY_COUNT &&
+ (audio_status() & AUDIO_STATUS_PLAY))
audio_flush_and_reload_tracks();
}
}
@@ -2337,13 +2348,18 @@ int playlist_insert_playlist(struct playlist_info* playlist, char *filename,
}
close(fd);
+
+ mutex_lock(&playlist->control_mutex);
fsync(playlist->control_fd);
+ mutex_unlock(&playlist->control_mutex);
if (temp_ptr)
*temp_ptr = '/';
display_playlist_count(count, count_str);
- audio_flush_and_reload_tracks();
+
+ if (audio_status() & AUDIO_STATUS_PLAY)
+ audio_flush_and_reload_tracks();
return result;
}
@@ -2370,7 +2386,7 @@ int playlist_delete(struct playlist_info* playlist, int index)
result = remove_track_from_playlist(playlist, index, true);
- if (result != -1)
+ if (result != -1 && (audio_status() & AUDIO_STATUS_PLAY))
audio_flush_and_reload_tracks();
return result;
@@ -2458,8 +2474,12 @@ int playlist_move(struct playlist_info* playlist, int index, int new_index)
}
}
+ mutex_lock(&playlist->control_mutex);
fsync(playlist->control_fd);
- audio_flush_and_reload_tracks();
+ mutex_unlock(&playlist->control_mutex);
+
+ if (audio_status() & AUDIO_STATUS_PLAY)
+ audio_flush_and_reload_tracks();
}
}
@@ -2479,7 +2499,7 @@ int playlist_randomise(struct playlist_info* playlist, unsigned int seed,
result = randomise_playlist(playlist, seed, start_current, true);
- if (result != -1)
+ if (result != -1 && (audio_status() & AUDIO_STATUS_PLAY))
audio_flush_and_reload_tracks();
return result;
@@ -2497,7 +2517,7 @@ int playlist_sort(struct playlist_info* playlist, bool start_current)
result = sort_playlist(playlist, start_current, true);
- if (result != -1)
+ if (result != -1 && (audio_status() & AUDIO_STATUS_PLAY))
audio_flush_and_reload_tracks();
return result;