summaryrefslogtreecommitdiff
path: root/src/ui_act.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui_act.c')
-rw-r--r--src/ui_act.c36
1 files changed, 27 insertions, 9 deletions
diff --git a/src/ui_act.c b/src/ui_act.c
index 70fbc9a..8d9ac09 100644
--- a/src/ui_act.c
+++ b/src/ui_act.c
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2008-2012
+Copyright (c) 2008-2013
Lars-Dominik Braun <lars@6xq.net>
Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -49,9 +49,9 @@ THE SOFTWARE.
static inline void BarUiDoSkipSong (struct audioPlayer *player) {
assert (player != NULL);
- player->doQuit = 1;
- /* unlocking an unlocked mutex is forbidden by some implementations */
- pthread_mutex_trylock (&player->pauseMutex);
+ pthread_mutex_lock (&player->pauseMutex);
+ player->doQuit = true;
+ pthread_cond_broadcast (&player->pauseCond);
pthread_mutex_unlock (&player->pauseMutex);
}
@@ -335,13 +335,31 @@ BarUiActCallback(BarUiActSkipSong) {
BarUiDoSkipSong (&app->player);
}
+/* play
+ */
+BarUiActCallback(BarUiActPlay) {
+ pthread_mutex_lock (&app->player.pauseMutex);
+ app->player.doPause = false;
+ pthread_cond_broadcast (&app->player.pauseCond);
+ pthread_mutex_unlock (&app->player.pauseMutex);
+}
+
/* pause
*/
BarUiActCallback(BarUiActPause) {
- /* already locked => unlock/unpause */
- if (pthread_mutex_trylock (&app->player.pauseMutex) == EBUSY) {
- pthread_mutex_unlock (&app->player.pauseMutex);
- }
+ pthread_mutex_lock (&app->player.pauseMutex);
+ app->player.doPause = true;
+ pthread_cond_broadcast (&app->player.pauseCond);
+ pthread_mutex_unlock (&app->player.pauseMutex);
+}
+
+/* toggle pause
+ */
+BarUiActCallback(BarUiActTogglePause) {
+ pthread_mutex_lock (&app->player.pauseMutex);
+ app->player.doPause = !app->player.doPause;
+ pthread_cond_broadcast (&app->player.pauseCond);
+ pthread_mutex_unlock (&app->player.pauseMutex);
}
/* rename current station
@@ -483,7 +501,7 @@ BarUiActCallback(BarUiActSelectQuickMix) {
/* quit
*/
BarUiActCallback(BarUiActQuit) {
- app->doQuit = 1;
+ app->doQuit = true;
BarUiDoSkipSong (&app->player);
}