aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/player_control.c7
-rw-r--r--src/player_control.h8
-rw-r--r--src/playlist.c10
3 files changed, 23 insertions, 2 deletions
diff --git a/src/player_control.c b/src/player_control.c
index 1d5c76aa0..bc55bcff4 100644
--- a/src/player_control.c
+++ b/src/player_control.c
@@ -44,6 +44,13 @@ void pc_deinit(void)
notify_deinit(&pc.notify);
}
+void
+pc_song_deleted(const struct song *song)
+{
+ if (pc.errored_song == song)
+ pc.errored_song = NULL;
+}
+
static void player_command(enum player_command cmd)
{
pc.command = cmd;
diff --git a/src/player_control.h b/src/player_control.h
index 2ae1fb618..fa228d8b3 100644
--- a/src/player_control.h
+++ b/src/player_control.h
@@ -84,6 +84,14 @@ void pc_init(unsigned int buffered_before_play);
void pc_deinit(void);
+/**
+ * Call this function when the specified song pointer is about to be
+ * invalidated. This makes sure that player_control.errored_song does
+ * not point to an invalid pointer.
+ */
+void
+pc_song_deleted(const struct song *song);
+
void
playerPlay(struct song *song);
diff --git a/src/playlist.c b/src/playlist.c
index 8d6d246f5..ba69844de 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -200,8 +200,10 @@ void clearPlaylist(void)
stopPlaylist();
for (unsigned i = 0; i < playlist.length; i++) {
- if (!song_in_database(playlist.songs[i]))
+ if (!song_in_database(playlist.songs[i])) {
+ pc_song_deleted(playlist.songs[i]);
song_free(playlist.songs[i]);
+ }
playlist.idToPosition[playlist.positionToId[i]] = -1;
playlist.songs[i] = NULL;
@@ -670,8 +672,10 @@ enum playlist_result deleteFromPlaylist(unsigned song)
|| playlist.order[playlist.current] == song))
clearPlayerQueue();
- if (!song_in_database(playlist.songs[song]))
+ if (!song_in_database(playlist.songs[song])) {
+ pc_song_deleted(playlist.songs[song]);
song_free(playlist.songs[song]);
+ }
playlist.idToPosition[playlist.positionToId[song]] = -1;
@@ -738,6 +742,8 @@ deleteASongFromPlaylist(const struct song *song)
for (unsigned i = 0; i < playlist.length; i++)
if (song == playlist.songs[i])
deleteFromPlaylist(i);
+
+ pc_song_deleted(song);
}
void stopPlaylist(void)