diff options
| author | Lars-Dominik Braun <PromyLOPh@lavabit.com> | 2009-01-30 23:25:36 +0100 | 
|---|---|---|
| committer | Lars-Dominik Braun <PromyLOPh@lavabit.com> | 2009-01-31 11:15:48 +0100 | 
| commit | 46b59017ffcc85505cf5f8b98f2ae226121d8a16 (patch) | |
| tree | 5817bde2c50d88d008f450cb00e3eade309d0604 /src/ui_act.c | |
| parent | 62ddf6ca4e5f4a03eca660c1d1a9f78a051fd647 (diff) | |
| download | pianobar-windows-46b59017ffcc85505cf5f8b98f2ae226121d8a16.tar.gz pianobar-windows-46b59017ffcc85505cf5f8b98f2ae226121d8a16.tar.bz2 pianobar-windows-46b59017ffcc85505cf5f8b98f2ae226121d8a16.zip | |
Use pthread mutex to block player in pause state
Diffstat (limited to 'src/ui_act.c')
| -rw-r--r-- | src/ui_act.c | 28 | 
1 files changed, 20 insertions, 8 deletions
| diff --git a/src/ui_act.c b/src/ui_act.c index ae42164..5c28672 100644 --- a/src/ui_act.c +++ b/src/ui_act.c @@ -25,6 +25,7 @@ THE SOFTWARE.  #include <string.h>  #include <unistd.h> +#include <pthread.h>  /* needed by readline */  #include <stdio.h>  #include <readline/readline.h> @@ -40,6 +41,14 @@ THE SOFTWARE.  		BarUiMsg ("No song playing.\n"); \  		return; } +/*	helper to _really_ skip a song (unlock mutex, quit player) + *	@param player handle + */ +inline void BarUiDoSkipSong (struct aacPlayer *player) { +	player->doQuit = 1; +	pthread_mutex_unlock (&player->pauseMutex); +} +  /*	transform station if necessary to allow changes like rename, rate, ...   *	@param piano handle   *	@param transform this station @@ -101,7 +110,7 @@ void BarUiActBanSong (BAR_KS_ARGS) {  	BarUiMsg ("Banning song... ");  	if (BarUiPrintPianoStatus (PianoRateTrack (ph, *curSong,  			PIANO_RATE_BAN)) == PIANO_RET_OK) { -		player->doQuit = 1; +		BarUiDoSkipSong (player);  	}  } @@ -130,7 +139,7 @@ void BarUiActDeleteStation (BAR_KS_ARGS) {  		BarUiMsg ("Deleting station... ");  		if (BarUiPrintPianoStatus (PianoDeleteStation (ph,  				*curStation)) == PIANO_RET_OK) { -			player->doQuit = 1; +			BarUiDoSkipSong (player);  			PianoDestroyPlaylist (ph);  			*curSong = NULL;  			*curStation = NULL; @@ -202,7 +211,7 @@ void BarUiActLoveSong (BAR_KS_ARGS) {  /*	skip song   */  void BarUiActSkipSong (BAR_KS_ARGS) { -	player->doQuit = 1; +	BarUiDoSkipSong (player);  }  /*	move song to different station @@ -227,7 +236,7 @@ void BarUiActMoveSong (BAR_KS_ARGS) {  		}  		if (BarUiPrintPianoStatus (PianoMoveSong (ph, fromStation,  				moveStation, *curSong)) == PIANO_RET_OK) { -			player->doQuit = 1; +			BarUiDoSkipSong (player);  		}  	}  } @@ -235,7 +244,10 @@ void BarUiActMoveSong (BAR_KS_ARGS) {  /*	pause   */  void BarUiActPause (BAR_KS_ARGS) { -	player->doPause = !player->doPause; +	/* already locked => unlock/unpause */ +	if (pthread_mutex_trylock (&player->pauseMutex) == EBUSY) { +		pthread_mutex_unlock (&player->pauseMutex); +	}  }  /*	rename current station @@ -261,7 +273,7 @@ void BarUiActRenameStation (BAR_KS_ARGS) {  /*	play another station   */  void BarUiActSelectStation (BAR_KS_ARGS) { -	player->doQuit = 1; +	BarUiDoSkipSong (player);  	PianoDestroyPlaylist (ph);  	*curSong = NULL;  	*curStation = BarUiSelectStation (ph, "Select station: "); @@ -281,7 +293,7 @@ void BarUiActTempBanSong (BAR_KS_ARGS) {  	BarUiMsg ("Putting song on shelf... ");  	if (BarUiPrintPianoStatus (PianoSongTired (ph, *curSong)) ==  			PIANO_RET_OK) { -		player->doQuit = 1; +		BarUiDoSkipSong (player);  	}  } @@ -328,5 +340,5 @@ void BarUiActSelectQuickMix (BAR_KS_ARGS) {   */  void BarUiActQuit (BAR_KS_ARGS) {  	*doQuit = 1; -	player->doQuit = 1; +	BarUiDoSkipSong (player);  } | 
