mirror of
https://github.com/libretro/RetroArch
synced 2025-02-23 15:40:35 +00:00
Style nits.
This commit is contained in:
parent
0ff3cbc93b
commit
48e015558e
25
audio/alsa.c
25
audio/alsa.c
@ -21,7 +21,7 @@
|
|||||||
#include <asoundlib.h>
|
#include <asoundlib.h>
|
||||||
#include "general.h"
|
#include "general.h"
|
||||||
|
|
||||||
#define TRY_ALSA(x) if ( x < 0 ) { \
|
#define TRY_ALSA(x) if (x < 0) { \
|
||||||
goto error; \
|
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)
|
static void* __alsa_init(const char* device, unsigned rate, unsigned latency)
|
||||||
{
|
{
|
||||||
alsa_t *alsa = calloc(1, sizeof(alsa_t));
|
alsa_t *alsa = calloc(1, sizeof(alsa_t));
|
||||||
if ( alsa == NULL )
|
if (!alsa)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
snd_pcm_hw_params_t *params = NULL;
|
snd_pcm_hw_params_t *params = NULL;
|
||||||
snd_pcm_sw_params_t *sw_params = NULL;
|
snd_pcm_sw_params_t *sw_params = NULL;
|
||||||
|
|
||||||
const char *alsa_dev = "default";
|
const char *alsa_dev = "default";
|
||||||
if ( device != NULL )
|
if (device)
|
||||||
alsa_dev = device;
|
alsa_dev = device;
|
||||||
|
|
||||||
TRY_ALSA(snd_pcm_open(&alsa->pcm, alsa_dev, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK));
|
TRY_ALSA(snd_pcm_open(&alsa->pcm, alsa_dev, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK));
|
||||||
@ -117,7 +117,7 @@ error:
|
|||||||
return NULL;
|
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;
|
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);
|
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 -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else if ( frames == -EAGAIN && alsa->nonblock )
|
else if (frames == -EAGAIN && alsa->nonblock)
|
||||||
return 0;
|
return 0;
|
||||||
else if ( frames < 0 )
|
else if (frames < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
written += frames;
|
written += frames;
|
||||||
@ -178,9 +178,9 @@ static bool __alsa_start(void *data)
|
|||||||
static void __alsa_free(void *data)
|
static void __alsa_free(void *data)
|
||||||
{
|
{
|
||||||
alsa_t *alsa = data;
|
alsa_t *alsa = data;
|
||||||
if ( alsa )
|
if (alsa)
|
||||||
{
|
{
|
||||||
if ( alsa->pcm )
|
if (alsa->pcm)
|
||||||
{
|
{
|
||||||
snd_pcm_drop(alsa->pcm);
|
snd_pcm_drop(alsa->pcm);
|
||||||
snd_pcm_close(alsa->pcm);
|
snd_pcm_close(alsa->pcm);
|
||||||
@ -200,8 +200,3 @@ const audio_driver_t audio_alsa = {
|
|||||||
.ident = "alsa"
|
.ident = "alsa"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ static void* __al_init(const char* device, unsigned rate, unsigned latency)
|
|||||||
{
|
{
|
||||||
(void)device;
|
(void)device;
|
||||||
al_t *al = calloc(1, sizeof(al_t));
|
al_t *al = calloc(1, sizeof(al_t));
|
||||||
if ( al == NULL )
|
if (!al)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
al->handle = alcOpenDevice(NULL);
|
al->handle = alcOpenDevice(NULL);
|
||||||
@ -221,7 +221,7 @@ static void __al_free(void *data)
|
|||||||
{
|
{
|
||||||
alSourceStop(al->source);
|
alSourceStop(al->source);
|
||||||
alDeleteSources(1, &al->source);
|
alDeleteSources(1, &al->source);
|
||||||
if ( al->buffers )
|
if (al->buffers)
|
||||||
{
|
{
|
||||||
alDeleteBuffers(al->num_buffers, al->buffers);
|
alDeleteBuffers(al->num_buffers, al->buffers);
|
||||||
free(al->buffers);
|
free(al->buffers);
|
||||||
@ -244,4 +244,3 @@ const audio_driver_t audio_openal = {
|
|||||||
.ident = "openal"
|
.ident = "openal"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,12 +57,12 @@ static void err_cb(void *userdata)
|
|||||||
static void* __rsd_init(const char* device, unsigned rate, unsigned latency)
|
static void* __rsd_init(const char* device, unsigned rate, unsigned latency)
|
||||||
{
|
{
|
||||||
rsd_t *rsd = calloc(1, sizeof(rsd_t));
|
rsd_t *rsd = calloc(1, sizeof(rsd_t));
|
||||||
if ( rsd == NULL )
|
if (!rsd)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
rsound_t *rd;
|
rsound_t *rd;
|
||||||
|
|
||||||
if ( rsd_init(&rd) < 0 )
|
if (rsd_init(&rd) < 0)
|
||||||
{
|
{
|
||||||
free(rsd);
|
free(rsd);
|
||||||
return NULL;
|
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_SAMPLERATE, &rate);
|
||||||
rsd_set_param(rd, RSD_LATENCY, &latency);
|
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_HOST, (void*)device);
|
||||||
|
|
||||||
rsd_set_param(rd, RSD_FORMAT, &format);
|
rsd_set_param(rd, RSD_FORMAT, &format);
|
||||||
|
|
||||||
rsd_set_callback(rd, audio_cb, err_cb, 256, rsd);
|
rsd_set_callback(rd, audio_cb, err_cb, 256, rsd);
|
||||||
|
|
||||||
if ( rsd_start(rd) < 0 )
|
if (rsd_start(rd) < 0)
|
||||||
{
|
{
|
||||||
free(rsd);
|
free(rsd);
|
||||||
rsd_free(rd);
|
rsd_free(rd);
|
||||||
@ -161,7 +161,7 @@ static void __rsd_set_nonblock_state(void *data, bool state)
|
|||||||
static bool __rsd_start(void *data)
|
static bool __rsd_start(void *data)
|
||||||
{
|
{
|
||||||
rsd_t *rsd = data;
|
rsd_t *rsd = data;
|
||||||
if ( rsd_start(rsd->rd) < 0)
|
if (rsd_start(rsd->rd) < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user