(Audio) Cleanups

This commit is contained in:
twinaphex 2020-01-04 10:39:33 +01:00
parent ee7051891b
commit 1d6f547e7f
6 changed files with 24 additions and 23 deletions

View File

@ -372,7 +372,7 @@ static void *alsa_device_list_new(void *data)
n = hints;
while (*n != NULL)
while (*n)
{
char *name = snd_device_name_get_hint(*n, "NAME");
char *io = snd_device_name_get_hint(*n, "IOID");

View File

@ -361,7 +361,7 @@ static void *alsa_thread_device_list_new(void *data)
n = hints;
while (*n != NULL)
while (*n)
{
char *name = snd_device_name_get_hint(*n, "NAME");
char *io = snd_device_name_get_hint(*n, "IOID");

View File

@ -166,7 +166,7 @@ static void *ja_init(const char *device, unsigned rate, unsigned latency,
#endif
jd->client = jack_client_open("RetroArch", JackNullOption, NULL);
if (jd->client == NULL)
if (!jd->client)
goto error;
*new_rate = jack_get_sample_rate(jd->client);
@ -176,14 +176,14 @@ static void *ja_init(const char *device, unsigned rate, unsigned latency,
jd->ports[0] = jack_port_register(jd->client, "left", JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0);
jd->ports[1] = jack_port_register(jd->client, "right", JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0);
if (jd->ports[0] == NULL || jd->ports[1] == NULL)
if (!jd->ports[0] || !jd->ports[1])
{
RARCH_ERR("[JACK]: Failed to register ports.\n");
goto error;
}
jports = jack_get_ports(jd->client, NULL, NULL, JackPortIsPhysical | JackPortIsInput);
if (jports == NULL)
if (!jports)
{
RARCH_ERR("[JACK]: Failed to get ports.\n");
goto error;
@ -196,7 +196,7 @@ static void *ja_init(const char *device, unsigned rate, unsigned latency,
for (i = 0; i < 2; i++)
{
jd->buffer[i] = jack_ringbuffer_create(bufsize);
if (jd->buffer[i] == NULL)
if (!jd->buffer[i])
{
RARCH_ERR("[JACK]: Failed to create buffers.\n");
goto error;
@ -229,7 +229,7 @@ static void *ja_init(const char *device, unsigned rate, unsigned latency,
error:
for (i = 0; i < parsed; i++)
free(dest_ports[i]);
if (jports != NULL)
if (jports)
jack_free(jports);
free(jd);
return NULL;
@ -334,14 +334,14 @@ static void ja_free(void *data)
jd->shutdown = true;
if (jd->client != NULL)
if (jd->client)
{
jack_deactivate(jd->client);
jack_client_close(jd->client);
}
for (i = 0; i < 2; i++)
if (jd->buffer[i] != NULL)
if (jd->buffer[i])
jack_ringbuffer_free(jd->buffer[i]);
#ifdef HAVE_THREADS

View File

@ -115,7 +115,7 @@ static void *al_init(const char *device, unsigned rate, unsigned latency,
al->buffers = (ALuint*)calloc(al->num_buffers, sizeof(ALuint));
al->res_buf = (ALuint*)calloc(al->num_buffers, sizeof(ALuint));
if (al->buffers == NULL || al->res_buf == NULL)
if (!al->buffers || !al->res_buf)
goto error;
alGenSources(1, &al->source);

View File

@ -808,7 +808,7 @@ static unsigned int pcm_get_channels(const struct pcm *pcm)
* */
static const struct pcm_config * pcm_get_config(const struct pcm *pcm)
{
if (pcm == NULL)
if (!pcm)
return NULL;
return &pcm->config;
}
@ -929,7 +929,7 @@ static int pcm_set_config(struct pcm *pcm, const struct pcm_config *config)
struct snd_pcm_sw_params sparams;
struct snd_pcm_hw_params params;
if (pcm == NULL)
if (!pcm)
return -EFAULT;
if (config)
@ -1293,7 +1293,7 @@ static int pcm_get_htimestamp(struct pcm *pcm, unsigned int *avail,
*/
static int pcm_is_ready(const struct pcm *pcm)
{
if (pcm != NULL)
if (pcm)
return pcm->fd >= 0;
return 0;
}
@ -1582,7 +1582,7 @@ static const struct pcm_mask *pcm_params_get_mask(const struct pcm_params *pcm_p
{
int p;
struct snd_pcm_hw_params *params = (struct snd_pcm_hw_params *)pcm_params;
if (params == NULL)
if (!params)
return NULL;
p = pcm_param_to_alsa(param);
@ -2185,7 +2185,7 @@ static void * tinyalsa_init(const char *devicestr, unsigned rate,
RARCH_LOG("[TINYALSA]: Using card: %u, device: %u.\n", card, device);
tinyalsa->params = pcm_params_get(card, device, PCM_OUT);
if (tinyalsa->params == NULL)
if (!tinyalsa->params)
{
RARCH_ERR("[TINYALSA]: params: Cannot open audio device.\n");
goto error;
@ -2224,7 +2224,7 @@ static void * tinyalsa_init(const char *devicestr, unsigned rate,
tinyalsa->pcm = pcm_open(card, device, PCM_OUT, &config);
if (tinyalsa->pcm == NULL)
if (!tinyalsa->pcm)
{
RARCH_ERR("[TINYALSA]: Failed to allocate memory for pcm.\n");
goto error;

View File

@ -869,26 +869,27 @@ static INLINE HRESULT XAudio2Create(_Outptr_ IXAudio2** ppXAudio2,
typedef HRESULT(__stdcall *XAudio2CreateWithVersionInfoFunc)(_Outptr_ IXAudio2**, UINT32, XAUDIO2_PROCESSOR, DWORD);
typedef HRESULT(__stdcall *XAudio2CreateInfoFunc)(_Outptr_ IXAudio2**, UINT32, XAUDIO2_PROCESSOR);
static HMODULE s_dllInstance = NULL;
static XAudio2CreateWithVersionInfoFunc s_pfnAudio2CreateWithVersion = NULL;
static XAudio2CreateWithVersionInfoFunc
s_pfnAudio2CreateWithVersion = NULL;
static XAudio2CreateInfoFunc s_pfnAudio2Create = NULL;
static HMODULE s_dllInstance = NULL;
if (s_dllInstance == NULL)
if (!s_dllInstance)
{
s_dllInstance = LoadLibraryEx(XAUDIO2_DLL, NULL, LOAD_LIBRARY_SEARCH_SYSTEM32);
if (s_dllInstance == NULL)
if (!s_dllInstance)
return HRESULT_FROM_WIN32(GetLastError());
s_pfnAudio2CreateWithVersion = (XAudio2CreateWithVersionInfoFunc)(void*)GetProcAddress(s_dllInstance, "XAudio2CreateWithVersionInfo");
if (s_pfnAudio2CreateWithVersion == NULL)
if (!s_pfnAudio2CreateWithVersion)
{
s_pfnAudio2Create = (XAudio2CreateInfoFunc)(void*)GetProcAddress(s_dllInstance, "XAudio2Create");
if (s_pfnAudio2Create == NULL)
if (!s_pfnAudio2Create)
return HRESULT_FROM_WIN32(GetLastError());
}
}
if (s_pfnAudio2CreateWithVersion != NULL)
if (s_pfnAudio2CreateWithVersion)
return (*s_pfnAudio2CreateWithVersion)(ppXAudio2, Flags, XAudio2Processor, NTDDI_VERSION);
return (*s_pfnAudio2Create)(ppXAudio2, Flags, XAudio2Processor);
}