summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars-Dominik Braun <PromyLOPh@gmail.com>2008-06-15 21:35:45 +0200
committerLars-Dominik Braun <PromyLOPh@gmail.com>2008-06-15 21:35:45 +0200
commit5a3c68a6d13464be6330aa4a5a32ec6115cedef0 (patch)
treee45fe4a2e172f3c9dd1512f39f045c19b2a9d4fa
parentc17911ba268a4a784c57baed1540d08ba8741e04 (diff)
downloadpianobar-5a3c68a6d13464be6330aa4a5a32ec6115cedef0.tar.gz
pianobar-5a3c68a6d13464be6330aa4a5a32ec6115cedef0.tar.bz2
pianobar-5a3c68a6d13464be6330aa4a5a32ec6115cedef0.zip
client: Removed unneeded debugging printf's; some more documentation for functions
-rw-r--r--src/main.c19
-rw-r--r--src/settings.c6
-rw-r--r--src/terminal.c11
3 files changed, 21 insertions, 15 deletions
diff --git a/src/main.c b/src/main.c
index a7df2aa..e893b1d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -88,13 +88,10 @@ int playCurlCb (void *ptr, size_t size, size_t nmemb, void *stream) {
/* keep some bytes in buffer */
while (bufferOffset < aacBufferN-500) {
- //printf ("play buffer at %i/%i: ", bufferOffset, aacBufferN);
- //dumpBuffer (aacBuffer+bufferOffset, 50);
/* FIXME: well, i think we need this block length table */
aacDecoded = NeAACDecDecode(player->aacHandle, &frameInfo,
(unsigned char *) aacBuffer+bufferOffset,
aacBufferN-bufferOffset);
- //printf ("bytesconsumed: %li\nerror: %i\nsamples: %lu\nsamplerate: %lu\n\n", frameInfo.bytesconsumed, frameInfo.error, frameInfo.samples, frameInfo.samplerate);
if (frameInfo.error != 0) {
printf ("error: %s\n\n", NeAACDecGetErrorMessage (frameInfo.error));
break;
@@ -108,8 +105,6 @@ int playCurlCb (void *ptr, size_t size, size_t nmemb, void *stream) {
memcpy (player->buffer, aacBuffer+bufferOffset,
aacBufferN - bufferOffset);
player->bufferFilled = aacBufferN - bufferOffset;
- //printf ("player->buffer (%i) = ", aacBufferN - bufferOffset);
- //dumpBuffer (player->buffer, 50);
free (aacBuffer);
} else {
player->buffer = calloc (nmemb + sizeof (player->lastBytes), size);
@@ -144,14 +139,13 @@ int playCurlCb (void *ptr, size_t size, size_t nmemb, void *stream) {
printf ("whoops... %i\n", err);
return 1;
}
- //printf ("samplerate: %li\nchannels: %i\n\n",
- // player->samplerate, player->channels);
audioOutDriver = ao_default_driver_id();
format.bits = 16;
format.channels = player->channels;
format.rate = player->samplerate;
format.byte_format = AO_FMT_LITTLE;
- player->audioOutDevice = ao_open_live (audioOutDriver, &format, NULL);
+ player->audioOutDevice = ao_open_live (audioOutDriver,
+ &format, NULL);
player->audioInitialized = 1;
break;
}
@@ -164,8 +158,6 @@ int playCurlCb (void *ptr, size_t size, size_t nmemb, void *stream) {
player->dataMode = 1;
memmove (player->buffer, searchBegin+4, nmemb - (searchBegin-player->buffer));
player->bufferFilled = nmemb - (searchBegin-player->buffer);
- //printf ("copied %i bytes: ", nmemb - (searchBegin-player->buffer));
- //dumpBuffer (player->buffer, 50);
break;
}
searchBegin++;
@@ -174,8 +166,6 @@ int playCurlCb (void *ptr, size_t size, size_t nmemb, void *stream) {
if (!player->dataMode) {
memcpy (player->lastBytes, data + (size * nmemb - sizeof (player->lastBytes)),
sizeof (player->lastBytes));
- //printf ("last bytes: ");
- //dumpBuffer (player->lastBytes, 4);
free (player->buffer);
}
}
@@ -183,6 +173,7 @@ int playCurlCb (void *ptr, size_t size, size_t nmemb, void *stream) {
return size*nmemb;
}
+/* player thread; for every song a new thread is started */
void *threadPlayUrl (void *data) {
struct aacPlayer *player = data;
NeAACDecConfigurationPtr conf;
@@ -300,12 +291,11 @@ int main (int argc, char **argv) {
}
PianoInit (&ph);
- /* setup control proxy */
+ /* setup control connection */
curl_easy_setopt (ph.curlHandle, CURLOPT_PROXY, bsettings.controlProxy);
curl_easy_setopt (ph.curlHandle, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4A);
curl_easy_setopt (ph.curlHandle, CURLOPT_CONNECTTIMEOUT, 60);
- /* no buffering for stdin */
termSetBuffer (0);
printf ("Login...\n");
@@ -319,7 +309,6 @@ int main (int argc, char **argv) {
PianoGetPlaylist (&ph, curStation->id);
curSong = ph.playlist;
- /* play first track */
while (!doQuit) {
pthread_t playerThread;
printf ("\"%s\" by \"%s\"%s\n", curSong->title, curSong->artist,
diff --git a/src/settings.c b/src/settings.c
index 2b1c313..40a5064 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -65,6 +65,12 @@ void BarSettingsDestroy (BarSettings_t *settings) {
free (settings->password);
}
+/* read app settings from file; format is: key = value\n
+ * @author PromyLOPh
+ * @added 2008-06-15
+ * @param where to save these settings
+ * @return nothing yet
+ */
void readSettings (BarSettings_t *settings) {
char configfile[1024], key[256], val[256];
FILE *configfd;
diff --git a/src/terminal.c b/src/terminal.c
index e3fd5d0..2b13e24 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -23,6 +23,11 @@ THE SOFTWARE.
#include <termios.h>
#include <stdio.h>
+/* en/disable echoing for stdin
+ * @author PromyLOPh
+ * @added 2008-06-15
+ * @param 1 = enable, everything else = disable
+ */
void termSetEcho (char enable) {
struct termios termopts;
@@ -35,6 +40,12 @@ void termSetEcho (char enable) {
tcsetattr(fileno (stdin), TCSANOW, &termopts);
}
+/* en/disable stdin buffering; when enabling line-buffer method will be
+ * selected for you
+ * @author PromyLOPh
+ * @added 2008-06-15
+ * @param 1 = enable, everything else = disable
+ */
void termSetBuffer (char enable) {
struct termios termopts;