aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/player.c23
-rw-r--r--src/player.h3
-rw-r--r--src/playerData.c1
-rw-r--r--src/playlist.c5
4 files changed, 29 insertions, 3 deletions
diff --git a/src/player.c b/src/player.c
index 4870dc73..e2dc2106 100644
--- a/src/player.c
+++ b/src/player.c
@@ -155,6 +155,9 @@ int playerInit(void)
} else if (pc->cycleLogFiles) {
cycle_log_files();
pc->cycleLogFiles = 0;
+ } else if (pc->quit) {
+ pc->quit = 0;
+ break;
} else
my_usleep(10000);
}
@@ -174,6 +177,24 @@ int playerInit(void)
return 0;
}
+int playerQuit(int fd)
+{
+ PlayerControl *pc = &(getPlayerData()->playerControl);
+
+ if (playerStop(fd) < 0)
+ return -1;
+
+ playerCloseAudio();
+
+ if (player_pid > 0) {
+ pc->quit = 1;
+ while (player_pid > 0 && pc->quit)
+ my_usleep(1000);
+ }
+
+ return 0;
+}
+
int playerPlay(int fd, Song * song)
{
PlayerControl *pc = &(getPlayerData()->playerControl);
@@ -341,6 +362,8 @@ void playerCloseAudio(void)
if (playerStop(STDERR_FILENO) < 0)
return;
pc->closeAudio = 1;
+ while (player_pid > 0 && pc->closeAudio)
+ my_usleep(1000);
}
}
diff --git a/src/player.h b/src/player.h
index b62fab2e..ce7eebc9 100644
--- a/src/player.h
+++ b/src/player.h
@@ -57,6 +57,7 @@
#define PLAYER_METADATA_STATE_WRITE 2
typedef struct _PlayerControl {
+ volatile mpd_sint8 quit;
volatile mpd_sint8 stop;
volatile mpd_sint8 play;
volatile mpd_sint8 pause;
@@ -121,6 +122,8 @@ int getPlayerError(void);
int playerInit(void);
+int playerQuit(int fd);
+
int queueSong(Song * song);
int getPlayerQueueState(void);
diff --git a/src/playerData.c b/src/playerData.c
index 30ff6d6d..e4506c1e 100644
--- a/src/playerData.c
+++ b/src/playerData.c
@@ -118,6 +118,7 @@ void initPlayerData(void)
buffered_chunks * sizeof(mpd_sint8));
buffer->acceptMetadata = 0;
+ playerData_pd->playerControl.quit = 0;
playerData_pd->playerControl.stop = 0;
playerData_pd->playerControl.pause = 0;
playerData_pd->playerControl.play = 0;
diff --git a/src/playlist.c b/src/playlist.c
index de5a2a3d..d68033e1 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -786,7 +786,7 @@ int deleteFromPlaylist(int fd, int song)
&& playlist.current == songOrder) {
/*if(playlist.current>=playlist.length) return playerStop(fd);
else return playPlaylistOrderNumber(fd,playlist.current); */
- playerStop(STDERR_FILENO);
+ playerQuit(STDERR_FILENO);
playlist_noGoToNext = 1;
}
@@ -827,9 +827,8 @@ void deleteASongFromPlaylist(Song * song)
int stopPlaylist(int fd)
{
DEBUG("playlist: stop\n");
- if (playerStop(fd) < 0)
+ if (playerQuit(fd) < 0)
return -1;
- playerCloseAudio();
playlist.queued = -1;
playlist_state = PLAYLIST_STATE_STOP;
playlist_noGoToNext = 0;