Commit ae2d13ac authored by Max Kellermann's avatar Max Kellermann

playlist: moved stopOnError and errorCount into struct playlist

Moved the 2 remaining global variables into the playlist struct.
parent 82df4cb2
...@@ -75,8 +75,6 @@ static GRand *g_rand; ...@@ -75,8 +75,6 @@ static GRand *g_rand;
/** the global playlist object */ /** the global playlist object */
static Playlist playlist; static Playlist playlist;
unsigned playlist_max_length; unsigned playlist_max_length;
static int playlist_stopOnError;
static unsigned playlist_errorCount;
bool playlist_saveAbsolutePaths = DEFAULT_PLAYLIST_SAVE_ABSOLUTE_PATHS; bool playlist_saveAbsolutePaths = DEFAULT_PLAYLIST_SAVE_ABSOLUTE_PATHS;
...@@ -743,8 +741,8 @@ enum playlist_result playPlaylist(int song) ...@@ -743,8 +741,8 @@ enum playlist_result playPlaylist(int song)
i = playlist.current; i = playlist.current;
} }
playlist_stopOnError = false; playlist.stop_on_error = false;
playlist_errorCount = 0; playlist.error_count = 0;
playPlaylistOrderNumber(i); playPlaylistOrderNumber(i);
return PLAYLIST_RESULT_SUCCESS; return PLAYLIST_RESULT_SUCCESS;
...@@ -808,7 +806,7 @@ void nextSongInPlaylist(void) ...@@ -808,7 +806,7 @@ void nextSongInPlaylist(void)
syncPlaylistWithQueue(); syncPlaylistWithQueue();
playlist_stopOnError = 0; playlist.stop_on_error = false;
/* determine the next song from the queue's order list */ /* determine the next song from the queue's order list */
...@@ -849,13 +847,13 @@ static void playPlaylistIfPlayerStopped(void) ...@@ -849,13 +847,13 @@ static void playPlaylistIfPlayerStopped(void)
error = getPlayerError(); error = getPlayerError();
if (error == PLAYER_ERROR_NOERROR) if (error == PLAYER_ERROR_NOERROR)
playlist_errorCount = 0; playlist.error_count = 0;
else else
playlist_errorCount++; ++playlist.error_count;
if ((playlist_stopOnError && error != PLAYER_ERROR_NOERROR) || if ((playlist.stop_on_error && error != PLAYER_ERROR_NOERROR) ||
error == PLAYER_ERROR_AUDIO || error == PLAYER_ERROR_SYSTEM || error == PLAYER_ERROR_AUDIO || error == PLAYER_ERROR_SYSTEM ||
playlist_errorCount >= queue_length(&playlist.queue)) playlist.error_count >= queue_length(&playlist.queue))
/* too many errors, or critical error: stop /* too many errors, or critical error: stop
playback */ playback */
stopPlaylist(); stopPlaylist();
...@@ -1157,8 +1155,8 @@ enum playlist_result seekSongInPlaylist(unsigned song, float seek_time) ...@@ -1157,8 +1155,8 @@ enum playlist_result seekSongInPlaylist(unsigned song, float seek_time)
i = song; i = song;
clearPlayerError(); clearPlayerError();
playlist_stopOnError = 1; playlist.stop_on_error = true;
playlist_errorCount = 0; playlist.error_count = 0;
if (playlist.playing) { if (playlist.playing) {
if (playlist.queued >= 0) if (playlist.queued >= 0)
......
...@@ -56,6 +56,20 @@ typedef struct _Playlist { ...@@ -56,6 +56,20 @@ typedef struct _Playlist {
bool playing; bool playing;
/** /**
* If true, then any error is fatal; if false, MPD will
* attempt to play the next song on non-fatal errors. During
* seeking, this flag is set.
*/
bool stop_on_error;
/**
* Number of errors since playback was started. If this
* number exceeds the length of the playlist, MPD gives up,
* because all songs have been tried.
*/
unsigned error_count;
/**
* The "current song pointer". This is the song which is * The "current song pointer". This is the song which is
* played when we get the "play" command. It is also the song * played when we get the "play" command. It is also the song
* which is currently being played. * which is currently being played.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment