From bdf53282f3f2a20ff1b112469e1c1266a0563d11 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Tue, 9 Sep 2008 12:17:25 +0200 Subject: Pause song faster --- src/player.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'src/player.c') diff --git a/src/player.c b/src/player.c index 86c9b70..b009b4f 100644 --- a/src/player.c +++ b/src/player.c @@ -31,6 +31,20 @@ THE SOFTWARE. #include "player.h" #include "config.h" +/* FIXME: not the best solution to poll every second, but the easiest + * one I know... (pthread's conditions could be another solution) */ +#define QUIT_PAUSE_CHECK \ + if (player->doQuit) { \ + return 0; \ + } \ + if (player->doPause) { \ + curl_easy_pause (player->audioFd, CURLPAUSE_ALL); \ + while (player->doPause && !player->doQuit) { \ + sleep (1); \ + } \ + curl_easy_pause (player->audioFd, CURLPAUSE_CONT); \ + } + /* compute replaygain scale factor * algo taken from here: http://www.dsprelated.com/showmessage/29246/1.php * mpd does the same @@ -52,19 +66,7 @@ size_t BarPlayerCurlCb (void *ptr, size_t size, size_t nmemb, void *stream) { char *data = ptr; struct aacPlayer *player = stream; - if (player->doQuit) { - return 0; - } - - /* FIXME: not the best solution to poll every second, but the easiest - * one I know... (pthread's conditions could be another solution) */ - if (player->doPause) { - curl_easy_pause (player->audioFd, CURLPAUSE_ALL); - while (player->doPause && !player->doQuit) { - sleep (1); - } - curl_easy_pause (player->audioFd, CURLPAUSE_CONT); - } + QUIT_PAUSE_CHECK; /* fill buffer */ if (player->bufferFilled + size*nmemb > sizeof (player->buffer)) { @@ -110,9 +112,7 @@ size_t BarPlayerCurlCb (void *ptr, size_t size, size_t nmemb, void *stream) { player->sampleSizeCurr++; /* going through this loop can take up to a few seconds => * allow earlier thread abort */ - if (player->doQuit) { - return 0; - } + QUIT_PAUSE_CHECK; } } else { if (player->mode == PLAYER_INITIALIZED) { -- cgit v1.2.3