diff options
| author | Lars-Dominik Braun <PromyLOPh@lavabit.com> | 2009-11-11 19:50:04 +0100 | 
|---|---|---|
| committer | Lars-Dominik Braun <PromyLOPh@lavabit.com> | 2009-11-11 19:50:04 +0100 | 
| commit | 7d2fa5b1bcce7351b81b2d0d927e61035c2224d9 (patch) | |
| tree | 7b41294b368875b88c93896ca817f321f92f1158 /src | |
| parent | b7986539c350f5de1077dd27eeffaa4c11a476f7 (diff) | |
| download | pianobar-7d2fa5b1bcce7351b81b2d0d927e61035c2224d9.tar.gz pianobar-7d2fa5b1bcce7351b81b2d0d927e61035c2224d9.tar.bz2 pianobar-7d2fa5b1bcce7351b81b2d0d927e61035c2224d9.zip | |
Print message and stop playback when hitting libao error
Thanks to jpfuentes2@github
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.c | 7 | ||||
| -rw-r--r-- | src/player.c | 22 | 
2 files changed, 23 insertions, 6 deletions
| @@ -189,7 +189,12 @@ int main (int argc, char **argv) {  			WardrobeSongDestroy (&scrobbleSong);  			/* FIXME: pthread_join blocks everything if network connection  			 * is hung up e.g. */ -			pthread_join (playerThread, NULL); +			void *threadRet; +			pthread_join (playerThread, &threadRet); +			/* don't continue playback if thread reports error */ +			if (threadRet != NULL) { +				curStation = NULL; +			}  			memset (&player, 0, sizeof (player));  		} diff --git a/src/player.c b/src/player.c index bb65ee0..ef3cd19 100644 --- a/src/player.c +++ b/src/player.c @@ -197,8 +197,11 @@ static char BarPlayerAACCb (void *ptr, size_t size, void *stream) {  					format.channels = player->channels;  					format.rate = player->samplerate;  					format.byte_format = AO_FMT_LITTLE; -					player->audioOutDevice = ao_open_live (audioOutDriver, -							&format, NULL); +					if ((player->audioOutDevice = ao_open_live (audioOutDriver, +							&format, NULL)) == NULL) { +						BarUiMsg (MSG_ERR, "Cannot open audio device\n"); +						return 0; +					}  					player->mode = PLAYER_AUDIO_INITIALIZED;  					break;  				} @@ -351,8 +354,11 @@ static char BarPlayerMp3Cb (void *ptr, size_t size, void *stream) {  			format.channels = player->channels;  			format.rate = player->samplerate;  			format.byte_format = AO_FMT_LITTLE; -			player->audioOutDevice = ao_open_live (audioOutDriver, -					&format, NULL); +			if ((player->audioOutDevice = ao_open_live (audioOutDriver, +					&format, NULL)) == NULL) { +				BarUiMsg (MSG_ERR, "Cannot open audio device\n"); +				return 0; +			}  			/* calc song length using the framerate of the first decoded frame */  			player->songDuration = (float) player->waith.contentLength / @@ -394,6 +400,7 @@ static char BarPlayerMp3Cb (void *ptr, size_t size, void *stream) {  void *BarPlayerThread (void *data) {  	struct audioPlayer *player = data;  	char extraHeaders[25]; +	void *ret = NULL;  	#ifdef ENABLE_FAAD  	NeAACDecConfigurationPtr conf;  	#endif @@ -468,6 +475,9 @@ void *BarPlayerThread (void *data) {  			/* this should never happen: thread is aborted above */  			break;  	} +	if (player->audioOutDevice == NULL && wRet == WAITRESS_RET_CB_ABORT) { +		ret = (void *) 0x1; +	}  	ao_close(player->audioOutDevice);  	WaitressFree (&player->waith);  	#ifdef ENABLE_FAAD @@ -479,5 +489,7 @@ void *BarPlayerThread (void *data) {  	player->mode = PLAYER_FINISHED_PLAYBACK; -	return NULL; +	/* return NULL == everything's fine, everything else: hard error, stop +	 * playback */ +	return ret;  } | 
