diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2021-04-28 19:28:14 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2021-04-28 19:28:14 -0700 |
commit | 3812a302cefcccbeb9bc46ed5c55710eb4c0512e (patch) | |
tree | 0699a192560cd2e9d50a363a1929af7f794ed43c /src/rmd_encode_cache.c | |
parent | 64eed5bc02c0a4e09423aa67f118a2a7c8bc69b0 (diff) |
encode_cache: handle pthread_create() errors
switch to using rmdThread() and handle errors
previously pthread_create() errors were completely unnoticed
Diffstat (limited to 'src/rmd_encode_cache.c')
-rw-r--r-- | src/rmd_encode_cache.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/rmd_encode_cache.c b/src/rmd_encode_cache.c index e2bf85d..2d778be 100644 --- a/src/rmd_encode_cache.c +++ b/src/rmd_encode_cache.c @@ -30,6 +30,7 @@ #include "rmd_flush_to_ogg.h" #include "rmd_init_encoder.h" #include "rmd_load_cache.h" +#include "rmd_threads.h" #include "rmd_types.h" #include <pthread.h> @@ -38,8 +39,7 @@ #include <stdlib.h> - -void rmdEncodeCache(ProgData *pdata) +int rmdEncodeCache(ProgData *pdata) { pthread_t flush_to_ogg_t, load_cache_t; @@ -61,13 +61,22 @@ void rmdEncodeCache(ProgData *pdata) pdata->sound_buffer = pdata->sound_buffer->next; } } - pthread_create(&flush_to_ogg_t, NULL, (void *)rmdFlushToOgg, (void *)pdata); + + if (rmdThread(&flush_to_ogg_t, rmdFlushToOgg, pdata)) { + fprintf(stderr, "Error creating rmdFlushToOgg thread!!!\n"); + return 1; + } //start loading image and audio - pthread_create(&load_cache_t, NULL, (void *)rmdLoadCache, (void *)pdata); + if (rmdThread(&load_cache_t, rmdLoadCache, pdata)) { + fprintf(stderr, "Error creating rmdLoadCache thread!!!\n"); + return 1; + } //join and finish pthread_join(load_cache_t, NULL); fprintf(stderr, "Encoding finished!\nWait a moment please...\n"); pthread_join(flush_to_ogg_t, NULL); + + return 0; } |