added clearPlayerQueueLocked()
since clearPlayerQueue() is always called within lockPlaylistInteraction() / unlockPlaylistInteraction(), it simplifies the code to add another function which calls these three functions. git-svn-id: https://svn.musicpd.org/mpd/trunk@7253 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:

committed by
Eric Wong

parent
7aa78d9b4a
commit
82fbf1a24c
@@ -566,6 +566,13 @@ static void clearPlayerQueue(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void clearPlayerQueueLocked(void)
|
||||||
|
{
|
||||||
|
lockPlaylistInteraction();
|
||||||
|
clearPlayerQueue();
|
||||||
|
unlockPlaylistInteraction();
|
||||||
|
}
|
||||||
|
|
||||||
int addToPlaylist(int fd, char *url, int *added_id)
|
int addToPlaylist(int fd, char *url, int *added_id)
|
||||||
{
|
{
|
||||||
Song *song;
|
Song *song;
|
||||||
@@ -624,11 +631,8 @@ int addSongToPlaylist(int fd, Song * song, int *added_id)
|
|||||||
|
|
||||||
if (playlist_state == PLAYLIST_STATE_PLAY) {
|
if (playlist_state == PLAYLIST_STATE_PLAY) {
|
||||||
if (playlist.queued >= 0
|
if (playlist.queued >= 0
|
||||||
&& playlist.current == playlist.length - 1) {
|
&& playlist.current == playlist.length - 1)
|
||||||
lockPlaylistInteraction();
|
clearPlayerQueueLocked();
|
||||||
clearPlayerQueue();
|
|
||||||
unlockPlaylistInteraction();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
id = getNextId();
|
id = getNextId();
|
||||||
@@ -687,11 +691,8 @@ int swapSongsInPlaylist(int fd, int song1, int song2)
|
|||||||
currentSong = playlist.order[playlist.current];
|
currentSong = playlist.order[playlist.current];
|
||||||
|
|
||||||
if (queuedSong == song1 || queuedSong == song2
|
if (queuedSong == song1 || queuedSong == song2
|
||||||
|| currentSong == song1 || currentSong == song2) {
|
|| currentSong == song1 || currentSong == song2)
|
||||||
lockPlaylistInteraction();
|
clearPlayerQueueLocked();
|
||||||
clearPlayerQueue();
|
|
||||||
unlockPlaylistInteraction();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
swapSongs(song1, song2);
|
swapSongs(song1, song2);
|
||||||
@@ -750,11 +751,8 @@ int deleteFromPlaylist(int fd, int song)
|
|||||||
if (playlist_state == PLAYLIST_STATE_PLAY) {
|
if (playlist_state == PLAYLIST_STATE_PLAY) {
|
||||||
if (playlist.queued >= 0
|
if (playlist.queued >= 0
|
||||||
&& (playlist.order[playlist.queued] == song
|
&& (playlist.order[playlist.queued] == song
|
||||||
|| playlist.order[playlist.current] == song)) {
|
|| playlist.order[playlist.current] == song))
|
||||||
lockPlaylistInteraction();
|
clearPlayerQueueLocked();
|
||||||
clearPlayerQueue();
|
|
||||||
unlockPlaylistInteraction();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playlist.songs[song]->type == SONG_TYPE_URL) {
|
if (playlist.songs[song]->type == SONG_TYPE_URL) {
|
||||||
@@ -1040,11 +1038,8 @@ int setPlaylistRepeatStatus(int fd, int status)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (playlist_state == PLAYLIST_STATE_PLAY) {
|
if (playlist_state == PLAYLIST_STATE_PLAY) {
|
||||||
if (playlist.repeat && !status && playlist.queued == 0) {
|
if (playlist.repeat && !status && playlist.queued == 0)
|
||||||
lockPlaylistInteraction();
|
clearPlayerQueueLocked();
|
||||||
clearPlayerQueue();
|
|
||||||
unlockPlaylistInteraction();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
playlist.repeat = status;
|
playlist.repeat = status;
|
||||||
@@ -1093,11 +1088,8 @@ int moveSongInPlaylist(int fd, int from, int to)
|
|||||||
if (playlist.queued >= 0)
|
if (playlist.queued >= 0)
|
||||||
queuedSong = playlist.order[playlist.queued];
|
queuedSong = playlist.order[playlist.queued];
|
||||||
if (queuedSong == from || queuedSong == to
|
if (queuedSong == from || queuedSong == to
|
||||||
|| currentSong == from || currentSong == to) {
|
|| currentSong == from || currentSong == to)
|
||||||
lockPlaylistInteraction();
|
clearPlayerQueueLocked();
|
||||||
clearPlayerQueue();
|
|
||||||
unlockPlaylistInteraction();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpSong = playlist.songs[from];
|
tmpSong = playlist.songs[from];
|
||||||
@@ -1170,11 +1162,8 @@ static void orderPlaylist(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (playlist_state == PLAYLIST_STATE_PLAY) {
|
if (playlist_state == PLAYLIST_STATE_PLAY) {
|
||||||
if (playlist.queued >= 0) {
|
if (playlist.queued >= 0)
|
||||||
lockPlaylistInteraction();
|
clearPlayerQueueLocked();
|
||||||
clearPlayerQueue();
|
|
||||||
unlockPlaylistInteraction();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < playlist.length; i++) {
|
for (i = 0; i < playlist.length; i++) {
|
||||||
@@ -1198,11 +1187,8 @@ static void randomizeOrder(int start, int end)
|
|||||||
DEBUG("playlist: randomize from %i to %i\n", start, end);
|
DEBUG("playlist: randomize from %i to %i\n", start, end);
|
||||||
|
|
||||||
if (playlist_state == PLAYLIST_STATE_PLAY) {
|
if (playlist_state == PLAYLIST_STATE_PLAY) {
|
||||||
if (playlist.queued >= start && playlist.queued <= end) {
|
if (playlist.queued >= start && playlist.queued <= end)
|
||||||
lockPlaylistInteraction();
|
clearPlayerQueueLocked();
|
||||||
clearPlayerQueue();
|
|
||||||
unlockPlaylistInteraction();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = start; i <= end; i++) {
|
for (i = start; i <= end; i++) {
|
||||||
@@ -1278,9 +1264,7 @@ int shufflePlaylist(int fd)
|
|||||||
|
|
||||||
if (playlist.length > 1) {
|
if (playlist.length > 1) {
|
||||||
if (playlist_state == PLAYLIST_STATE_PLAY) {
|
if (playlist_state == PLAYLIST_STATE_PLAY) {
|
||||||
lockPlaylistInteraction();
|
clearPlayerQueueLocked();
|
||||||
clearPlayerQueue();
|
|
||||||
unlockPlaylistInteraction();
|
|
||||||
/* put current playing song first */
|
/* put current playing song first */
|
||||||
swapSongs(0, playlist.order[playlist.current]);
|
swapSongs(0, playlist.order[playlist.current]);
|
||||||
if (playlist.random) {
|
if (playlist.random) {
|
||||||
@@ -1406,11 +1390,8 @@ int seekSongInPlaylist(int fd, int song, float seek_time)
|
|||||||
playlist_errorCount = 0;
|
playlist_errorCount = 0;
|
||||||
|
|
||||||
if (playlist_state == PLAYLIST_STATE_PLAY) {
|
if (playlist_state == PLAYLIST_STATE_PLAY) {
|
||||||
if (playlist.queued >= 0) {
|
if (playlist.queued >= 0)
|
||||||
lockPlaylistInteraction();
|
clearPlayerQueueLocked();
|
||||||
clearPlayerQueue();
|
|
||||||
unlockPlaylistInteraction();
|
|
||||||
}
|
|
||||||
} else if (playPlaylistOrderNumber(fd, i) < 0)
|
} else if (playPlaylistOrderNumber(fd, i) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user