diff --git a/audio/alsa.c b/audio/alsa.c index 014c6c5b09..7132631696 100644 --- a/audio/alsa.c +++ b/audio/alsa.c @@ -21,7 +21,7 @@ #include #include "general.h" -#define TRY_ALSA(x) if ( x < 0 ) { \ +#define TRY_ALSA(x) if (x < 0) { \ goto error; \ } @@ -52,14 +52,14 @@ static bool find_float_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) static void* __alsa_init(const char* device, unsigned rate, unsigned latency) { alsa_t *alsa = calloc(1, sizeof(alsa_t)); - if ( alsa == NULL ) + if (!alsa) return NULL; snd_pcm_hw_params_t *params = NULL; snd_pcm_sw_params_t *sw_params = NULL; const char *alsa_dev = "default"; - if ( device != NULL ) + if (device) alsa_dev = device; TRY_ALSA(snd_pcm_open(&alsa->pcm, alsa_dev, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK)); @@ -117,7 +117,7 @@ error: return NULL; } -static ssize_t __alsa_write(void* data, const void* buf, size_t size) +static ssize_t __alsa_write(void *data, const void *buf, size_t size) { alsa_t *alsa = data; @@ -141,16 +141,16 @@ static ssize_t __alsa_write(void* data, const void* buf, size_t size) frames = snd_pcm_writei(alsa->pcm, (const char*)buf + written * 2 * (alsa->has_float ? sizeof(float) : sizeof(int16_t)), size - written); - if ( frames == -EPIPE || frames == -EINTR || frames == -ESTRPIPE ) + if (frames == -EPIPE || frames == -EINTR || frames == -ESTRPIPE) { - if ( snd_pcm_recover(alsa->pcm, frames, 1) < 0 ) + if (snd_pcm_recover(alsa->pcm, frames, 1) < 0) return -1; return 0; } - else if ( frames == -EAGAIN && alsa->nonblock ) + else if (frames == -EAGAIN && alsa->nonblock) return 0; - else if ( frames < 0 ) + else if (frames < 0) return -1; written += frames; @@ -178,9 +178,9 @@ static bool __alsa_start(void *data) static void __alsa_free(void *data) { alsa_t *alsa = data; - if ( alsa ) + if (alsa) { - if ( alsa->pcm ) + if (alsa->pcm) { snd_pcm_drop(alsa->pcm); snd_pcm_close(alsa->pcm); @@ -200,8 +200,3 @@ const audio_driver_t audio_alsa = { .ident = "alsa" }; - - - - - diff --git a/audio/openal.c b/audio/openal.c index 09d96238fc..2819f0e32f 100644 --- a/audio/openal.c +++ b/audio/openal.c @@ -60,7 +60,7 @@ static void* __al_init(const char* device, unsigned rate, unsigned latency) { (void)device; al_t *al = calloc(1, sizeof(al_t)); - if ( al == NULL ) + if (!al) return NULL; al->handle = alcOpenDevice(NULL); @@ -221,7 +221,7 @@ static void __al_free(void *data) { alSourceStop(al->source); alDeleteSources(1, &al->source); - if ( al->buffers ) + if (al->buffers) { alDeleteBuffers(al->num_buffers, al->buffers); free(al->buffers); @@ -244,4 +244,3 @@ const audio_driver_t audio_openal = { .ident = "openal" }; - diff --git a/audio/rsound.c b/audio/rsound.c index 6de9249e41..a623e88686 100644 --- a/audio/rsound.c +++ b/audio/rsound.c @@ -57,12 +57,12 @@ static void err_cb(void *userdata) static void* __rsd_init(const char* device, unsigned rate, unsigned latency) { rsd_t *rsd = calloc(1, sizeof(rsd_t)); - if ( rsd == NULL ) + if (!rsd) return NULL; rsound_t *rd; - if ( rsd_init(&rd) < 0 ) + if (rsd_init(&rd) < 0) { free(rsd); return NULL; @@ -80,14 +80,14 @@ static void* __rsd_init(const char* device, unsigned rate, unsigned latency) rsd_set_param(rd, RSD_SAMPLERATE, &rate); rsd_set_param(rd, RSD_LATENCY, &latency); - if ( device != NULL ) + if (device) rsd_set_param(rd, RSD_HOST, (void*)device); rsd_set_param(rd, RSD_FORMAT, &format); rsd_set_callback(rd, audio_cb, err_cb, 256, rsd); - if ( rsd_start(rd) < 0 ) + if (rsd_start(rd) < 0) { free(rsd); rsd_free(rd); @@ -161,7 +161,7 @@ static void __rsd_set_nonblock_state(void *data, bool state) static bool __rsd_start(void *data) { rsd_t *rsd = data; - if ( rsd_start(rsd->rd) < 0) + if (rsd_start(rsd->rd) < 0) return false; return true;