summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorLars-Dominik Braun <PromyLOPh@gmail.com>2008-06-20 21:10:05 +0200
committerLars-Dominik Braun <PromyLOPh@gmail.com>2008-06-20 21:10:05 +0200
commitad3519948af6964d1545252caca9e78c3928bbf8 (patch)
tree5a0bcc2f39b51cb75ca6355bad5736f16647f434 /src/main.c
parentb0b3178a80ba0d32cf9c4e9692ee004ea929c3ed (diff)
downloadpianobar-ad3519948af6964d1545252caca9e78c3928bbf8.tar.gz
pianobar-ad3519948af6964d1545252caca9e78c3928bbf8.tar.bz2
pianobar-ad3519948af6964d1545252caca9e78c3928bbf8.zip
client: Pause implemented
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/src/main.c b/src/main.c
index 5a6aaaa..26ff6e8 100644
--- a/src/main.c
+++ b/src/main.c
@@ -55,6 +55,8 @@ struct aacPlayer {
char *url;
char finishedPlayback;
char doQuit;
+ char doPause;
+ CURL *audioFd;
};
void dumpBuffer (char *buf, size_t len) {
@@ -74,6 +76,16 @@ size_t playCurlCb (void *ptr, size_t size, size_t nmemb, void *stream) {
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 == 1) {
+ curl_easy_pause (player->audioFd, CURLPAUSE_ALL);
+ while (player->doPause == 1) {
+ sleep (1);
+ }
+ curl_easy_pause (player->audioFd, CURLPAUSE_CONT);
+ }
+
/* fill buffer */
if (player->bufferFilled + size*nmemb > sizeof (player->buffer)) {
printf ("Buffer overflow!\n");
@@ -171,9 +183,8 @@ size_t playCurlCb (void *ptr, size_t size, size_t nmemb, void *stream) {
void *threadPlayUrl (void *data) {
struct aacPlayer *player = data;
NeAACDecConfigurationPtr conf;
- CURL *audioFd;
- audioFd = curl_easy_init ();
+ player->audioFd = curl_easy_init ();
player->aacHandle = NeAACDecOpen();
conf = NeAACDecGetCurrentConfiguration(player->aacHandle);
@@ -181,15 +192,15 @@ void *threadPlayUrl (void *data) {
conf->downMatrix = 1;
NeAACDecSetConfiguration(player->aacHandle, conf);
- curl_easy_setopt (audioFd, CURLOPT_URL, player->url);
- curl_easy_setopt (audioFd, CURLOPT_WRITEFUNCTION, playCurlCb);
- curl_easy_setopt (audioFd, CURLOPT_WRITEDATA, player);
- curl_easy_setopt (audioFd, CURLOPT_USERAGENT, PACKAGE_STRING);
- curl_easy_perform (audioFd);
+ curl_easy_setopt (player->audioFd, CURLOPT_URL, player->url);
+ curl_easy_setopt (player->audioFd, CURLOPT_WRITEFUNCTION, playCurlCb);
+ curl_easy_setopt (player->audioFd, CURLOPT_WRITEDATA, player);
+ curl_easy_setopt (player->audioFd, CURLOPT_USERAGENT, PACKAGE_STRING);
+ curl_easy_perform (player->audioFd);
NeAACDecClose(player->aacHandle);
ao_close(player->audioOutDevice);
- curl_easy_cleanup (audioFd);
+ curl_easy_cleanup (player->audioFd);
player->finishedPlayback = 1;
@@ -418,6 +429,7 @@ int main (int argc, char **argv) {
"d\tdelete current station\n"
"l\tlove current song\n"
"n\tnext song\n"
+ "p\tpause/continue\n"
"q\tquit\n"
"r\trename current station\n"
"s\tchange station\n");
@@ -487,6 +499,10 @@ int main (int argc, char **argv) {
case 'n':
player.doQuit = 1;
break;
+
+ case 'p':
+ player.doPause = !player.doPause;
+ break;
case 'q':
doQuit = 1;