diff options
author | waker <wakeroid@gmail.com> | 2011-04-16 20:01:48 +0200 |
---|---|---|
committer | waker <wakeroid@gmail.com> | 2011-04-16 20:01:48 +0200 |
commit | c046fa84523315840c217b9d3bb32bc62c92b77b (patch) | |
tree | d34a0b033bda2f4ba0018b738e8bd691d290bd84 /streamer.c | |
parent | fb975043edccf8b42ade017bc9e9ce844db157df (diff) |
fixed few more possible race conditions in streamer
Diffstat (limited to 'streamer.c')
-rw-r--r-- | streamer.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -790,7 +790,9 @@ streamer_set_nextsong (int song, int pstate) { nextsong_pstate = pstate; if (output->state () == OUTPUT_STATE_STOPPED) { if (pstate == 1) { // means user initiated this + pl_lock (); streamer_playlist = plt_get_curr_ptr (); + pl_unlock (); } // no sense to wait until end of previous song, reset buffer bytes_until_next_song = 0; @@ -1842,7 +1844,9 @@ streamer_play_current_track (void) { } streamer_set_nextsong (idx, 1); + pl_lock (); streamer_playlist = plt; + pl_unlock (); } else { // restart currently playing track @@ -1858,19 +1862,25 @@ streamer_get_current_fileinfo (void) { void streamer_set_current_playlist (int plt) { + pl_lock (); streamer_playlist = plt_get (plt); + pl_unlock (); } int streamer_get_current_playlist (void) { + pl_lock (); if (!streamer_playlist) { streamer_playlist = plt_get_curr_ptr (); } - return plt_get_idx_of (streamer_playlist); + int idx = plt_get_idx_of (streamer_playlist); + pl_unlock (); + return idx; } void streamer_notify_playlist_deleted (playlist_t *plt) { + // this is only called from playlist code, no lock required if (plt == streamer_playlist) { streamer_playlist = NULL; } |