From: John Janus Date: Thu, 21 Sep 2017 17:01:08 +0000 (+0200) Subject: small X-Git-Url: https://git.johnzone.org/?a=commitdiff_plain;h=8c0059ab76c6ca8fcf3b3f71d0d36e9e1128fc19;p=FakeRadio.git small --- diff --git a/mp3player.c b/mp3player.c index 6e9b012..2c6c386 100644 --- a/mp3player.c +++ b/mp3player.c @@ -64,8 +64,9 @@ void* playFunc(void* arg) mem->mh = mpg123_new(NULL, &err); 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; + pthread_cleanup_push(cleanupThread, (void*) mem); + if (mpg123_open(mem->mh, settings->file) != MPG123_OK) pthread_exit((void*) pthread_self());; + if (mpg123_getformat(mem->mh, &rate, &channels, &encoding) != MPG123_OK) pthread_exit((void*) pthread_self());; format.bits = mpg123_encsize(encoding) * BITS; format.rate = rate; @@ -74,7 +75,7 @@ void* playFunc(void* arg) format.matrix = 0; ao_option options = {"debug","",NULL}; mem->aodev = ao_open_live(driver, &format, &options); - pthread_cleanup_push(cleanupThread, (void*) mem); + do { while (running) { @@ -88,10 +89,10 @@ void* playFunc(void* arg) pthread_exit((void*) pthread_self()); } -//int main(int argc, char** argv) -//{ -// pthread_t th = startPlayThread("platt01.mp3", true); -// //sleep(3); -// //pthread_cancel(th); -// pthread_join(th, NULL); -//} +int main(int argc, char** argv) +{ + pthread_t th = startPlayThread("platt01.mp3", true); + //sleep(3); + //pthread_cancel(th); + pthread_join(th, NULL); +}