From 8c0059ab76c6ca8fcf3b3f71d0d36e9e1128fc19 Mon Sep 17 00:00:00 2001 From: John Janus Date: Thu, 21 Sep 2017 19:01:08 +0200 Subject: [PATCH] small --- mp3player.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) 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); +} -- 2.47.0