From 5845a9944d2c2e7c4532c5d739793dee4ac3ae77 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 19:02:43 +0200 Subject: [PATCH] Add more HAVE_THREADS ifdefs --- Makefile.common | 9 +++++++-- audio/audio_driver.c | 2 +- audio/drivers/jack.c | 14 ++++++++++++++ audio/drivers/sdl_audio.c | 10 ++++++++++ gfx/drivers_context/wayland_ctx.c | 2 +- gfx/drivers_context/x_ctx.c | 2 +- griffin/griffin.c | 2 +- input/input_hid_driver.c | 2 +- 8 files changed, 36 insertions(+), 7 deletions(-) diff --git a/Makefile.common b/Makefile.common index b36ec42be9..4d909c217a 100644 --- a/Makefile.common +++ b/Makefile.common @@ -291,8 +291,11 @@ ifeq ($(HAVE_OSS_BSD), 1) endif ifeq ($(HAVE_ALSA), 1) - OBJ += audio/drivers/alsa.o \ - audio/drivers/alsathread.o + OBJ += audio/drivers/alsa.o + +ifeq ($(HAVE_THREADS), 1) + OBJ += audio/drivers/alsathread.o +endif LIBS += $(ALSA_LIBS) DEFINES += $(ALSA_CFLAGS) endif @@ -575,11 +578,13 @@ ifeq ($(HAVE_UDEV), 1) endif ifeq ($(HAVE_LIBUSB), 1) +ifeq ($(HAVE_THREADS), 1) DEFINES += -DHAVE_LIBUSB OBJ += input/drivers_hid/libusb_hid.o LIBS += -lusb-1.0 HAVE_HID = 1 endif +endif ifeq ($(HAVE_IOHIDMANAGER), 1) DEFINES += -DHAVE_IOHIDMANAGER diff --git a/audio/audio_driver.c b/audio/audio_driver.c index b9cd3fed4c..c875df40f1 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -93,7 +93,7 @@ typedef struct audio_driver_input_data static const audio_driver_t *audio_drivers[] = { #ifdef HAVE_ALSA &audio_alsa, -#ifndef __QNX__ +#if !defined(__QNX__) && defined(HAVE_THREADS) &audio_alsathread, #endif #endif diff --git a/audio/drivers/jack.c b/audio/drivers/jack.c index f9f3abfaf6..80b2ee34e3 100644 --- a/audio/drivers/jack.c +++ b/audio/drivers/jack.c @@ -41,8 +41,10 @@ typedef struct jack bool nonblock; bool is_paused; +#ifdef HAVE_THREADS scond_t *cond; slock_t *cond_lock; +#endif size_t buffer_size; } jack_t; @@ -54,7 +56,9 @@ static int process_cb(jack_nframes_t nframes, void *data) if (nframes <= 0) { +#ifdef HAVE_THREADS scond_signal(jd->cond); +#endif return 0; } @@ -74,7 +78,9 @@ static int process_cb(jack_nframes_t nframes, void *data) for (f = min_avail; f < nframes; f++) out[f] = 0.0f; } +#ifdef HAVE_THREADS scond_signal(jd->cond); +#endif return 0; } @@ -86,7 +92,9 @@ static void shutdown_cb(void *data) return; jd->shutdown = true; +#ifdef HAVE_THREADS scond_signal(jd->cond); +#endif } static int parse_ports(char **dest_ports, const char **jports) @@ -149,8 +157,10 @@ static void *ja_init(const char *device, unsigned rate, unsigned latency) if (!jd) return NULL; +#ifdef HAVE_THREADS jd->cond = scond_new(); jd->cond_lock = slock_new(); +#endif jd->client = jack_client_open("RetroArch", JackNullOption, NULL); if (jd->client == NULL) @@ -258,12 +268,14 @@ static size_t write_buffer(jack_t *jd, const float *buf, size_t size) } written += write_frames; } +#ifdef HAVE_THREADS else { slock_lock(jd->cond_lock); scond_wait(jd->cond, jd->cond_lock); slock_unlock(jd->cond_lock); } +#endif if (jd->nonblock) break; @@ -327,10 +339,12 @@ static void ja_free(void *data) if (jd->buffer[i] != NULL) jack_ringbuffer_free(jd->buffer[i]); +#ifdef HAVE_THREADS if (jd->cond_lock) slock_free(jd->cond_lock); if (jd->cond) scond_free(jd->cond); +#endif free(jd); } diff --git a/audio/drivers/sdl_audio.c b/audio/drivers/sdl_audio.c index dc6f16eb34..181d60f105 100644 --- a/audio/drivers/sdl_audio.c +++ b/audio/drivers/sdl_audio.c @@ -35,8 +35,10 @@ typedef struct sdl_audio bool nonblock; bool is_paused; +#ifdef HAVE_THREADS slock_t *lock; scond_t *cond; +#endif fifo_buffer_t *buffer; } sdl_audio_t; @@ -47,7 +49,9 @@ static void sdl_audio_cb(void *data, Uint8 *stream, int len) size_t write_size = len > (int)avail ? avail : len; fifo_read(sdl->buffer, stream, write_size); +#ifdef HAVE_THREADS scond_signal(sdl->cond); +#endif /* If underrun, fill rest with silence. */ memset(stream + write_size, 0, len - write_size); @@ -109,8 +113,10 @@ static void *sdl_audio_init(const char *device, settings->audio.out_rate = out.freq; +#ifdef HAVE_THREADS sdl->lock = slock_new(); sdl->cond = scond_new(); +#endif RARCH_LOG("SDL audio: Requested %u ms latency, got %d ms\n", latency, (int)(out.samples * 4 * 1000 / settings->audio.out_rate)); @@ -160,9 +166,11 @@ static ssize_t sdl_audio_write(void *data, const void *buf, size_t size) if (avail == 0) { SDL_UnlockAudio(); +#ifdef HAVE_THREADS slock_lock(sdl->lock); scond_wait(sdl->cond, sdl->lock); slock_unlock(sdl->lock); +#endif } else { @@ -220,8 +228,10 @@ static void sdl_audio_free(void *data) if (sdl) { fifo_free(sdl->buffer); +#ifdef HAVE_THREADS slock_free(sdl->lock); scond_free(sdl->cond); +#endif } free(sdl); } diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index 7098916b39..66b7dbbdc9 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -706,7 +706,7 @@ static void gfx_ctx_wl_destroy(void *data) switch (wl_api) { case GFX_CTX_VULKAN_API: -#ifdef HAVE_VULKAN +#if defined(HAVE_VULKAN) && defined(HAVE_THREADS) if (wl->vk.context.queue_lock) slock_free(wl->vk.context.queue_lock); #endif diff --git a/gfx/drivers_context/x_ctx.c b/gfx/drivers_context/x_ctx.c index 1e6c41101b..1f7aec4f85 100644 --- a/gfx/drivers_context/x_ctx.c +++ b/gfx/drivers_context/x_ctx.c @@ -167,7 +167,7 @@ static void gfx_ctx_x_destroy(void *data) switch (x_api) { case GFX_CTX_VULKAN_API: -#ifdef HAVE_VULKAN +#if defined(HAVE_VULKAN) && defined(HAVE_THREADS) if (x->vk.context.queue_lock) slock_free(x->vk.context.queue_lock); #endif diff --git a/griffin/griffin.c b/griffin/griffin.c index edf45c5fad..da142c7151 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -430,7 +430,7 @@ INPUT (HID) #include "../input/drivers_hid/null_hid.c" -#if defined(HAVE_LIBUSB) +#if defined(HAVE_LIBUSB) && defined(HAVE_THREADS) #include "../input/drivers_hid/libusb_hid.c" #endif diff --git a/input/input_hid_driver.c b/input/input_hid_driver.c index ce37c24f22..a7b9bdc732 100644 --- a/input/input_hid_driver.c +++ b/input/input_hid_driver.c @@ -29,7 +29,7 @@ static hid_driver_t *hid_drivers[] = { #if defined(__APPLE__) && defined(HAVE_IOHIDMANAGER) &iohidmanager_hid, #endif -#ifdef HAVE_LIBUSB +#if defined(HAVE_LIBUSB) && defined(HAVE_THREADS) &libusb_hid, #endif #ifdef HW_RVL