summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2011-05-16 20:23:03 +0200
committerGravatar waker <wakeroid@gmail.com>2011-05-16 20:23:03 +0200
commitaf22ddf012fee8540c81b81a8b4957af6a941c2c (patch)
tree86c9ca479bd0e4879c4de36f3652e7ce821f0c74
parent9f1e7425b79a295da9263ebb1ea1aac7e9052f1e (diff)
call streamer_notify_playlist_deleted from plt_remove, instead of plt_free
-rw-r--r--playlist.c3
-rw-r--r--streamer.c25
2 files changed, 13 insertions, 15 deletions
diff --git a/playlist.c b/playlist.c
index 3ec33ad9..af978032 100644
--- a/playlist.c
+++ b/playlist.c
@@ -274,6 +274,7 @@ plt_ref (playlist_t *plt) {
void
plt_unref (playlist_t *plt) {
LOCK;
+ assert (plt->refc > 0);
plt->refc--;
if (plt->refc < 0) {
trace ("\033[0;31mplaylist: bad refcount on playlist %p (%s)\033[37;0m\n", plt, plt->title);
@@ -410,6 +411,7 @@ plt_remove (int plt) {
prev = p;
p = p->next;
}
+ streamer_notify_playlist_deleted (p);
if (!plt_loading) {
// move files (will decrease number of files by 1)
for (int i = plt+1; i < playlists_count; i++) {
@@ -603,7 +605,6 @@ plt_get_modification_idx (playlist_t *plt) {
void
plt_free (playlist_t *plt) {
LOCK;
- streamer_notify_playlist_deleted (plt);
plt_clear (plt);
free (plt->title);
diff --git a/streamer.c b/streamer.c
index fb1798da..1d9d33a6 100644
--- a/streamer.c
+++ b/streamer.c
@@ -327,12 +327,13 @@ streamer_move_to_nextsong (int reason) {
}
else {
trace ("%s not found in current streaming playlist\n", pl_find_meta (it, ":URI"));
- // find playlist
- playlist_t *old = streamer_playlist;
- streamer_playlist = plt_get_list ();
- int i = 0;
- while (streamer_playlist) {
- trace ("searching for %s in playlist %d\n", pl_find_meta (it, ":URI"), i);
+
+ playlist_t *p = pl_get_playlist (it);
+ if (p) {
+ if (streamer_playlist) {
+ plt_unref (streamer_playlist);
+ }
+ streamer_playlist = p;
int r = str_get_idx_of (it);
if (r >= 0) {
trace ("%s found in playlist %d\n", pl_find_meta (it, ":URI"), i);
@@ -341,11 +342,8 @@ streamer_move_to_nextsong (int reason) {
streamer_set_nextsong (r, 3);
return 0;
}
- i++;
- streamer_playlist = streamer_playlist->next;
}
trace ("%s not found in any playlists\n", pl_find_meta (it, ":URI"));
- streamer_playlist = old;
pl_item_unref (it);
}
}
@@ -355,7 +353,6 @@ streamer_move_to_nextsong (int reason) {
if (reason == 1) {
if (streamer_playlist) {
plt_unref (streamer_playlist);
- streamer_playlist = NULL;
}
streamer_playlist = plt_get_curr ();
// check if prev song is in this playlist
@@ -501,7 +498,6 @@ streamer_move_to_prevsong (void) {
pl_lock ();
if (streamer_playlist) {
plt_unref (streamer_playlist);
- streamer_playlist = NULL;
}
streamer_playlist = plt_get_curr ();
// check if prev song is in this playlist
@@ -880,7 +876,6 @@ streamer_set_nextsong (int song, int pstate) {
pl_lock ();
if (streamer_playlist) {
plt_unref (streamer_playlist);
- streamer_playlist = NULL;
}
streamer_playlist = plt_get_curr ();
pl_unlock ();
@@ -1945,9 +1940,12 @@ streamer_play_current_track (void) {
streamer_set_nextsong (idx, 1);
pl_lock ();
+ if (streamer_playlist) {
+ plt_unref (streamer_playlist);
+ }
streamer_playlist = plt;
- plt_ref (plt);
pl_unlock ();
+ return;
}
else {
// restart currently playing track
@@ -1969,7 +1967,6 @@ streamer_set_current_playlist (int plt) {
pl_lock ();
if (streamer_playlist) {
plt_unref (streamer_playlist);
- streamer_playlist = NULL;
}
streamer_playlist = plt_get_for_idx (plt);
pl_unlock ();