summaryrefslogtreecommitdiff
path: root/src/ui_act.c
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2012-05-26 15:06:05 +0200
committerLars-Dominik Braun <lars@6xq.net>2012-05-26 15:10:54 +0200
commit2c5bcc5ee10d6e982daa6660ba1925b3d95a2922 (patch)
tree5f8879251782e52d40a33a31da158f8a640f2cb2 /src/ui_act.c
parentf54c15c8b1b88c9689cadf9a9bc43a5f735f4b8e (diff)
downloadpianobar-windows-2c5bcc5ee10d6e982daa6660ba1925b3d95a2922.tar.gz
pianobar-windows-2c5bcc5ee10d6e982daa6660ba1925b3d95a2922.tar.bz2
pianobar-windows-2c5bcc5ee10d6e982daa6660ba1925b3d95a2922.zip
Revert "Remove pause mutex/add pthread cleanup function"
This reverts commit 7df9371491e96a99c1e463f7787aede352ac5a37.
Diffstat (limited to 'src/ui_act.c')
-rw-r--r--src/ui_act.c25
1 files changed, 9 insertions, 16 deletions
diff --git a/src/ui_act.c b/src/ui_act.c
index 2cc3197..0c9ed1b 100644
--- a/src/ui_act.c
+++ b/src/ui_act.c
@@ -23,14 +23,10 @@ THE SOFTWARE.
/* functions responding to user's keystrokes */
-#ifndef __FreeBSD__
-#define _POSIX_C_SOURCE 200112L /* pthread_kill() */
-#endif
-
#include <string.h>
#include <unistd.h>
+#include <pthread.h>
#include <assert.h>
-#include <signal.h>
#include "ui.h"
#include "ui_readline.h"
@@ -53,9 +49,10 @@ THE SOFTWARE.
static inline void BarUiDoSkipSong (struct audioPlayer *player) {
assert (player != NULL);
- if (player->mode != PLAYER_FINISHED_PLAYBACK && player->mode != PLAYER_FREED) {
- pthread_cancel (player->thread);
- }
+ player->doQuit = 1;
+ /* unlocking an unlocked mutex is forbidden by some implementations */
+ pthread_mutex_trylock (&player->pauseMutex);
+ pthread_mutex_unlock (&player->pauseMutex);
}
/* transform station if necessary to allow changes like rename, rate, ...
@@ -347,12 +344,9 @@ BarUiActCallback(BarUiActMoveSong) {
/* pause
*/
BarUiActCallback(BarUiActPause) {
- if (app->player.paused) {
- pthread_kill (app->player.thread, BAR_PLAYER_SIGCONT);
- app->player.paused = false;
- } else {
- pthread_kill (app->player.thread, BAR_PLAYER_SIGSTOP);
- app->player.paused = true;
+ /* already locked => unlock/unpause */
+ if (pthread_mutex_trylock (&app->player.pauseMutex) == EBUSY) {
+ pthread_mutex_unlock (&app->player.pauseMutex);
}
}
@@ -495,9 +489,8 @@ BarUiActCallback(BarUiActSelectQuickMix) {
/* quit
*/
BarUiActCallback(BarUiActQuit) {
- /* cancels player thread */
- BarUiDoSkipSong (&app->player);
app->doQuit = 1;
+ BarUiDoSkipSong (&app->player);
}
/* song history