]> Johnzone git - FakeRadio.git/commitdiff
decode in loop
authorJohn Janus <j.janus@lighthouse-it.de>
Thu, 21 Sep 2017 09:48:53 +0000 (11:48 +0200)
committerJohn Janus <j.janus@lighthouse-it.de>
Thu, 21 Sep 2017 09:48:53 +0000 (11:48 +0200)
mp3player.c

index 4661b26e809b3ca8416be00246963822518dd786..6e9b01205e912967432761a2598e23bd063f3164 100644 (file)
@@ -62,7 +62,7 @@ void* playFunc(void* arg)
     driver = ao_default_driver_id();
     mpg123_init();
     mem->mh = mpg123_new(NULL, &err);
-    buffer_size = mpg123_outblock(mem->mh)*30;
+    buffer_size = mpg123_outblock(mem->mh)*2;
     mem->buffer = (unsigned char*) malloc(buffer_size * sizeof(unsigned char));
     if (mpg123_open(mem->mh, settings->file) != MPG123_OK) return NULL;
     if (mpg123_getformat(mem->mh, &rate, &channels, &encoding) != MPG123_OK) return NULL;
@@ -76,8 +76,9 @@ void* playFunc(void* arg)
     mem->aodev = ao_open_live(driver, &format, &options);
     pthread_cleanup_push(cleanupThread, (void*) mem);
     do {
-        while (mpg123_read(mem->mh, mem->buffer, buffer_size, &done) == MPG123_OK && running)
+        while (running)
         {
+            if (mpg123_read(mem->mh, mem->buffer, buffer_size, &done) != MPG123_OK) break;
             ao_play(mem->aodev, mem->buffer, done);
             pthread_testcancel();
         }