]> Johnzone git - FakeRadio.git/commitdiff
reduce cracking, buffer ptobably needs to be filled asynchronously
authorJohn Janus <mail@johnzone.org>
Thu, 21 Sep 2017 06:27:25 +0000 (08:27 +0200)
committerJohn Janus <mail@johnzone.org>
Thu, 21 Sep 2017 06:27:25 +0000 (08:27 +0200)
mp3player.c

index ad7b9893c4e644881621aefd628727e15bb9f0f3..4661b26e809b3ca8416be00246963822518dd786 100644 (file)
@@ -62,22 +62,20 @@ void* playFunc(void* arg)
     driver = ao_default_driver_id();
     mpg123_init();
     mem->mh = mpg123_new(NULL, &err);
-    buffer_size = mpg123_outblock(mem->mh);
+    buffer_size = mpg123_outblock(mem->mh)*30;
     mem->buffer = (unsigned char*) malloc(buffer_size * sizeof(unsigned char));
-    mem->aodev = ao_open_live(driver, &format, NULL);
+    if (mpg123_open(mem->mh, settings->file) != MPG123_OK) return NULL;
+    if (mpg123_getformat(mem->mh, &rate, &channels, &encoding) != MPG123_OK) return NULL;
+    
+    format.bits = mpg123_encsize(encoding) * BITS;
+    format.rate = rate;
+    format.channels = channels;
+    format.byte_format = AO_FMT_NATIVE;
+    format.matrix = 0;
+    ao_option options = {"debug","",NULL};
+    mem->aodev = ao_open_live(driver, &format, &options);
     pthread_cleanup_push(cleanupThread, (void*) mem);
     do {
-        if (mpg123_open(mem->mh, settings->file) != MPG123_OK) return NULL;
-        if (mpg123_getformat(mem->mh, &rate, &channels, &encoding) != MPG123_OK) return NULL;
-    
-        format.bits = mpg123_encsize(encoding) * BITS;
-        format.rate = rate;
-        format.channels = channels;
-        format.byte_format = AO_FMT_NATIVE;
-        format.matrix = 0;
-        
-        
-        
         while (mpg123_read(mem->mh, mem->buffer, buffer_size, &done) == MPG123_OK && running)
         {
             ao_play(mem->aodev, mem->buffer, done);