summaryrefslogtreecommitdiff
path: root/src/rmd_threads.c
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2020-07-12 11:14:30 -0700
committerVito Caputo <vcaputo@pengaru.com>2020-07-12 11:14:30 -0700
commit193a1e77bf798ef2ce2a1546d845f3bfe6ab3928 (patch)
tree5bc2701279b1fd3fdd4d3054270d7a003e23e708 /src/rmd_threads.c
parent99bc91a3c939e07f2d754a67dce60a55d509b3c1 (diff)
*: standardize sleeps on nanosleep()
usleep() is deprecated by posix in favor of nanosleep(), nanosleep doesn't dick with signals so it's generally better anyways.
Diffstat (limited to 'src/rmd_threads.c')
-rw-r--r--src/rmd_threads.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/rmd_threads.c b/src/rmd_threads.c
index 69b98bf..88a4bbc 100644
--- a/src/rmd_threads.c
+++ b/src/rmd_threads.c
@@ -44,6 +44,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <sys/prctl.h>
+#include <time.h>
#include <unistd.h>
void rmdThreads(ProgData *pdata) {
@@ -58,7 +59,7 @@ void rmdThreads(ProgData *pdata) {
if (pdata->args.delay > 0) {
fprintf(stderr, "Will sleep for %d seconds now.\n", pdata->args.delay);
- sleep(pdata->args.delay);
+ nanosleep(&(struct timespec){ .tv_sec = pdata->args.delay }, NULL);
}
/*start threads*/
@@ -125,7 +126,7 @@ void rmdThreads(ProgData *pdata) {
puts("waiting for th_enc");
pthread_cond_signal(&pdata->image_buffer_ready);
pthread_mutex_unlock(&pdata->theora_lib_mutex);
- usleep(10000);
+ nanosleep(&(struct timespec){ .tv_nsec = 10000000 }, NULL);
pthread_mutex_lock(&pdata->theora_lib_mutex);
}
pthread_mutex_unlock(&pdata->theora_lib_mutex);
@@ -150,7 +151,7 @@ void rmdThreads(ProgData *pdata) {
puts("waiting for v_enc");
pthread_cond_signal(&pdata->sound_data_read);
pthread_mutex_unlock(&pdata->vorbis_lib_mutex);
- usleep(10000);
+ nanosleep(&(struct timespec){ .tv_nsec = 10000000 }, NULL);
pthread_mutex_lock(&pdata->vorbis_lib_mutex);
}
pthread_mutex_unlock(&pdata->vorbis_lib_mutex);
© All Rights Reserved