aboutsummaryrefslogtreecommitdiffstats
path: root/src/player_control.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2012-08-09 22:19:39 +0200
committerMax Kellermann <max@duempel.org>2012-08-15 23:09:22 +0200
commite96779de48be1f1b0080a8e1cfa89756c40e562d (patch)
tree58a329d5e1719733019cef09bbbc6f6c0ae8f579 /src/player_control.c
parenteb54337c40cbedc79177b48d2feaea9d12e95c0f (diff)
downloadmpd-e96779de48be1f1b0080a8e1cfa89756c40e562d.tar.gz
mpd-e96779de48be1f1b0080a8e1cfa89756c40e562d.tar.xz
mpd-e96779de48be1f1b0080a8e1cfa89756c40e562d.zip
player_control: duplicate the song object
Make sure the player "owns" the next_song object, so nobody else can free it.
Diffstat (limited to '')
-rw-r--r--src/player_control.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/player_control.c b/src/player_control.c
index 69357bf26..28134ccdc 100644
--- a/src/player_control.c
+++ b/src/player_control.c
@@ -59,6 +59,9 @@ pc_new(unsigned buffer_chunks, unsigned int buffered_before_play)
void
pc_free(struct player_control *pc)
{
+ if (pc->next_song != NULL)
+ song_free(pc->next_song);
+
g_cond_free(pc->cond);
g_mutex_free(pc->mutex);
g_free(pc);
@@ -284,6 +287,10 @@ pc_seek(struct player_control *pc, struct song *song, float seek_time)
assert(song != NULL);
player_lock(pc);
+
+ if (pc->next_song != NULL)
+ song_free(pc->next_song);
+
pc->next_song = song;
pc->seek_where = seek_time;
player_command_locked(pc, PLAYER_COMMAND_SEEK);