summaryrefslogtreecommitdiff
path: root/src/player.c
diff options
context:
space:
mode:
authorLars-Dominik Braun <PromyLOPh@lavabit.com>2008-09-09 12:17:25 +0200
committerLars-Dominik Braun <PromyLOPh@lavabit.com>2008-09-09 12:17:52 +0200
commitbdf53282f3f2a20ff1b112469e1c1266a0563d11 (patch)
treeb882b2ce889f5265ef5f0fa0142e3e1630afe198 /src/player.c
parentb909f85258016f013d11589de4bc829e77ae2db1 (diff)
downloadpianobar-windows-bdf53282f3f2a20ff1b112469e1c1266a0563d11.tar.gz
pianobar-windows-bdf53282f3f2a20ff1b112469e1c1266a0563d11.tar.bz2
pianobar-windows-bdf53282f3f2a20ff1b112469e1c1266a0563d11.zip
Pause song faster
Diffstat (limited to 'src/player.c')
-rw-r--r--src/player.c32
1 files changed, 16 insertions, 16 deletions
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) {