From cde82f532ca7db0bd114b07a56d2b5e891e1801d Mon Sep 17 00:00:00 2001 From: LibretroAdmin Date: Sun, 19 Jan 2025 20:19:14 +0100 Subject: [PATCH] * Naming convention changes for variable names/function arguments * Try to fit lines within ANSI 80-char limit --- audio/drivers/alsa.c | 59 ++-- audio/drivers/alsa_qsa.c | 11 +- audio/drivers/alsathread.c | 17 +- audio/drivers/audioio.c | 10 +- audio/drivers/coreaudio.c | 23 +- audio/drivers/coreaudio3.m | 5 +- audio/drivers/ctr_csnd_audio.c | 26 +- audio/drivers/ctr_dsp_audio.c | 34 +- audio/drivers/ctr_dsp_thread_audio.c | 8 +- audio/drivers/dsound.c | 20 +- audio/drivers/gx_audio.c | 28 +- audio/drivers/jack.c | 14 +- audio/drivers/oss.c | 9 +- audio/drivers/pipewire.c | 28 +- audio/drivers/ps2_audio.c | 6 +- audio/drivers/ps3_audio.c | 15 +- audio/drivers/psp_audio.c | 13 +- audio/drivers/roar.c | 10 +- audio/drivers/rsound.c | 8 +- audio/drivers/sdl_audio.c | 65 ++-- audio/drivers/switch_audio.c | 4 +- audio/drivers/switch_libnx_audren_audio.c | 14 +- .../switch_libnx_audren_thread_audio.c | 10 +- audio/drivers/switch_thread_audio.c | 8 +- audio/drivers/tinyalsa.c | 4 +- audio/drivers/wasapi.c | 29 +- audio/drivers/wiiu_audio.c | 10 +- audio/drivers/xaudio.c | 12 +- audio/drivers/xenon360_audio.c | 12 +- audio/drivers_microphone/alsa.c | 111 +++--- audio/drivers_microphone/alsathread.c | 221 ++++++------ audio/drivers_microphone/pipewire.c | 308 ++++++++--------- audio/drivers_microphone/sdl_microphone.c | 210 ++++++----- audio/drivers_microphone/wasapi.c | 325 ++++++++---------- input/drivers/udev_input.c | 12 +- input/drivers_hid/iohidmanager_hid.c | 12 +- input/drivers_hid/libusb_hid.c | 16 +- input/drivers_hid/wiiusb_hid.c | 21 +- input/drivers_keyboard/keyboard_event_xkb.c | 12 +- input/input_driver.c | 20 +- input/input_osk.h | 2 +- libretro-db/query.c | 231 ++++++------- memory/wii/mem2_manager.c | 40 +-- menu/cbs/menu_cbs_ok.c | 16 +- menu/drivers/materialui.c | 227 +++++------- menu/drivers/ozone.c | 23 +- menu/drivers/rgui.c | 39 +-- menu/drivers/xmb.c | 24 +- menu/menu_contentless_cores.c | 4 +- menu/menu_displaylist.c | 118 +++---- menu/menu_driver.c | 32 +- menu/menu_explore.c | 2 +- menu/menu_screensaver.c | 18 +- menu/menu_setting.c | 141 +++----- network/cloud_sync/webdav.c | 12 +- 55 files changed, 1212 insertions(+), 1497 deletions(-) diff --git a/audio/drivers/alsa.c b/audio/drivers/alsa.c index 9200d70e1f6f..9748c20e2562 100644 --- a/audio/drivers/alsa.c +++ b/audio/drivers/alsa.c @@ -73,14 +73,36 @@ static void *alsa_init(const char *device, unsigned rate, unsigned latency, #define BYTES_TO_FRAMES(bytes, frame_bits) ((bytes) * 8 / frame_bits) #define FRAMES_TO_BYTES(frames, frame_bits) ((frames) * frame_bits / 8) -static bool alsa_start(void *data, bool is_shutdown); -static ssize_t alsa_write(void *data, const void *buf_, size_t size_) +static bool alsa_start(void *data, bool is_shutdown) { - alsa_t *alsa = (alsa_t*)data; - const uint8_t *buf = (const uint8_t*)buf_; - snd_pcm_sframes_t written = 0; - snd_pcm_sframes_t size = BYTES_TO_FRAMES(size_, alsa->stream_info.frame_bits); - size_t frames_size = alsa->stream_info.has_float ? sizeof(float) : sizeof(int16_t); + alsa_t *alsa = (alsa_t*)data; + if (!alsa->is_paused) + return true; + + if ( alsa->stream_info.can_pause + && alsa->is_paused) + { + int ret = snd_pcm_pause(alsa->pcm, 0); + + if (ret < 0) + { + RARCH_ERR("[ALSA]: Failed to unpause: %s.\n", + snd_strerror(ret)); + return false; + } + + alsa->is_paused = false; + } + return true; +} + +static ssize_t alsa_write(void *data, const void *buf_, size_t len) +{ + ssize_t written = 0; + alsa_t *alsa = (alsa_t*)data; + const uint8_t *buf = (const uint8_t*)buf_; + snd_pcm_sframes_t size = BYTES_TO_FRAMES(len, alsa->stream_info.frame_bits); + size_t frames_size = alsa->stream_info.has_float ? sizeof(float) : sizeof(int16_t); /* Workaround buggy menu code. * If a write happens while we're paused, we might never progress. */ @@ -192,29 +214,6 @@ static void alsa_set_nonblock_state(void *data, bool state) alsa->nonblock = state; } -static bool alsa_start(void *data, bool is_shutdown) -{ - alsa_t *alsa = (alsa_t*)data; - if (!alsa->is_paused) - return true; - - if (alsa->stream_info.can_pause - && alsa->is_paused) - { - int ret = snd_pcm_pause(alsa->pcm, 0); - - if (ret < 0) - { - RARCH_ERR("[ALSA]: Failed to unpause: %s.\n", - snd_strerror(ret)); - return false; - } - - alsa->is_paused = false; - } - return true; -} - static void alsa_free(void *data) { alsa_t *alsa = (alsa_t*)data; diff --git a/audio/drivers/alsa_qsa.c b/audio/drivers/alsa_qsa.c index f78c490d6e53..73cab726fe99 100644 --- a/audio/drivers/alsa_qsa.c +++ b/audio/drivers/alsa_qsa.c @@ -219,14 +219,14 @@ static int check_pcm_status(void *data, int channel_type) return ret; } -static ssize_t alsa_qsa_write(void *data, const void *buf, size_t size) +static ssize_t alsa_qsa_write(void *data, const void *buf, size_t len) { - alsa_qsa_t *alsa = (alsa_qsa_t*)data; - snd_pcm_sframes_t written = 0; + alsa_qsa_t *alsa = (alsa_qsa_t*)data; + ssize_t written = 0; while (size) { - size_t avail_write = MIN(alsa->buf_size - alsa->buffer_ptr, size); + size_t avail_write = MIN(alsa->buf_size - alsa->buffer_ptr, len); if (avail_write) { @@ -235,7 +235,7 @@ static ssize_t alsa_qsa_write(void *data, const void *buf, size_t size) alsa->buffer_ptr += avail_write; buf = (void*)((uint8_t*)buf + avail_write); - size -= avail_write; + len -= avail_write; written += avail_write; } @@ -260,7 +260,6 @@ static ssize_t alsa_qsa_write(void *data, const void *buf, size_t size) return -1; } } - } return written; diff --git a/audio/drivers/alsathread.c b/audio/drivers/alsathread.c index 030f23dad03a..c836a9aeec6f 100644 --- a/audio/drivers/alsathread.c +++ b/audio/drivers/alsathread.c @@ -157,8 +157,9 @@ static void *alsa_thread_init(const char *device, return NULL; } -static ssize_t alsa_thread_write(void *data, const void *buf, size_t size) +static ssize_t alsa_thread_write(void *data, const void *buf, size_t len) { + ssize_t written = 0; alsa_thread_t *alsa = (alsa_thread_t*)data; if (alsa->info.thread_dead) @@ -167,21 +168,17 @@ static ssize_t alsa_thread_write(void *data, const void *buf, size_t size) if (alsa->nonblock) { size_t avail; - size_t write_amt; slock_lock(alsa->info.fifo_lock); avail = FIFO_WRITE_AVAIL(alsa->info.buffer); - write_amt = MIN(avail, size); + written = MIN(avail, len); - fifo_write(alsa->info.buffer, buf, write_amt); + fifo_write(alsa->info.buffer, buf, written); slock_unlock(alsa->info.fifo_lock); - - return write_amt; } else { - size_t written = 0; - while (written < size && !alsa->info.thread_dead) + while (written < len && !alsa->info.thread_dead) { size_t avail; slock_lock(alsa->info.fifo_lock); @@ -197,15 +194,15 @@ static ssize_t alsa_thread_write(void *data, const void *buf, size_t size) } else { - size_t write_amt = MIN(size - written, avail); + size_t write_amt = MIN(len - written, avail); fifo_write(alsa->info.buffer, (const char*)buf + written, write_amt); slock_unlock(alsa->info.fifo_lock); written += write_amt; } } - return written; } + return written; } static bool alsa_thread_alive(void *data) diff --git a/audio/drivers/audioio.c b/audio/drivers/audioio.c index 8176a0d7b4d3..bec10582e54b 100644 --- a/audio/drivers/audioio.c +++ b/audio/drivers/audioio.c @@ -82,15 +82,15 @@ static void *audioio_init(const char *device, unsigned rate, unsigned latency, return NULL; } -static ssize_t audioio_write(void *data, const void *buf, size_t size) +static ssize_t audioio_write(void *data, const void *buf, size_t len) { - ssize_t ret; + ssize_t written; int *fd = (int*)data; - if (size == 0) + if (len == 0) return 0; - if ((ret = write(*fd, buf, size)) < 0) + if ((written = write(*fd, buf, len)) < 0) { if (errno == EAGAIN && (fcntl(*fd, F_GETFL) & O_NONBLOCK)) return 0; @@ -98,7 +98,7 @@ static ssize_t audioio_write(void *data, const void *buf, size_t size) return -1; } - return ret; + return written; } static bool audioio_stop(void *data) diff --git a/audio/drivers/coreaudio.c b/audio/drivers/coreaudio.c index b950937f7d24..3d84a13fd89c 100644 --- a/audio/drivers/coreaudio.c +++ b/audio/drivers/coreaudio.c @@ -312,26 +312,26 @@ static void *coreaudio_init(const char *device, return NULL; } -static ssize_t coreaudio_write(void *data, const void *buf_, size_t size) +static ssize_t coreaudio_write(void *data, const void *buf_, size_t len) { coreaudio_t *dev = (coreaudio_t*)data; const uint8_t *buf = (const uint8_t*)buf_; size_t written = 0; - while (!dev->is_paused && size > 0) + while (!dev->is_paused && len > 0) { size_t write_avail; slock_lock(dev->lock); write_avail = FIFO_WRITE_AVAIL(dev->buffer); - if (write_avail > size) - write_avail = size; + if (write_avail > len) + write_avail = len; fifo_write(dev->buffer, buf, write_avail); buf += write_avail; written += write_avail; - size -= write_avail; + len -= write_avail; if (dev->nonblock) { @@ -409,16 +409,9 @@ static size_t coreaudio_buffer_size(void *data) return dev->buffer_size; } -static void *coreaudio_device_list_new(void *data) -{ - /* TODO/FIXME */ - return NULL; -} - -static void coreaudio_device_list_free(void *data, void *array_list_data) -{ - /* TODO/FIXME */ -} +/* TODO/FIXME - implement */ +static void *coreaudio_device_list_new(void *data) { return NULL; } +static void coreaudio_device_list_free(void *data, void *array_list_data) { } audio_driver_t audio_coreaudio = { coreaudio_init, diff --git a/audio/drivers/coreaudio3.m b/audio/drivers/coreaudio3.m index 3b28e5f61d61..c8838d9e90c7 100644 --- a/audio/drivers/coreaudio3.m +++ b/audio/drivers/coreaudio3.m @@ -307,12 +307,11 @@ static void coreaudio3_free(void *data) return (__bridge_retained void *)dev; } -static ssize_t coreaudio3_write(void *data, - const void *buf_, size_t size) +static ssize_t coreaudio3_write(void *data, const void *buf_, size_t len) { CoreAudio3 *dev = (__bridge CoreAudio3 *)data; return [dev writeFloat:(const float *) - buf_ samples:size/sizeof(float)] * sizeof(float); + buf_ samples:len / sizeof(float)] * sizeof(float); } static void coreaudio3_set_nonblock_state(void *data, bool state) diff --git a/audio/drivers/ctr_csnd_audio.c b/audio/drivers/ctr_csnd_audio.c index e751be305282..b47484a1377b 100644 --- a/audio/drivers/ctr_csnd_audio.c +++ b/audio/drivers/ctr_csnd_audio.c @@ -162,19 +162,19 @@ static void ctr_csnd_audio_free(void *data) free(ctr); } -static ssize_t ctr_csnd_audio_write(void *data, const void *buf, size_t size) +static ssize_t ctr_csnd_audio_write(void *data, const void *buf, size_t len) { int i; - uint32_t samples_played = 0; - uint64_t current_tick = 0; - const uint16_t *src = buf; - ctr_csnd_audio_t *ctr = (ctr_csnd_audio_t*)data; + uint32_t samples_played = 0; + uint64_t current_tick = 0; + const uint16_t *src = buf; + ctr_csnd_audio_t *ctr = (ctr_csnd_audio_t*)data; ctr_csnd_audio_update_playpos(ctr); - if ((((ctr->playpos - ctr->pos) & CTR_CSND_AUDIO_COUNT_MASK) < (CTR_CSND_AUDIO_COUNT >> 2)) || - (((ctr->pos - ctr->playpos ) & CTR_CSND_AUDIO_COUNT_MASK) < (CTR_CSND_AUDIO_COUNT >> 4)) || - (((ctr->playpos - ctr->pos) & CTR_CSND_AUDIO_COUNT_MASK) < (size >> 2))) + if ( (((ctr->playpos - ctr->pos) & CTR_CSND_AUDIO_COUNT_MASK) < (CTR_CSND_AUDIO_COUNT >> 2)) + || (((ctr->pos - ctr->playpos) & CTR_CSND_AUDIO_COUNT_MASK) < (CTR_CSND_AUDIO_COUNT >> 4)) + || (((ctr->playpos - ctr->pos) & CTR_CSND_AUDIO_COUNT_MASK) < (len >> 2))) { if (ctr->nonblock) ctr->pos = (ctr->playpos + (CTR_CSND_AUDIO_COUNT >> 1)) & CTR_CSND_AUDIO_COUNT_MASK; @@ -189,7 +189,7 @@ static ssize_t ctr_csnd_audio_write(void *data, const void *buf, size_t size) } } - for (i = 0; i < (size >> 1); i += 2) + for (i = 0; i < (len >> 1); i += 2) { ctr->l[ctr->pos] = src[i]; ctr->r[ctr->pos] = src[i + 1]; @@ -200,7 +200,7 @@ static ssize_t ctr_csnd_audio_write(void *data, const void *buf, size_t size) GSPGPU_FlushDataCache(ctr->l, CTR_CSND_AUDIO_SIZE); GSPGPU_FlushDataCache(ctr->r, CTR_CSND_AUDIO_SIZE); - return size; + return len; } static bool ctr_csnd_audio_stop(void *data) @@ -264,11 +264,7 @@ static void ctr_csnd_audio_set_nonblock_state(void *data, bool state) ctr->nonblock = state; } -static bool ctr_csnd_audio_use_float(void *data) -{ - (void)data; - return false; -} +static bool ctr_csnd_audio_use_float(void *data) { return false; } static size_t ctr_csnd_audio_write_avail(void *data) { diff --git a/audio/drivers/ctr_dsp_audio.c b/audio/drivers/ctr_dsp_audio.c index 9cc165be92a9..ce7cbc27affe 100644 --- a/audio/drivers/ctr_dsp_audio.c +++ b/audio/drivers/ctr_dsp_audio.c @@ -91,15 +91,15 @@ static void ctr_dsp_audio_free(void *data) ndspExit(); } -static ssize_t ctr_dsp_audio_write(void *data, const void *buf, size_t size) +static ssize_t ctr_dsp_audio_write(void *data, const void *buf, size_t len) { u32 pos; - ctr_dsp_audio_t * ctr = (ctr_dsp_audio_t*)data; - uint32_t sample_pos = ndspChnGetSamplePos(ctr->channel); + ctr_dsp_audio_t *ctr = (ctr_dsp_audio_t*)data; + uint32_t sample_pos = ndspChnGetSamplePos(ctr->channel); - if ((((sample_pos - ctr->pos) & CTR_DSP_AUDIO_COUNT_MASK) < (CTR_DSP_AUDIO_COUNT >> 2)) || - (((ctr->pos - sample_pos ) & CTR_DSP_AUDIO_COUNT_MASK) < (CTR_DSP_AUDIO_COUNT >> 4)) || - (((sample_pos - ctr->pos) & CTR_DSP_AUDIO_COUNT_MASK) < (size >> 2))) + if ( (((sample_pos - ctr->pos) & CTR_DSP_AUDIO_COUNT_MASK) < (CTR_DSP_AUDIO_COUNT >> 2)) + || (((ctr->pos - sample_pos) & CTR_DSP_AUDIO_COUNT_MASK) < (CTR_DSP_AUDIO_COUNT >> 4)) + || (((sample_pos - ctr->pos) & CTR_DSP_AUDIO_COUNT_MASK) < (len >> 2))) { if (ctr->nonblock) ctr->pos = (sample_pos + (CTR_DSP_AUDIO_COUNT >> 1)) & CTR_DSP_AUDIO_COUNT_MASK; @@ -118,33 +118,33 @@ static ssize_t ctr_dsp_audio_write(void *data, const void *buf, size_t size) } sample_pos = ndspChnGetSamplePos(ctr->channel); - }while ( ((sample_pos - (ctr->pos + (size >>2))) & CTR_DSP_AUDIO_COUNT_MASK) > (CTR_DSP_AUDIO_COUNT >> 1) + }while ( ((sample_pos - (ctr->pos + (len >>2))) & CTR_DSP_AUDIO_COUNT_MASK) > (CTR_DSP_AUDIO_COUNT >> 1) || (((ctr->pos - (CTR_DSP_AUDIO_COUNT >> 4) - sample_pos) & CTR_DSP_AUDIO_COUNT_MASK) > (CTR_DSP_AUDIO_COUNT >> 1))); } } pos = ctr->pos << 2; - if ((pos + size) > CTR_DSP_AUDIO_SIZE) + if ((pos + len) > CTR_DSP_AUDIO_SIZE) { memcpy(ctr->dsp_buf.data_pcm8 + pos, buf, (CTR_DSP_AUDIO_SIZE - pos)); DSP_FlushDataCache(ctr->dsp_buf.data_pcm8 + pos, (CTR_DSP_AUDIO_SIZE - pos)); memcpy(ctr->dsp_buf.data_pcm8, (uint8_t*) buf + (CTR_DSP_AUDIO_SIZE - pos), - (pos + size - CTR_DSP_AUDIO_SIZE)); - DSP_FlushDataCache(ctr->dsp_buf.data_pcm8, (pos + size - CTR_DSP_AUDIO_SIZE)); + (pos + len - CTR_DSP_AUDIO_SIZE)); + DSP_FlushDataCache(ctr->dsp_buf.data_pcm8, (pos + len - CTR_DSP_AUDIO_SIZE)); } else { - memcpy(ctr->dsp_buf.data_pcm8 + pos, buf, size); - DSP_FlushDataCache(ctr->dsp_buf.data_pcm8 + pos, size); + memcpy(ctr->dsp_buf.data_pcm8 + pos, buf, len); + DSP_FlushDataCache(ctr->dsp_buf.data_pcm8 + pos, len); } - ctr->pos += size >> 2; + ctr->pos += len >> 2; ctr->pos &= CTR_DSP_AUDIO_COUNT_MASK; - return size; + return len; } static bool ctr_dsp_audio_stop(void *data) @@ -185,11 +185,7 @@ static void ctr_dsp_audio_set_nonblock_state(void *data, bool state) ctr->nonblock = state; } -static bool ctr_dsp_audio_use_float(void *data) -{ - (void)data; - return false; -} +static bool ctr_dsp_audio_use_float(void *data) { return false; } static size_t ctr_dsp_audio_write_avail(void *data) { diff --git a/audio/drivers/ctr_dsp_thread_audio.c b/audio/drivers/ctr_dsp_thread_audio.c index 458695113a5f..4f5ffb0618e8 100644 --- a/audio/drivers/ctr_dsp_thread_audio.c +++ b/audio/drivers/ctr_dsp_thread_audio.c @@ -198,7 +198,7 @@ static void ctr_dsp_thread_audio_free(void *data) ctr = NULL; } -static ssize_t ctr_dsp_thread_audio_write(void *data, const void *buf, size_t size) +static ssize_t ctr_dsp_thread_audio_write(void *data, const void *buf, size_t len) { size_t avail, written; ctr_dsp_thread_audio_t * ctr = (ctr_dsp_thread_audio_t*)data; @@ -210,7 +210,7 @@ static ssize_t ctr_dsp_thread_audio_write(void *data, const void *buf, size_t si { slock_lock(ctr->fifo_lock); avail = FIFO_WRITE_AVAIL(ctr->fifo); - written = MIN(avail, size); + written = MIN(avail, len); if (written > 0) { fifo_write(ctr->fifo, buf, written); @@ -221,7 +221,7 @@ static ssize_t ctr_dsp_thread_audio_write(void *data, const void *buf, size_t si else { written = 0; - while (written < size && ctr->running) + while (written < len && ctr->running) { slock_lock(ctr->fifo_lock); avail = FIFO_WRITE_AVAIL(ctr->fifo); @@ -240,7 +240,7 @@ static ssize_t ctr_dsp_thread_audio_write(void *data, const void *buf, size_t si } else { - size_t write_amt = MIN(size - written, avail); + size_t write_amt = MIN(len - written, avail); fifo_write(ctr->fifo, (const char*)buf + written, write_amt); scond_signal(ctr->fifo_avail); slock_unlock(ctr->fifo_lock); diff --git a/audio/drivers/dsound.c b/audio/drivers/dsound.c index 000540540f39..f61335ba8771 100644 --- a/audio/drivers/dsound.c +++ b/audio/drivers/dsound.c @@ -205,7 +205,7 @@ static DWORD CALLBACK dsound_thread(PVOID data) IDirectSoundBuffer_Unlock(ds->dsb, region.chunk1, region.size1, region.chunk2, region.size2); - write_ptr = (write_ptr + region.size1 + region.size2) + write_ptr = (write_ptr + region.size1 + region.size2) % ds->buffer_size; if (is_pull) @@ -501,7 +501,7 @@ static void dsound_set_nonblock_state(void *data, bool state) ds->nonblock = state; } -static ssize_t dsound_write(void *data, const void *buf_, size_t size) +static ssize_t dsound_write(void *data, const void *buf_, size_t len) { size_t written = 0; dsound_t *ds = (dsound_t*)data; @@ -512,39 +512,39 @@ static ssize_t dsound_write(void *data, const void *buf_, size_t size) if (ds->nonblock) { - if (size > 0) + if (len > 0) { size_t avail; EnterCriticalSection(&ds->crit); avail = FIFO_WRITE_AVAIL(ds->buffer); - if (avail > size) - avail = size; + if (avail > len) + avail = len; fifo_write(ds->buffer, buf, avail); LeaveCriticalSection(&ds->crit); buf += avail; - size -= avail; + len -= avail; written += avail; } } else { - while (size > 0) + while (len > 0) { size_t avail; EnterCriticalSection(&ds->crit); avail = FIFO_WRITE_AVAIL(ds->buffer); - if (avail > size) - avail = size; + if (avail > len) + avail = len; fifo_write(ds->buffer, buf, avail); LeaveCriticalSection(&ds->crit); buf += avail; - size -= avail; + len -= avail; written += avail; if (!ds->thread_alive) diff --git a/audio/drivers/gx_audio.c b/audio/drivers/gx_audio.c index f594863b9815..aae3cdf1b45f 100644 --- a/audio/drivers/gx_audio.c +++ b/audio/drivers/gx_audio.c @@ -79,7 +79,7 @@ static void *gx_audio_init(const char *device, AIInit(NULL); AIRegisterDMACallback(dma_callback); - /* Ranges 0-32000 (default low) and 40000-47999 + /* Ranges 0-32000 (default low) and 40000-47999 (in settings going down from 48000) -> set to 32000 hz */ if (rate <= 32000 || (rate >= 40000 && rate < 48000)) { @@ -103,18 +103,18 @@ static void *gx_audio_init(const char *device, /* Wii uses silly R, L, R, L interleaving. */ static INLINE void copy_swapped(uint32_t * restrict dst, - const uint32_t * restrict src, size_t size) + const uint32_t * restrict src, size_t len) { do { uint32_t s = *src++; *dst++ = (s >> 16) | (s << 16); - } while (--size); + } while (--len); } -static ssize_t gx_audio_write(void *data, const void *buf_, size_t size) +static ssize_t gx_audio_write(void *data, const void *buf_, size_t len) { - size_t frames = size >> 2; + size_t frames = len >> 2; const uint32_t *buf = buf_; gx_audio_t *wa = data; @@ -142,8 +142,7 @@ static ssize_t gx_audio_write(void *data, const void *buf_, size_t size) wa->dma_write = (wa->dma_write + 1) & (BLOCKS - 1); } } - - return size; + return len; } static bool gx_audio_stop(void *data) @@ -209,18 +208,9 @@ static size_t gx_audio_write_avail(void *data) & (BLOCKS - 1)) * CHUNK_SIZE; } -static size_t gx_audio_buffer_size(void *data) -{ - (void)data; - return BLOCKS * CHUNK_SIZE; -} - -static bool gx_audio_use_float(void *data) -{ - /* TODO/FIXME - verify */ - (void)data; - return false; -} +static size_t gx_audio_buffer_size(void *data) { return BLOCKS * CHUNK_SIZE; } +/* TODO/FIXME - implement/verify? */ +static bool gx_audio_use_float(void *data) { return false; } audio_driver_t audio_gx = { gx_audio_init, diff --git a/audio/drivers/jack.c b/audio/drivers/jack.c index 6d199067e252..c581cb72688c 100644 --- a/audio/drivers/jack.c +++ b/audio/drivers/jack.c @@ -252,13 +252,13 @@ static void *ja_init(const char *device, return NULL; } -static ssize_t ja_write(void *data, const void *buf_, size_t size) +static ssize_t ja_write(void *data, const void *buf_, size_t len) { jack_t *jd = (jack_t*)data; const char *buf = (const char *)buf_; size_t written = 0; - while (size > 0) + while (len > 0) { size_t avail, to_write; @@ -267,7 +267,7 @@ static ssize_t ja_write(void *data, const void *buf_, size_t size) avail = jack_ringbuffer_write_space(jd->buffer); - to_write = size < avail ? size : avail; + to_write = (len < avail) ? len : avail; /* make sure to only write multiples of the sample size */ to_write = (to_write / sizeof(float)) * sizeof(float); @@ -275,7 +275,7 @@ static ssize_t ja_write(void *data, const void *buf_, size_t size) { jack_ringbuffer_write(jd->buffer, buf, to_write); buf += to_write; - size -= to_write; + len -= to_write; written += to_write; } else if (!jd->nonblock) @@ -350,11 +350,7 @@ static void ja_free(void *data) free(jd); } -static bool ja_use_float(void *data) -{ - (void)data; - return true; -} +static bool ja_use_float(void *data) { return true; } static size_t ja_write_avail(void *data) { diff --git a/audio/drivers/oss.c b/audio/drivers/oss.c index 52b525ac34a6..70cf801f97a7 100644 --- a/audio/drivers/oss.c +++ b/audio/drivers/oss.c @@ -103,15 +103,15 @@ static void *oss_init(const char *device, return NULL; } -static ssize_t oss_write(void *data, const void *buf, size_t size) +static ssize_t oss_write(void *data, const void *buf, size_t len) { ssize_t ret; oss_audio_t *ossaudio = (oss_audio_t*)data; - if (size == 0) + if (len == 0) return 0; - if ((ret = write(ossaudio->fd, buf, size)) < 0) + if ((ret = write(ossaudio->fd, buf, len)) < 0) { if (errno == EAGAIN && (fcntl(ossaudio->fd, F_GETFL) & O_NONBLOCK)) return 0; @@ -169,7 +169,7 @@ static void oss_free(void *data) { oss_audio_t *ossaudio = (oss_audio_t*)data; -/*RETROFW IOCTL always returns EINVAL*/ +/*RETROFW IOCTL always returns EINVAL*/ #if !defined(RETROFW) if (ioctl(ossaudio->fd, SNDCTL_DSP_RESET, 0) < 0) return; @@ -209,7 +209,6 @@ static size_t oss_buffer_size(void *data) static bool oss_use_float(void *data) { - (void)data; return false; } diff --git a/audio/drivers/pipewire.c b/audio/drivers/pipewire.c index 45142948d5e2..c819dd0a196f 100644 --- a/audio/drivers/pipewire.c +++ b/audio/drivers/pipewire.c @@ -278,7 +278,7 @@ static void *pipewire_init(const char *device, unsigned rate, return NULL; } -static ssize_t pipewire_write(void *data, const void *buf_, size_t size) +static ssize_t pipewire_write(void *data, const void *buf_, size_t len) { int32_t filled, avail; uint32_t idx; @@ -288,7 +288,7 @@ static ssize_t pipewire_write(void *data, const void *buf_, size_t size) if (pw_stream_get_state(audio->stream, &error) != PW_STREAM_STATE_STREAMING) return 0; /* wait for stream to become ready */ - if (size > audio->highwater_mark) + if (len > audio->highwater_mark) { RARCH_ERR("[PipeWire]: Buffer too small! Please try increasing the latency.\n"); return 0; @@ -296,23 +296,23 @@ static ssize_t pipewire_write(void *data, const void *buf_, size_t size) pw_thread_loop_lock(audio->pw->thread_loop); - while (size) + while (len) { filled = spa_ringbuffer_get_write_index(&audio->ring, &idx); avail = audio->highwater_mark - filled; #if 0 /* Useful for tracing */ RARCH_DBG("[PipeWire]: Ringbuffer utilization: filled %d, avail %d, index %d, size %d\n", - filled, avail, idx, size); + filled, avail, idx, len); #endif /* in non-blocking mode we play as much as we can * in blocking mode we expect a freed buffer of at least the given size */ - if (size > (size_t)avail) + if (len > (size_t)avail) { if (audio->pw->nonblock) { - size = avail; + len = avail; break; } @@ -326,21 +326,21 @@ static ssize_t pipewire_write(void *data, const void *buf_, size_t size) RARCH_ERR("[Pipewire]: %p: underrun write:%u filled:%d\n", audio, idx, filled); else { - if ((uint32_t) filled + size > RINGBUFFER_SIZE) + if ((uint32_t) filled + len > RINGBUFFER_SIZE) { RARCH_ERR("[PipeWire]: %p: overrun write:%u filled:%d + size:%zu > max:%u\n", - audio, idx, filled, size, RINGBUFFER_SIZE); + audio, idx, filled, len, RINGBUFFER_SIZE); } } spa_ringbuffer_write_data(&audio->ring, audio->buffer, RINGBUFFER_SIZE, - idx & RINGBUFFER_MASK, buf_, size); - idx += size; + idx & RINGBUFFER_MASK, buf_, len); + idx += len; spa_ringbuffer_write_update(&audio->ring, idx); pw_thread_loop_unlock(audio->pw->thread_loop); - return size; + return len; } static bool pipewire_stop(void *data) @@ -426,11 +426,7 @@ static void pipewire_free(void *data) pw_deinit(); } -static bool pipewire_use_float(void *data) -{ - (void)data; - return true; -} +static bool pipewire_use_float(void *data) { return true; } static void *pipewire_device_list_new(void *data) { diff --git a/audio/drivers/ps2_audio.c b/audio/drivers/ps2_audio.c index 786b2a49b429..d073d1aa766f 100644 --- a/audio/drivers/ps2_audio.c +++ b/audio/drivers/ps2_audio.c @@ -71,14 +71,12 @@ static void ps2_audio_free(void *data) free(ps2); } -static ssize_t ps2_audio_write(void *data, const void *buf, size_t size) +static ssize_t ps2_audio_write(void *data, const void *buf, size_t len) { ps2_audio_t* ps2 = (ps2_audio_t*)data; - if (!ps2->running) return -1; - - return audsrv_play_audio(buf, size); + return audsrv_play_audio(buf, len); } static bool ps2_audio_alive(void *data) diff --git a/audio/drivers/ps3_audio.c b/audio/drivers/ps3_audio.c index da7a82345bca..eb2c9a08c811 100644 --- a/audio/drivers/ps3_audio.c +++ b/audio/drivers/ps3_audio.c @@ -142,24 +142,24 @@ static void *ps3_audio_init(const char *device, return data; } -static ssize_t ps3_audio_write(void *data, const void *buf, size_t size) +static ssize_t ps3_audio_write(void *data, const void *buf, size_t len) { ps3_audio_t *aud = data; if (aud->nonblock) { - if (FIFO_WRITE_AVAIL(aud->buffer) < size) + if (FIFO_WRITE_AVAIL(aud->buffer) < len) return 0; } - while (FIFO_WRITE_AVAIL(aud->buffer) < size) + while (FIFO_WRITE_AVAIL(aud->buffer) < len) sysLwCondWait(&aud->cond, 0); sysLwMutexLock(&aud->lock, PS3_SYS_NO_TIMEOUT); - fifo_write(aud->buffer, buf, size); + fifo_write(aud->buffer, buf, len); sysLwMutexUnlock(&aud->lock); - return size; + return len; } static bool ps3_audio_stop(void *data) @@ -220,10 +220,7 @@ static void ps3_audio_free(void *data) free(data); } -static bool ps3_audio_use_float(void *data) -{ - return true; -} +static bool ps3_audio_use_float(void *data) { return true; } static size_t ps3_audio_write_avail(void *data) { diff --git a/audio/drivers/psp_audio.c b/audio/drivers/psp_audio.c index e6f8e2c17431..7a2e29aa1af6 100644 --- a/audio/drivers/psp_audio.c +++ b/audio/drivers/psp_audio.c @@ -202,11 +202,11 @@ static void psp_audio_free(void *data) } -static ssize_t psp_audio_write(void *data, const void *buf, size_t size) +static ssize_t psp_audio_write(void *data, const void *buf, size_t len) { psp_audio_t* psp = (psp_audio_t*)data; uint16_t write_pos = psp->write_pos; - uint16_t sampleCount = size / sizeof(uint32_t); + uint16_t sampleCount = len / sizeof(uint32_t); if (!psp->running) return -1; @@ -214,13 +214,13 @@ static ssize_t psp_audio_write(void *data, const void *buf, size_t size) if (psp->nonblock) { if (AUDIO_BUFFER_SIZE - ((uint16_t) - (psp->write_pos - psp->read_pos) & AUDIO_BUFFER_SIZE_MASK) < size) + (psp->write_pos - psp->read_pos) & AUDIO_BUFFER_SIZE_MASK) < len) return 0; } slock_lock(psp->cond_lock); while (AUDIO_BUFFER_SIZE - ((uint16_t) - (psp->write_pos - psp->read_pos) & AUDIO_BUFFER_SIZE_MASK) < size) + (psp->write_pos - psp->read_pos) & AUDIO_BUFFER_SIZE_MASK) < len) scond_wait(psp->cond, psp->cond_lock); slock_unlock(psp->cond_lock); @@ -234,15 +234,14 @@ static ssize_t psp_audio_write(void *data, const void *buf, size_t size) (write_pos + sampleCount - AUDIO_BUFFER_SIZE) * sizeof(uint32_t)); } else - memcpy(psp->buffer + write_pos, buf, size); + memcpy(psp->buffer + write_pos, buf, len); write_pos += sampleCount; write_pos &= AUDIO_BUFFER_SIZE_MASK; psp->write_pos = write_pos; slock_unlock(psp->fifo_lock); - return size; - + return len; } static bool psp_audio_alive(void *data) diff --git a/audio/drivers/roar.c b/audio/drivers/roar.c index 9110fdfb10c2..6e3a58bac94d 100644 --- a/audio/drivers/roar.c +++ b/audio/drivers/roar.c @@ -56,19 +56,19 @@ static void *ra_init(const char *device, unsigned rate, unsigned latency, return roar; } -static ssize_t ra_write(void *data, const void *buf, size_t size) +static ssize_t ra_write(void *data, const void *buf, size_t len) { int err; size_t written = 0; roar_t *roar = (roar_t*)data; - if (size == 0) + if (len == 0) return 0; - while (written < size) + while (written < len) { ssize_t rc; - size_t write_amt = size - written; + size_t write_amt = len - written; if ((rc = roar_vs_write(roar->vss, (const char*)buf + written, write_amt, &err)) < (ssize_t)write_amt) @@ -81,7 +81,7 @@ static ssize_t ra_write(void *data, const void *buf, size_t size) written += rc; } - return size; + return len; } static bool ra_stop(void *data) diff --git a/audio/drivers/rsound.c b/audio/drivers/rsound.c index fbc6f749a76a..4133d3d5052f 100644 --- a/audio/drivers/rsound.c +++ b/audio/drivers/rsound.c @@ -101,7 +101,7 @@ static void *rs_init(const char *device, unsigned rate, unsigned latency, return NULL; } -static ssize_t rs_write(void *data, const void *buf, size_t size) +static ssize_t rs_write(void *data, const void *buf, size_t len) { rsd_t *rsd = (rsd_t*)data; @@ -115,7 +115,7 @@ static ssize_t rs_write(void *data, const void *buf, size_t size) rsd_callback_lock(rsd->rd); avail = FIFO_WRITE_AVAIL(rsd->buffer); - write_amt = avail > size ? size : avail; + write_amt = avail > len ? len : avail; fifo_write(rsd->buffer, buf, write_amt); rsd_callback_unlock(rsd->rd); @@ -124,7 +124,7 @@ static ssize_t rs_write(void *data, const void *buf, size_t size) else { size_t written = 0; - while (written < size && !rsd->has_error) + while (written < len && !rsd->has_error) { size_t avail; rsd_callback_lock(rsd->rd); @@ -143,7 +143,7 @@ static ssize_t rs_write(void *data, const void *buf, size_t size) } else { - size_t write_amt = size - written > avail ? avail : size - written; + size_t write_amt = len - written > avail ? avail : len - written; fifo_write(rsd->buffer, (const char*)buf + written, write_amt); rsd_callback_unlock(rsd->rd); written += write_amt; diff --git a/audio/drivers/sdl_audio.c b/audio/drivers/sdl_audio.c index 998e9ff48fb5..3be72b79044f 100644 --- a/audio/drivers/sdl_audio.c +++ b/audio/drivers/sdl_audio.c @@ -82,30 +82,25 @@ static void sdl_audio_playback_cb(void *data, Uint8 *stream, int len) { sdl_audio_t *sdl = (sdl_audio_t*)data; size_t avail = FIFO_READ_AVAIL(sdl->speaker_buffer); - size_t write_size = (len > (int)avail) ? avail : (size_t)len; - - fifo_read(sdl->speaker_buffer, stream, write_size); + size_t _len = (len > (int)avail) ? avail : (size_t)len; + fifo_read(sdl->speaker_buffer, stream, _len); #ifdef HAVE_THREADS scond_signal(sdl->cond); #endif - /* If underrun, fill rest with silence. */ - memset(stream + write_size, 0, len - write_size); + memset(stream + _len, 0, len - _len); } static INLINE int sdl_audio_find_num_frames(int rate, int latency) { int frames = (rate * latency) / 1000; - /* SDL only likes 2^n sized buffers. */ - return next_pow2(frames); } static void *sdl_audio_init(const char *device, unsigned rate, unsigned latency, - unsigned block_frames, - unsigned *new_rate) + unsigned block_frames, unsigned *new_rate) { int frames; size_t bufsize; @@ -215,52 +210,52 @@ static void *sdl_audio_init(const char *device, return NULL; } -static ssize_t sdl_audio_write(void *data, const void *buf, size_t size) +static ssize_t sdl_audio_write(void *data, const void *buf, size_t len) { ssize_t ret = 0; sdl_audio_t *sdl = (sdl_audio_t*)data; + /* If we shouldn't wait for space in a full outgoing sample queue... */ if (sdl->nonblock) - { /* If we shouldn't wait for space in a full outgoing sample queue... */ + { size_t avail, write_amt; - SDL_LockAudioDevice(sdl->speaker_device); /* Stop the SDL speaker thread from running */ - avail = FIFO_WRITE_AVAIL(sdl->speaker_buffer); - write_amt = avail > size ? size : avail; /* Enqueue as much data as we can */ + avail = FIFO_WRITE_AVAIL(sdl->speaker_buffer); + write_amt = (avail > len) ? len : avail; /* Enqueue as much data as we can */ fifo_write(sdl->speaker_buffer, buf, write_amt); SDL_UnlockAudioDevice(sdl->speaker_device); /* Let the speaker thread run again */ - ret = write_amt; /* If the queue was full...well, too bad. */ + ret = write_amt; /* If the queue was full...well, too bad. */ } else { size_t written = 0; - - while (written < size) - { /* Until we've written all the sample data we have available... */ + /* Until we've written all the sample data we have available... */ + while (written < len) + { size_t avail; - SDL_LockAudioDevice(sdl->speaker_device); /* Stop the SDL speaker thread from running */ + /* Stop the SDL speaker thread from running */ + SDL_LockAudioDevice(sdl->speaker_device); avail = FIFO_WRITE_AVAIL(sdl->speaker_buffer); + /* If the outgoing sample queue is full... */ if (avail == 0) - { /* If the outgoing sample queue is full... */ + { SDL_UnlockAudioDevice(sdl->speaker_device); /* Let the SDL speaker thread run so it can play the enqueued samples, * which will free up space for us to write new ones. */ #ifdef HAVE_THREADS slock_lock(sdl->lock); /* Let *only* the SDL speaker thread touch the outgoing sample queue */ - scond_wait(sdl->cond, sdl->lock); /* Block until SDL tells us that it's made room for new samples */ - slock_unlock(sdl->lock); /* Now let this thread use the outgoing sample queue (which we'll do next iteration) */ #endif } else { - size_t write_amt = size - written > avail ? avail : size - written; + size_t write_amt = len - written > avail ? avail : len - written; fifo_write(sdl->speaker_buffer, (const char*)buf + written, write_amt); /* Enqueue as many samples as we have available without overflowing the queue */ SDL_UnlockAudioDevice(sdl->speaker_device); /* Let the SDL speaker thread run again */ @@ -276,9 +271,8 @@ static ssize_t sdl_audio_write(void *data, const void *buf, size_t size) static bool sdl_audio_stop(void *data) { sdl_audio_t *sdl = (sdl_audio_t*)data; - sdl->is_paused = true; + sdl->is_paused = true; SDL_PauseAudioDevice(sdl->speaker_device, true); - return true; } @@ -293,10 +287,8 @@ static bool sdl_audio_alive(void *data) static bool sdl_audio_start(void *data, bool is_shutdown) { sdl_audio_t *sdl = (sdl_audio_t*)data; - sdl->is_paused = false; - + sdl->is_paused = false; SDL_PauseAudioDevice(sdl->speaker_device, false); - return true; } @@ -319,9 +311,7 @@ static void sdl_audio_free(void *data) } if (sdl->speaker_buffer) - { fifo_free(sdl->speaker_buffer); - } #ifdef HAVE_THREADS slock_free(sdl->lock); @@ -333,18 +323,9 @@ static void sdl_audio_free(void *data) free(sdl); } -static bool sdl_audio_use_float(void *data) -{ - (void)data; - return false; -} - -static size_t sdl_audio_write_avail(void *data) -{ - /* stub */ - (void)data; - return 0; -} +/* TODO/FIXME - implement */ +static bool sdl_audio_use_float(void *data) { return false; } +static size_t sdl_audio_write_avail(void *data) { return 0; } audio_driver_t audio_sdl = { sdl_audio_init, diff --git a/audio/drivers/switch_audio.c b/audio/drivers/switch_audio.c index a2b6291ccbfc..c622e8ac063b 100644 --- a/audio/drivers/switch_audio.c +++ b/audio/drivers/switch_audio.c @@ -73,9 +73,9 @@ static size_t switch_audio_buffer_size(void *data) #endif } -static ssize_t switch_audio_write(void *data, const void *buf, size_t size) +static ssize_t switch_audio_write(void *data, const void *buf, size_t len) { - size_t to_write = size; + size_t to_write = len; switch_audio_t *swa = (switch_audio_t*) data; if (!swa) diff --git a/audio/drivers/switch_libnx_audren_audio.c b/audio/drivers/switch_libnx_audren_audio.c index 998a25a6a270..05fc0193f62d 100644 --- a/audio/drivers/switch_libnx_audren_audio.c +++ b/audio/drivers/switch_libnx_audren_audio.c @@ -186,7 +186,7 @@ static ssize_t libnx_audren_audio_get_free_wavebuf_idx(libnx_audren_t* aud) } static size_t libnx_audren_audio_append( - libnx_audren_t* aud, const void *buf, size_t size) + libnx_audren_t* aud, const void *buf, size_t len) { void *dstbuf = NULL; ssize_t free_idx = -1; @@ -202,14 +202,14 @@ static size_t libnx_audren_audio_append( aud->current_size = 0; } - if (size > aud->buffer_size - aud->current_size) - size = aud->buffer_size - aud->current_size; + if (len > aud->buffer_size - aud->current_size) + len = aud->buffer_size - aud->current_size; dstbuf = aud->current_pool_ptr + aud->current_size; - memcpy(dstbuf, buf, size); - armDCacheFlush(dstbuf, size); + memcpy(dstbuf, buf, len); + armDCacheFlush(dstbuf, len); - aud->current_size += size; + aud->current_size += len; if (aud->current_size == aud->buffer_size) { @@ -227,7 +227,7 @@ static size_t libnx_audren_audio_append( aud->current_wavebuf = NULL; } - return size; + return len; } static ssize_t libnx_audren_audio_write(void *data, diff --git a/audio/drivers/switch_libnx_audren_thread_audio.c b/audio/drivers/switch_libnx_audren_thread_audio.c index 286dbd1dc637..7b9073b15b0a 100644 --- a/audio/drivers/switch_libnx_audren_thread_audio.c +++ b/audio/drivers/switch_libnx_audren_thread_audio.c @@ -166,7 +166,7 @@ static void *libnx_audren_thread_audio_init(const char *device, unsigned rate, u aud->buffer_size = (real_latency * sample_rate / 1000); aud->samples = (aud->buffer_size / num_channels / sizeof(int16_t)); - mempool_size = (aud->buffer_size * BUFFER_COUNT + + mempool_size = (aud->buffer_size * BUFFER_COUNT + (AUDREN_MEMPOOL_ALIGNMENT-1)) &~ (AUDREN_MEMPOOL_ALIGNMENT-1); aud->mempool = memalign(AUDREN_MEMPOOL_ALIGNMENT, mempool_size); @@ -282,7 +282,7 @@ static size_t libnx_audren_thread_audio_buffer_size(void *data) } static ssize_t libnx_audren_thread_audio_write(void *data, - const void *buf, size_t size) + const void *buf, size_t len) { libnx_audren_thread_t *aud = (libnx_audren_thread_t*)data; size_t available, written, written_tmp; @@ -297,7 +297,7 @@ static ssize_t libnx_audren_thread_audio_write(void *data, { mutexLock(&aud->fifo_lock); available = FIFO_WRITE_AVAIL(aud->fifo); - written = MIN(available, size); + written = MIN(available, len); if (written > 0) fifo_write(aud->fifo, buf, written); mutexUnlock(&aud->fifo_lock); @@ -305,13 +305,13 @@ static ssize_t libnx_audren_thread_audio_write(void *data, else { written = 0; - while (written < size && aud->running) + while (written < len && aud->running) { mutexLock(&aud->fifo_lock); available = FIFO_WRITE_AVAIL(aud->fifo); if (available) { - written_tmp = MIN(size - written, available); + written_tmp = MIN(len - written, available); fifo_write(aud->fifo, (const char*)buf + written, written_tmp); mutexUnlock(&aud->fifo_lock); written += written_tmp; diff --git a/audio/drivers/switch_thread_audio.c b/audio/drivers/switch_thread_audio.c index 3a530b24f07d..37491f86f161 100644 --- a/audio/drivers/switch_thread_audio.c +++ b/audio/drivers/switch_thread_audio.c @@ -338,7 +338,7 @@ static void switch_thread_audio_free(void *data) swa = NULL; } -static ssize_t switch_thread_audio_write(void *data, const void *buf, size_t size) +static ssize_t switch_thread_audio_write(void *data, const void *buf, size_t len) { size_t avail, written; switch_thread_audio_t *swa = (switch_thread_audio_t *)data; @@ -350,7 +350,7 @@ static ssize_t switch_thread_audio_write(void *data, const void *buf, size_t siz { compat_mutex_lock(&swa->fifoLock); avail = FIFO_WRITE_AVAIL(swa->fifo); - written = MIN(avail, size); + written = MIN(avail, len); if (written > 0) fifo_write(swa->fifo, buf, written); compat_mutex_unlock(&swa->fifoLock); @@ -358,7 +358,7 @@ static ssize_t switch_thread_audio_write(void *data, const void *buf, size_t siz else { written = 0; - while (written < size && swa->running) + while (written < len && swa->running) { compat_mutex_lock(&swa->fifoLock); avail = FIFO_WRITE_AVAIL(swa->fifo); @@ -372,7 +372,7 @@ static ssize_t switch_thread_audio_write(void *data, const void *buf, size_t siz } else { - size_t write_amt = MIN(size - written, avail); + size_t write_amt = MIN(len - written, avail); fifo_write(swa->fifo, (const char*)buf + written, write_amt); compat_mutex_unlock(&swa->fifoLock); written += write_amt; diff --git a/audio/drivers/tinyalsa.c b/audio/drivers/tinyalsa.c index e701cd9047c7..5f87dc696b69 100644 --- a/audio/drivers/tinyalsa.c +++ b/audio/drivers/tinyalsa.c @@ -2275,12 +2275,12 @@ static void * tinyalsa_init(const char *devicestr, unsigned rate, } static ssize_t -tinyalsa_write(void *data, const void *buf_, size_t size_) +tinyalsa_write(void *data, const void *buf_, size_t len) { tinyalsa_t *tinyalsa = (tinyalsa_t*)data; const uint8_t *buf = (const uint8_t*)buf_; snd_pcm_sframes_t written = 0; - snd_pcm_sframes_t size = BYTES_TO_FRAMES(size_, tinyalsa->frame_bits); + snd_pcm_sframes_t size = BYTES_TO_FRAMES(len, tinyalsa->frame_bits); size_t frames_size = tinyalsa->has_float ? sizeof(float) : sizeof(int16_t); if (tinyalsa->nonblock) diff --git a/audio/drivers/wasapi.c b/audio/drivers/wasapi.c index 924bdf111b16..49f588010146 100644 --- a/audio/drivers/wasapi.c +++ b/audio/drivers/wasapi.c @@ -163,7 +163,7 @@ static void *wasapi_init(const char *dev_id, unsigned rate, unsigned latency, return NULL; } -static ssize_t wasapi_write(void *wh, const void *data, size_t size) +static ssize_t wasapi_write(void *wh, const void *data, size_t len) { size_t written = 0; wasapi_t *w = (wasapi_t*)wh; @@ -193,16 +193,16 @@ static ssize_t wasapi_write(void *wh, const void *data, size_t size) return -1; write_avail = w->engine_buffer_size; } - written = (size < write_avail) ? size : write_avail; + written = (len < write_avail) ? len : write_avail; fifo_write(w->buffer, data, written); } else { ssize_t ir; - for (ir = -1; written < size; written += ir) + for (ir = -1; written < len; written += ir) { const void *_data = (char*)data + written; - size_t __size = size - written; + size_t __len = len - written; size_t write_avail = FIFO_WRITE_AVAIL(w->buffer); if (!write_avail) { @@ -222,7 +222,7 @@ static ssize_t wasapi_write(void *wh, const void *data, size_t size) write_avail = w->engine_buffer_size; } } - ir = (__size < write_avail) ? __size : write_avail; + ir = (__len < write_avail) ? __len : write_avail; fifo_write(w->buffer, _data, ir); } } @@ -257,7 +257,7 @@ static ssize_t wasapi_write(void *wh, const void *data, size_t size) } } write_avail = FIFO_WRITE_AVAIL(w->buffer); - written = size < write_avail ? size : write_avail; + written = len < write_avail ? len : write_avail; if (written) fifo_write(w->buffer, data, written); } @@ -267,7 +267,7 @@ static ssize_t wasapi_write(void *wh, const void *data, size_t size) return -1; if (!(write_avail = w->engine_buffer_size - padding * w->frame_size)) return 0; - written = size < write_avail ? size : write_avail; + written = (len < write_avail) ? len : write_avail; if (written) { BYTE *dest = NULL; @@ -285,10 +285,10 @@ static ssize_t wasapi_write(void *wh, const void *data, size_t size) else if (w->buffer) { ssize_t ir; - for (ir = -1; written < size; written += ir) + for (ir = -1; written < len; written += ir) { const void *_data = (char*)data + written; - size_t _size = size - written; + size_t _len = len - written; size_t write_avail = FIFO_WRITE_AVAIL(w->buffer); UINT32 padding = 0; if (!write_avail) @@ -315,7 +315,7 @@ static ssize_t wasapi_write(void *wh, const void *data, size_t size) } } write_avail = FIFO_WRITE_AVAIL(w->buffer); - ir = (_size < write_avail) ? _size : write_avail; + ir = (_len < write_avail) ? _len : write_avail; if (ir) fifo_write(w->buffer, _data, ir); } @@ -323,10 +323,10 @@ static ssize_t wasapi_write(void *wh, const void *data, size_t size) else { ssize_t ir; - for (ir = -1; written < size; written += ir) + for (ir = -1; written < len; written += ir) { const void *_data = (char*)data + written; - size_t _size = size - written; + size_t _len = len - written; size_t write_avail = 0; UINT32 padding = 0; if (!(WaitForSingleObject(w->write_event, WASAPI_TIMEOUT) == WAIT_OBJECT_0)) @@ -337,7 +337,7 @@ static ssize_t wasapi_write(void *wh, const void *data, size_t size) ir = 0; else { - ir = (_size < write_avail) ? _size : write_avail; + ir = (_len < write_avail) ? _len : write_avail; if (ir) { BYTE *dest = NULL; @@ -427,8 +427,7 @@ static void wasapi_free(void *wh) static bool wasapi_use_float(void *wh) { wasapi_t *w = (wasapi_t*)wh; - - return w->frame_size == 8; + return (w->frame_size == 8); } static void wasapi_device_list_free(void *u, void *slp) diff --git a/audio/drivers/wiiu_audio.c b/audio/drivers/wiiu_audio.c index de5d3d93531c..6f8067dfa5af 100644 --- a/audio/drivers/wiiu_audio.c +++ b/audio/drivers/wiiu_audio.c @@ -194,23 +194,23 @@ static bool ax_audio_start(void* data, bool is_shutdown) return true; } -static ssize_t ax_audio_write(void* data, const void* buf, size_t size) +static ssize_t ax_audio_write(void* data, const void* buf, size_t len) { uint32_t i; size_t count_avail = 0; ax_audio_t* ax = (ax_audio_t*)data; const uint16_t* src = buf; - size_t count = size >> 2; + size_t count = len >> 2; - if (!size || (size & 0x3)) + if (!len || (len & 0x3)) return 0; if (count > AX_AUDIO_MAX_FREE) count = AX_AUDIO_MAX_FREE; count_avail = ( - (ax->written > AX_AUDIO_MAX_FREE) - ? 0 + (ax->written > AX_AUDIO_MAX_FREE) + ? 0 : (AX_AUDIO_MAX_FREE - ax->written)); if (ax->nonblock) diff --git a/audio/drivers/xaudio.c b/audio/drivers/xaudio.c index 23d0b6d1b038..47320d5c4759 100644 --- a/audio/drivers/xaudio.c +++ b/audio/drivers/xaudio.c @@ -341,9 +341,9 @@ static void *xa_init(const char *device, unsigned rate, unsigned latency, return xa; } -static ssize_t xa_write(void *data, const void *buf, size_t size) +static ssize_t xa_write(void *data, const void *buf, size_t len) { - unsigned bytes = size; + unsigned bytes = len; xa_t *xa = (xa_t*)data; xaudio2_t *handle = xa->xa; const uint8_t *buffer = (const uint8_t*)buf; @@ -354,8 +354,8 @@ static ssize_t xa_write(void *data, const void *buf, size_t size) if (avail == 0) return 0; - if (avail < size) - bytes = size = avail; + if (avail < len) + bytes = len = avail; } while (bytes) @@ -391,7 +391,7 @@ static ssize_t xa_write(void *data, const void *buf, size_t size) if (FAILED(IXAudio2SourceVoice_SubmitSourceBuffer( handle->pSourceVoice, &xa2buffer, NULL))) { - if (size > 0) + if (len > 0) return -1; return 0; } @@ -402,7 +402,7 @@ static ssize_t xa_write(void *data, const void *buf, size_t size) } } - return size; + return len; } static bool xa_stop(void *data) diff --git a/audio/drivers/xenon360_audio.c b/audio/drivers/xenon360_audio.c index 98a71443f267..04bce07d8225 100644 --- a/audio/drivers/xenon360_audio.c +++ b/audio/drivers/xenon360_audio.c @@ -57,21 +57,21 @@ static INLINE uint32_t bswap_32(uint32_t val) ((val >> 8) & 0xff00) | ((val << 8) & 0xff0000); } -static ssize_t xenon360_audio_write(void *data, const void *buf, size_t size) +static ssize_t xenon360_audio_write(void *data, const void *buf, size_t len) { size_t written = 0, i; const uint32_t *in_buf = buf; xenon_audio_t *xa = data; - for (i = 0; i < (size >> 2); i++) + for (i = 0; i < (len >> 2); i++) xa->buffer[i] = bswap_32(in_buf[i]); if (xa->nonblock) { if (xenon_sound_get_unplayed() < MAX_BUFFER) { - xenon_sound_submit(xa->buffer, size); - written = size; + xenon_sound_submit(xa->buffer, len); + written = len; } } else @@ -83,8 +83,8 @@ static ssize_t xenon360_audio_write(void *data, const void *buf, size_t size) udelay(50); } - xenon_sound_submit(xa->buffer, size); - written = size; + xenon_sound_submit(xa->buffer, len); + written = len; } return written; diff --git a/audio/drivers_microphone/alsa.c b/audio/drivers_microphone/alsa.c index 85de4ebe0ef0..287970910676 100644 --- a/audio/drivers_microphone/alsa.c +++ b/audio/drivers_microphone/alsa.c @@ -51,7 +51,7 @@ static void *alsa_microphone_init(void) return alsa; } -static void alsa_microphone_close_mic(void *driver_context, void *microphone_context); +static void alsa_microphone_close_mic(void *driver_context, void *mic_context); static void alsa_microphone_free(void *driver_context) { alsa_microphone_t *alsa = (alsa_microphone_t*)driver_context; @@ -64,36 +64,37 @@ static void alsa_microphone_free(void *driver_context) } } -static bool alsa_microphone_start_mic(void *driver_context, void *microphone_context); -static int alsa_microphone_read(void *driver_context, void *microphone_context, void *buf_, size_t size_) +static bool alsa_microphone_start_mic(void *driver_context, void *mic_context); + +static int alsa_microphone_read(void *driver_context, void *mic_context, void *s, size_t len) { - alsa_microphone_t *alsa = (alsa_microphone_t*)driver_context; - alsa_microphone_handle_t *microphone = (alsa_microphone_handle_t*)microphone_context; - uint8_t *buf = (uint8_t*)buf_; - snd_pcm_sframes_t read = 0; - int errnum = 0; - snd_pcm_sframes_t size; size_t frames_size; + snd_pcm_sframes_t size; snd_pcm_state_t state; + alsa_microphone_t *alsa = (alsa_microphone_t*)driver_context; + alsa_microphone_handle_t *mic = (alsa_microphone_handle_t*)mic_context; + uint8_t *buf = (uint8_t*)s; + snd_pcm_sframes_t read = 0; + int errnum = 0; - if (!alsa || !microphone || !buf) + if (!alsa || !mic || !buf) return -1; - size = BYTES_TO_FRAMES(size_, microphone->stream_info.frame_bits); - frames_size = microphone->stream_info.has_float ? sizeof(float) : sizeof(int16_t); + size = BYTES_TO_FRAMES(len, mic->stream_info.frame_bits); + frames_size = mic->stream_info.has_float ? sizeof(float) : sizeof(int16_t); - state = snd_pcm_state(microphone->pcm); + state = snd_pcm_state(mic->pcm); if (state != SND_PCM_STATE_RUNNING) { RARCH_WARN("[ALSA]: Expected microphone \"%s\" to be in state RUNNING, was in state %s\n", - snd_pcm_name(microphone->pcm), + snd_pcm_name(mic->pcm), snd_pcm_state_name(state)); - errnum = snd_pcm_start(microphone->pcm); + errnum = snd_pcm_start(mic->pcm); if (errnum < 0) { RARCH_ERR("[ALSA]: Failed to start microphone \"%s\": %s\n", - snd_pcm_name(microphone->pcm), + snd_pcm_name(mic->pcm), snd_strerror(errnum)); return -1; @@ -104,11 +105,11 @@ static int alsa_microphone_read(void *driver_context, void *microphone_context, { while (size) { - snd_pcm_sframes_t frames = snd_pcm_readi(microphone->pcm, buf, size); + snd_pcm_sframes_t frames = snd_pcm_readi(mic->pcm, buf, size); if (frames == -EPIPE || frames == -EINTR || frames == -ESTRPIPE) { - errnum = snd_pcm_recover(microphone->pcm, frames, 0); + errnum = snd_pcm_recover(mic->pcm, frames, 0); if (errnum < 0) { RARCH_ERR("[ALSA]: Failed to read from microphone: %s\n", snd_strerror(frames)); @@ -135,20 +136,20 @@ static int alsa_microphone_read(void *driver_context, void *microphone_context, while (size) { snd_pcm_sframes_t frames; - int rc = snd_pcm_wait(microphone->pcm, -1); + int rc = snd_pcm_wait(mic->pcm, -1); if (rc == -EPIPE || rc == -ESTRPIPE || rc == -EINTR) { - if (snd_pcm_recover(microphone->pcm, rc, 1) < 0) + if (snd_pcm_recover(mic->pcm, rc, 1) < 0) return -1; continue; } - frames = snd_pcm_readi(microphone->pcm, buf, size); + frames = snd_pcm_readi(mic->pcm, buf, size); if (frames == -EPIPE || frames == -EINTR || frames == -ESTRPIPE) { - if (snd_pcm_recover(microphone->pcm, frames, 1) < 0) + if (snd_pcm_recover(mic->pcm, frames, 1) < 0) return -1; break; @@ -172,18 +173,18 @@ static int alsa_microphone_read(void *driver_context, void *microphone_context, } } - return FRAMES_TO_BYTES(read, microphone->stream_info.frame_bits); + return FRAMES_TO_BYTES(read, mic->stream_info.frame_bits); } -static bool alsa_microphone_mic_alive(const void *driver_context, const void *microphone_context) +static bool alsa_microphone_mic_alive(const void *driver_context, const void *mic_context) { - alsa_microphone_handle_t *microphone = (alsa_microphone_handle_t*)microphone_context; + alsa_microphone_handle_t *mic = (alsa_microphone_handle_t*)mic_context; (void)driver_context; - if (!microphone) + if (!mic) return false; - return snd_pcm_state(microphone->pcm) == SND_PCM_STATE_RUNNING; + return snd_pcm_state(mic->pcm) == SND_PCM_STATE_RUNNING; } static void alsa_microphone_set_nonblock_state(void *driver_context, bool nonblock) @@ -194,7 +195,6 @@ static void alsa_microphone_set_nonblock_state(void *driver_context, bool nonblo static struct string_list *alsa_microphone_device_list_new(const void *data) { - (void)data; return alsa_device_list_type_new("Input"); } @@ -211,72 +211,63 @@ static void *alsa_microphone_open_mic(void *driver_context, unsigned latency, unsigned *new_rate) { - alsa_microphone_t *alsa = (alsa_microphone_t*)driver_context; - alsa_microphone_handle_t *microphone = NULL; + alsa_microphone_t *alsa = (alsa_microphone_t*)driver_context; + alsa_microphone_handle_t *mic = NULL; if (!alsa) /* If we weren't given a valid ALSA context... */ return NULL; - microphone = calloc(1, sizeof(alsa_microphone_handle_t)); - if (!microphone) /* If the microphone context couldn't be allocated... */ + /* If the microphone context couldn't be allocated... */ + if (!(mic = calloc(1, sizeof(alsa_microphone_handle_t)))) return NULL; /* channels hardcoded to 1, because we only support mono mic input */ - if (alsa_init_pcm(µphone->pcm, device, SND_PCM_STREAM_CAPTURE, rate, latency, 1, µphone->stream_info, new_rate, SND_PCM_NONBLOCK) < 0) - { + if (alsa_init_pcm(&mic->pcm, device, SND_PCM_STREAM_CAPTURE, rate, latency, 1, + &mic->stream_info, new_rate, SND_PCM_NONBLOCK) < 0) goto error; - } - return microphone; + return mic; error: RARCH_ERR("[ALSA]: Failed to initialize microphone...\n"); - alsa_microphone_close_mic(alsa, microphone); + alsa_microphone_close_mic(alsa, mic); return NULL; } -static void alsa_microphone_close_mic(void *driver_context, void *microphone_context) +static void alsa_microphone_close_mic(void *driver_context, void *mic_context) { - alsa_microphone_handle_t *microphone = (alsa_microphone_handle_t*)microphone_context; + alsa_microphone_handle_t *mic = (alsa_microphone_handle_t*)mic_context; (void)driver_context; - if (microphone) + if (mic) { - alsa_free_pcm(microphone->pcm); - free(microphone); + alsa_free_pcm(mic->pcm); + free(mic); } } -static bool alsa_microphone_start_mic(void *driver_context, void *microphone_context) +static bool alsa_microphone_start_mic(void *driver_context, void *mic_context) { - alsa_microphone_handle_t *microphone = (alsa_microphone_handle_t*)microphone_context; - (void)driver_context; - - if (!microphone) + alsa_microphone_handle_t *mic = (alsa_microphone_handle_t*)mic_context; + if (!mic) return false; - - return alsa_start_pcm(microphone->pcm); + return alsa_start_pcm(mic->pcm); } -static bool alsa_microphone_stop_mic(void *driver_context, void *microphone_context) +static bool alsa_microphone_stop_mic(void *driver_context, void *mic_context) { - alsa_microphone_handle_t *microphone = (alsa_microphone_handle_t*)microphone_context; - (void)driver_context; - - if (!microphone) + alsa_microphone_handle_t *mic = (alsa_microphone_handle_t*)mic_context; + if (!mic) return false; - - return alsa_stop_pcm(microphone->pcm); + return alsa_stop_pcm(mic->pcm); } -static bool alsa_microphone_mic_use_float(const void *driver_context, const void *microphone_context) +static bool alsa_microphone_mic_use_float(const void *driver_context, const void *mic_context) { - alsa_microphone_handle_t *microphone = (alsa_microphone_handle_t*)microphone_context; - (void)driver_context; - + alsa_microphone_handle_t *mic = (alsa_microphone_handle_t*)mic_context; return microphone->stream_info.has_float; } diff --git a/audio/drivers_microphone/alsathread.c b/audio/drivers_microphone/alsathread.c index 772b5f1fd225..aee708e71ec9 100644 --- a/audio/drivers_microphone/alsathread.c +++ b/audio/drivers_microphone/alsathread.c @@ -49,27 +49,27 @@ static void *alsa_thread_microphone_init(void) return alsa; } -static void alsa_thread_microphone_close_mic(void *driver_context, void *microphone_context); +/* Forward declaration */ +static void alsa_thread_microphone_close_mic(void *driver_context, void *mic_context); + static void alsa_thread_microphone_free(void *driver_context) { alsa_thread_microphone_t *alsa = (alsa_thread_microphone_t*)driver_context; if (alsa) - { free(alsa); - } } /** @see alsa_thread_read_microphone() */ -static void alsa_microphone_worker_thread(void *microphone_context) +static void alsa_microphone_worker_thread(void *mic_context) { - alsa_thread_microphone_handle_t *microphone = (alsa_thread_microphone_handle_t*)microphone_context; - uint8_t *buf = NULL; - uintptr_t thread_id = sthread_get_current_thread_id(); + alsa_thread_microphone_handle_t *mic = (alsa_thread_microphone_handle_t*)mic_context; + uint8_t *buf = NULL; + uintptr_t thread_id = sthread_get_current_thread_id(); - retro_assert(microphone != NULL); - buf = (uint8_t *)calloc(1, microphone->info.stream_info.period_size); - if (!buf) + retro_assert(mic != NULL); + + if (!(buf = (uint8_t *)calloc(1, mic->info.stream_info.period_size))) { RARCH_ERR("[ALSA] [capture thread %p]: Failed to allocate audio buffer\n", thread_id); goto end; @@ -78,34 +78,35 @@ static void alsa_microphone_worker_thread(void *microphone_context) RARCH_DBG("[ALSA] [capture thread %p]: Beginning microphone worker thread\n", thread_id); RARCH_DBG("[ALSA] [capture thread %p]: Microphone \"%s\" is in state %s\n", thread_id, - snd_pcm_name(microphone->info.pcm), - snd_pcm_state_name(snd_pcm_state(microphone->info.pcm))); + snd_pcm_name(mic->info.pcm), + snd_pcm_state_name(snd_pcm_state(mic->info.pcm))); - while (!microphone->info.thread_dead) - { /* Until we're told to stop... */ + /* Until we're told to stop... */ + while (!mic->info.thread_dead) + { size_t avail; size_t fifo_size; snd_pcm_sframes_t frames; int errnum = 0; /* Lock the incoming sample queue (the main thread may block) */ - slock_lock(microphone->info.fifo_lock); + slock_lock(mic->info.fifo_lock); /* Fill the incoming sample queue with whatever we recently read */ - avail = FIFO_WRITE_AVAIL(microphone->info.buffer); - fifo_size = MIN(microphone->info.stream_info.period_size, avail); - fifo_write(microphone->info.buffer, buf, fifo_size); + avail = FIFO_WRITE_AVAIL(mic->info.buffer); + fifo_size = MIN(mic->info.stream_info.period_size, avail); + fifo_write(mic->info.buffer, buf, fifo_size); /* Tell the main thread that it's okay to query the mic again */ - scond_signal(microphone->info.cond); + scond_signal(mic->info.cond); /* Unlock the incoming sample queue (the main thread may resume) */ - slock_unlock(microphone->info.fifo_lock); + slock_unlock(mic->info.fifo_lock); /* If underrun, fill rest with silence. */ - memset(buf + fifo_size, 0, microphone->info.stream_info.period_size - fifo_size); + memset(buf + fifo_size, 0, mic->info.stream_info.period_size - fifo_size); - errnum = snd_pcm_wait(microphone->info.pcm, 33); + errnum = snd_pcm_wait(mic->info.pcm, 33); if (errnum == 0) { @@ -118,7 +119,7 @@ static void alsa_microphone_worker_thread(void *microphone_context) thread_id, snd_strerror(errnum)); - if ((errnum = snd_pcm_recover(microphone->info.pcm, errnum, false)) < 0) + if ((errnum = snd_pcm_recover(mic->info.pcm, errnum, false)) < 0) { RARCH_ERR("[ALSA] [capture thread %p]: Failed to recover from prior wait error: %s\n", thread_id, @@ -130,7 +131,7 @@ static void alsa_microphone_worker_thread(void *microphone_context) continue; } - frames = snd_pcm_readi(microphone->info.pcm, buf, microphone->info.stream_info.period_frames); + frames = snd_pcm_readi(mic->info.pcm, buf, mic->info.stream_info.period_frames); if (frames == -EPIPE || frames == -EINTR || frames == -ESTRPIPE) { @@ -138,7 +139,7 @@ static void alsa_microphone_worker_thread(void *microphone_context) thread_id, snd_strerror(frames)); - if ((errnum = snd_pcm_recover(microphone->info.pcm, frames, false)) < 0) + if ((errnum = snd_pcm_recover(mic->info.pcm, frames, false)) < 0) { RARCH_ERR("[ALSA] [capture thread %p]: Failed to recover from prior read error: %s\n", thread_id, @@ -158,103 +159,104 @@ static void alsa_microphone_worker_thread(void *microphone_context) } end: - slock_lock(microphone->info.cond_lock); - microphone->info.thread_dead = true; - scond_signal(microphone->info.cond); - slock_unlock(microphone->info.cond_lock); + slock_lock(mic->info.cond_lock); + mic->info.thread_dead = true; + scond_signal(mic->info.cond); + slock_unlock(mic->info.cond_lock); free(buf); RARCH_DBG("[ALSA] [capture thread %p]: Ending microphone worker thread\n", thread_id); } -static int alsa_thread_microphone_read(void *driver_context, void *microphone_context, void *buf, size_t size) +static int alsa_thread_microphone_read(void *driver_context, void *mic_context, void *s, size_t len) { - alsa_thread_microphone_t *alsa = (alsa_thread_microphone_t*)driver_context; - alsa_thread_microphone_handle_t *microphone = (alsa_thread_microphone_handle_t*)microphone_context; + alsa_thread_microphone_t *alsa = (alsa_thread_microphone_t*)driver_context; + alsa_thread_microphone_handle_t *mic = (alsa_thread_microphone_handle_t*)mic_context; snd_pcm_state_t state; - if (!alsa || !microphone || !buf) /* If any of the parameters were invalid... */ + if (!alsa || !mic || !s) /* If any of the parameters were invalid... */ return -1; - if (microphone->info.thread_dead) /* If the mic thread is shutting down... */ + if (mic->info.thread_dead) /* If the mic thread is shutting down... */ return -1; - state = snd_pcm_state(microphone->info.pcm); + state = snd_pcm_state(mic->info.pcm); if (state != SND_PCM_STATE_RUNNING) { int errnum; RARCH_WARN("[ALSA]: Expected microphone \"%s\" to be in state RUNNING, was in state %s\n", - snd_pcm_name(microphone->info.pcm), - snd_pcm_state_name(state)); + snd_pcm_name(mic->info.pcm), snd_pcm_state_name(state)); - errnum = snd_pcm_start(microphone->info.pcm); + errnum = snd_pcm_start(mic->info.pcm); if (errnum < 0) { RARCH_ERR("[ALSA]: Failed to start microphone \"%s\": %s\n", - snd_pcm_name(microphone->info.pcm), - snd_strerror(errnum)); + snd_pcm_name(mic->info.pcm), snd_strerror(errnum)); return -1; } } + /* If driver interactions shouldn't block... */ if (alsa->nonblock) - { /* If driver interactions shouldn't block... */ + { size_t avail; size_t write_amt; /* "Hey, I'm gonna borrow the queue." */ - slock_lock(microphone->info.fifo_lock); + slock_lock(mic->info.fifo_lock); - avail = FIFO_READ_AVAIL(microphone->info.buffer); - write_amt = MIN(avail, size); + avail = FIFO_READ_AVAIL(mic->info.buffer); + write_amt = MIN(avail, len); /* "It's okay if you don't have any new samples, I'll just check in on you later." */ - fifo_read(microphone->info.buffer, buf, write_amt); + fifo_read(mic->info.buffer, s, write_amt); /* "Here, take this queue back." */ - slock_unlock(microphone->info.fifo_lock); + slock_unlock(mic->info.fifo_lock); return (int)write_amt; } else { size_t read = 0; - while (read < size && !microphone->info.thread_dead) - { /* Until we've read all requested samples (or we're told to stop)... */ + + /* Until we've read all requested samples (or we're told to stop)... */ + while (read < len && !mic->info.thread_dead) + { size_t avail; /* "Hey, I'm gonna borrow the queue." */ - slock_lock(microphone->info.fifo_lock); + slock_lock(mic->info.fifo_lock); - avail = FIFO_READ_AVAIL(microphone->info.buffer); + avail = FIFO_READ_AVAIL(mic->info.buffer); if (avail == 0) { /* "Oh, wait, it's empty." */ /* "Here, take it back..." */ - slock_unlock(microphone->info.fifo_lock); + slock_unlock(mic->info.fifo_lock); /* "...I'll just wait right here." */ - slock_lock(microphone->info.cond_lock); + slock_lock(mic->info.cond_lock); /* "Unless we're closing up shop..." */ - if (!microphone->info.thread_dead) + if (!mic->info.thread_dead) /* "...let me know when you've produced some samples." */ - scond_wait(microphone->info.cond, microphone->info.cond_lock); + scond_wait(mic->info.cond, mic->info.cond_lock); /* "Oh, you're ready? Okay, I'm gonna continue." */ - slock_unlock(microphone->info.cond_lock); + slock_unlock(mic->info.cond_lock); } else { - size_t read_amt = MIN(size - read, avail); + size_t read_amt = MIN(len - read, avail); /* "I'll just go ahead and consume all these samples..." - * (As many as will fit in buf, or as many as are available.) */ - fifo_read(microphone->info.buffer,buf + read, read_amt); + * (As many as will fit in s, or as many as are available.) */ + fifo_read(mic->info.buffer,s + read, read_amt); /* "I'm done, you can take the queue back now." */ - slock_unlock(microphone->info.fifo_lock); + slock_unlock(mic->info.fifo_lock); read += read_amt; } @@ -264,87 +266,75 @@ static int alsa_thread_microphone_read(void *driver_context, void *microphone_co } } -static bool alsa_thread_microphone_mic_alive(const void *driver_context, const void *microphone_context); +static bool alsa_thread_microphone_mic_alive(const void *driver_context, const void *mic_context); static void *alsa_thread_microphone_open_mic(void *driver_context, - const char *device, - unsigned rate, - unsigned latency, - unsigned *new_rate) + const char *device, unsigned rate, unsigned latency, unsigned *new_rate) { - alsa_thread_microphone_t *alsa = (alsa_thread_microphone_t*)driver_context; - alsa_thread_microphone_handle_t *microphone = NULL; + alsa_thread_microphone_t *alsa = (alsa_thread_microphone_t*)driver_context; + alsa_thread_microphone_handle_t *mic = NULL; if (!alsa) /* If we weren't given a valid ALSA context... */ return NULL; - microphone = calloc(1, sizeof(alsa_thread_microphone_handle_t)); - - if (!microphone) - { /* If the microphone context couldn't be allocated... */ + /* If the microphone context couldn't be allocated... */ + if (!(mic = calloc(1, sizeof(alsa_thread_microphone_handle_t)))) + { RARCH_ERR("[ALSA] Failed to allocate microphone context\n"); return NULL; } - if (alsa_init_pcm(µphone->info.pcm, device, SND_PCM_STREAM_CAPTURE, rate, latency, 1, µphone->info.stream_info, new_rate, 0) < 0) - { + if (alsa_init_pcm(&mic->info.pcm, device, SND_PCM_STREAM_CAPTURE, rate, latency, + 1, &mic->info.stream_info, new_rate, 0) < 0) goto error; - } - microphone->info.fifo_lock = slock_new(); - microphone->info.cond_lock = slock_new(); - microphone->info.cond = scond_new(); - microphone->info.buffer = fifo_new(microphone->info.stream_info.buffer_size); - if (!microphone->info.fifo_lock || !microphone->info.cond_lock || !microphone->info.cond || !microphone->info.buffer || !microphone->info.pcm) + mic->info.fifo_lock = slock_new(); + mic->info.cond_lock = slock_new(); + mic->info.cond = scond_new(); + mic->info.buffer = fifo_new(mic->info.stream_info.buffer_size); + if (!mic->info.fifo_lock || !mic->info.cond_lock || !mic->info.cond || !mic->info.buffer || !mic->info.pcm) goto error; - microphone->info.worker_thread = sthread_create(alsa_microphone_worker_thread, microphone); - if (!microphone->info.worker_thread) + mic->info.worker_thread = sthread_create(alsa_microphone_worker_thread, mic); + if (!mic->info.worker_thread) { RARCH_ERR("[ALSA]: Failed to initialize microphone worker thread\n"); goto error; } RARCH_DBG("[ALSA]: Initialized microphone worker thread\n"); - return microphone; + return mic; error: RARCH_ERR("[ALSA]: Failed to initialize microphone...\n"); - if (microphone) + if (mic) { - if (microphone->info.pcm) - { + if (mic->info.pcm) snd_pcm_close(microphone->info.pcm); - } - alsa_thread_microphone_close_mic(alsa, microphone); + alsa_thread_microphone_close_mic(alsa, mic); } return NULL; } -static void alsa_thread_microphone_close_mic(void *driver_context, void *microphone_context) +static void alsa_thread_microphone_close_mic(void *driver_context, void *mic_context) { - alsa_thread_microphone_handle_t *microphone = (alsa_thread_microphone_handle_t*)microphone_context; - (void)driver_context; - - if (microphone) + alsa_thread_microphone_handle_t *mic = (alsa_thread_microphone_handle_t*)mic_context; + if (mic) { - alsa_thread_free_info_members(µphone->info); - free(microphone); + alsa_thread_free_info_members(&mic->info); + free(mic); } } -static bool alsa_thread_microphone_mic_alive(const void *driver_context, const void *microphone_context) +static bool alsa_thread_microphone_mic_alive(const void *driver_context, const void *mic_context) { - alsa_thread_microphone_handle_t *microphone = (alsa_thread_microphone_handle_t *)microphone_context; - (void)driver_context; - - if (!microphone) + alsa_thread_microphone_handle_t *mic = (alsa_thread_microphone_handle_t *)mic_context; + if (!mic) return false; - - return snd_pcm_state(microphone->info.pcm) == SND_PCM_STATE_RUNNING; + return snd_pcm_state(mic->info.pcm) == SND_PCM_STATE_RUNNING; } static void alsa_thread_microphone_set_nonblock_state(void *driver_context, bool state) @@ -355,44 +345,35 @@ static void alsa_thread_microphone_set_nonblock_state(void *driver_context, bool static struct string_list *alsa_thread_microphone_device_list_new(const void *data) { - (void)data; return alsa_device_list_type_new("Input"); } static void alsa_thread_microphone_device_list_free(const void *driver_context, struct string_list *devices) { - (void)driver_context; string_list_free(devices); /* Does nothing if devices is NULL */ } -static bool alsa_thread_microphone_start_mic(void *driver_context, void *microphone_context) +static bool alsa_thread_microphone_start_mic(void *driver_context, void *mic_context) { - alsa_thread_microphone_handle_t *microphone = (alsa_thread_microphone_handle_t*)microphone_context; - (void)driver_context; - - if (!microphone) + alsa_thread_microphone_handle_t *mic = (alsa_thread_microphone_handle_t*)mic_context; + if (!mic) return false; - - return alsa_start_pcm(microphone->info.pcm); + return alsa_start_pcm(mic->info.pcm); } -static bool alsa_thread_microphone_stop_mic(void *driver_context, void *microphone_context) +static bool alsa_thread_microphone_stop_mic(void *driver_context, void *mic_context) { - alsa_thread_microphone_handle_t *microphone = (alsa_thread_microphone_handle_t*)microphone_context; - (void)driver_context; - - if (!microphone) + alsa_thread_microphone_handle_t *mic = (alsa_thread_microphone_handle_t*)mic_context; + if (!mic) return false; - - return alsa_stop_pcm(microphone->info.pcm); + return alsa_stop_pcm(mic->info.pcm); } -static bool alsa_thread_microphone_mic_use_float(const void *driver_context, const void *microphone_context) +static bool alsa_thread_microphone_mic_use_float(const void *driver_context, const void *mic_context) { - alsa_thread_microphone_handle_t *microphone = (alsa_thread_microphone_handle_t*)microphone_context; - - return microphone->info.stream_info.has_float; + alsa_thread_microphone_handle_t *mic = (alsa_thread_microphone_handle_t*)mic_context; + return mic->info.stream_info.has_float; } microphone_driver_t microphone_alsathread = { diff --git a/audio/drivers_microphone/pipewire.c b/audio/drivers_microphone/pipewire.c index 2bb009555f4b..76db9b3e9c93 100644 --- a/audio/drivers_microphone/pipewire.c +++ b/audio/drivers_microphone/pipewire.c @@ -27,9 +27,9 @@ #include #include -#include "audio/common/pipewire.h" -#include "audio/microphone_driver.h" -#include "verbosity.h" +#include "../common/pipewire.h" +#include "../microphone_driver.h" +#include "../../verbosity.h" #define DEFAULT_CHANNELS 1 @@ -51,22 +51,22 @@ typedef struct pipewire_microphone static void stream_state_changed_cb(void *data, enum pw_stream_state old, enum pw_stream_state state, const char *error) { - pipewire_microphone_t *microphone = (pipewire_microphone_t*)data; + pipewire_microphone_t *mic = (pipewire_microphone_t*)data; RARCH_DBG("[PipeWire]: New state for Source Node %d : %s\n", - pw_stream_get_node_id(microphone->stream), + pw_stream_get_node_id(mic->stream), pw_stream_state_as_string(state)); switch(state) { case PW_STREAM_STATE_UNCONNECTED: - microphone->is_ready = false; - pw_thread_loop_stop(microphone->pw->thread_loop); + mic->is_ready = false; + pw_thread_loop_stop(mic->pw->thread_loop); break; case PW_STREAM_STATE_STREAMING: case PW_STREAM_STATE_ERROR: case PW_STREAM_STATE_PAUSED: - pw_thread_loop_signal(microphone->pw->thread_loop, false); + pw_thread_loop_signal(mic->pw->thread_loop, false); break; default: break; @@ -75,24 +75,23 @@ static void stream_state_changed_cb(void *data, static void stream_destroy_cb(void *data) { - pipewire_microphone_t *microphone = (pipewire_microphone_t*)data; - spa_hook_remove(µphone->stream_listener); - microphone->stream = NULL; + pipewire_microphone_t *mic = (pipewire_microphone_t*)data; + spa_hook_remove(&mic->stream_listener); + mic->stream = NULL; } static void capture_process_cb(void *data) { - pipewire_microphone_t *microphone = (pipewire_microphone_t *)data; void *p; + int32_t filled; struct pw_buffer *b; struct spa_buffer *buf; - int32_t filled; uint32_t idx, offs, n_bytes; + pipewire_microphone_t *mic = (pipewire_microphone_t*)data; - assert(microphone->stream); + assert(mic->stream); - b = pw_stream_dequeue_buffer(microphone->stream); - if (b == NULL) + if (!(b = pw_stream_dequeue_buffer(mic->stream))) { RARCH_ERR("[PipeWire]: out of buffers: %s\n", strerror(errno)); return; @@ -102,11 +101,10 @@ static void capture_process_cb(void *data) if ((p = buf->datas[0].data) == NULL) goto done; - offs = SPA_MIN(buf->datas[0].chunk->offset, buf->datas[0].maxsize); + offs = SPA_MIN(buf->datas[0].chunk->offset, buf->datas[0].maxsize); n_bytes = SPA_MIN(buf->datas[0].chunk->size, buf->datas[0].maxsize - offs); - filled = spa_ringbuffer_get_write_index(µphone->ring, &idx); - if (filled < 0) + if ((filled = spa_ringbuffer_get_write_index(&mic->ring, &idx)) < 0) RARCH_ERR("[PipeWire]: %p: underrun write:%u filled:%d\n", p, idx, filled); else { @@ -114,16 +112,16 @@ static void capture_process_cb(void *data) RARCH_ERR("[PipeWire]: %p: overrun write:%u filled:%d + size:%u > max:%u\n", p, idx, filled, n_bytes, RINGBUFFER_SIZE); } - spa_ringbuffer_write_data(µphone->ring, - microphone->buffer, RINGBUFFER_SIZE, - idx & RINGBUFFER_MASK, - SPA_PTROFF(p, offs, void), n_bytes); + spa_ringbuffer_write_data(&mic->ring, + mic->buffer, RINGBUFFER_SIZE, + idx & RINGBUFFER_MASK, + SPA_PTROFF(p, offs, void), n_bytes); idx += n_bytes; - spa_ringbuffer_write_update(µphone->ring, idx); + spa_ringbuffer_write_update(&mic->ring, idx); done: - pw_stream_queue_buffer(microphone->stream, b); - pw_thread_loop_signal(microphone->pw->thread_loop, false); + pw_stream_queue_buffer(mic->stream, b); + pw_thread_loop_signal(mic->pw->thread_loop, false); } static const struct pw_stream_events capture_stream_events = { @@ -134,8 +132,8 @@ static const struct pw_stream_events capture_stream_events = { }; static void registry_event_global(void *data, uint32_t id, - uint32_t permissions, const char *type, uint32_t version, - const struct spa_dict *props) + uint32_t permissions, const char *type, uint32_t version, + const struct spa_dict *props) { union string_list_elem_attr attr; const struct spa_dict_item *item; @@ -170,14 +168,44 @@ static const struct pw_registry_events registry_events = { .global = registry_event_global, }; -static void pipewire_microphone_free(void *driver_context); +static void pipewire_microphone_free(void *driver_context) +{ + pipewire_core_t *pw = (pipewire_core_t*)driver_context; + + if (!pw) + return pw_deinit(); + + if (pw->thread_loop) + pw_thread_loop_stop(pw->thread_loop); + + if (pw->registry) + pw_proxy_destroy((struct pw_proxy*)pw->registry); + + if (pw->core) + { + spa_hook_remove(&pw->core_listener); + spa_zero(pw->core_listener); + pw_core_disconnect(pw->core); + } + + if (pw->ctx) + pw_context_destroy(pw->ctx); + + pw_thread_loop_destroy(pw->thread_loop); + + if (pw->devicelist) + string_list_free(pw->devicelist); + + free(pw); + pw_deinit(); +} static void *pipewire_microphone_init(void) { - int res; - uint64_t buf_samples; + int res; + uint8_t buffer[1024]; + uint64_t buf_samples; const struct spa_pod *params[1]; - uint8_t buffer[1024]; struct pw_properties *props = NULL; const char *error = NULL; pipewire_core_t *pw = (pipewire_core_t*)calloc(1, sizeof(*pw)); @@ -211,63 +239,45 @@ static void *pipewire_microphone_init(void) return NULL; } -static void pipewire_microphone_close_mic(void *driver_context, void *microphone_context); -static void pipewire_microphone_free(void *driver_context) +static void pipewire_microphone_close_mic(void *driver_context, void *mic_context) { - pipewire_core_t *pw = (pipewire_core_t*)driver_context; - - if (!pw) - return pw_deinit(); - - if (pw->thread_loop) - pw_thread_loop_stop(pw->thread_loop); - - if (pw->registry) - pw_proxy_destroy((struct pw_proxy*)pw->registry); + pipewire_core_t *pw = (pipewire_core_t*)driver_context; + pipewire_microphone_t *mic = (pipewire_microphone_t*)mic_context; - if (pw->core) + if (pw && mic) { - spa_hook_remove(&pw->core_listener); - spa_zero(pw->core_listener); - pw_core_disconnect(pw->core); + pw_thread_loop_lock(pw->thread_loop); + pw_stream_destroy(mic->stream); + mic->stream = NULL; + pw_thread_loop_unlock(pw->thread_loop); + free(mic); } - - if (pw->ctx) - pw_context_destroy(pw->ctx); - - pw_thread_loop_destroy(pw->thread_loop); - - if (pw->devicelist) - string_list_free(pw->devicelist); - - free(pw); - pw_deinit(); } -static int pipewire_microphone_read(void *driver_context, void *microphone_context, void *buf_, size_t size_) +static int pipewire_microphone_read(void *driver_context, void *mic_context, void *s, size_t len) { - int32_t readable; - uint32_t idx; - const char *error = NULL; - pipewire_core_t *pw = (pipewire_core_t*)driver_context; - pipewire_microphone_t *microphone = (pipewire_microphone_t*)microphone_context; - - if ( !microphone->is_ready - || pw_stream_get_state(microphone->stream, &error) != PW_STREAM_STATE_STREAMING) + uint32_t idx; + int32_t readable; + const char *error = NULL; + pipewire_core_t *pw = (pipewire_core_t*)driver_context; + pipewire_microphone_t *mic = (pipewire_microphone_t*)mic_context; + + if ( !mic->is_ready + || pw_stream_get_state(mic->stream, &error) != PW_STREAM_STATE_STREAMING) return -1; pw_thread_loop_lock(pw->thread_loop); - while (size_) + while (len) { /* get no of available bytes to read data from buffer */ - readable = spa_ringbuffer_get_read_index(µphone->ring, &idx); + readable = spa_ringbuffer_get_read_index(&mic->ring, &idx); - if (readable < (int32_t)size_) + if (readable < (int32_t)len) { if (pw->nonblock) { - size_ = readable; + len = readable; break; } @@ -277,26 +287,23 @@ static int pipewire_microphone_read(void *driver_context, void *microphone_conte break; } - spa_ringbuffer_read_data(µphone->ring, - microphone->buffer, RINGBUFFER_SIZE, - idx & RINGBUFFER_MASK, buf_, size_); - idx += size_; - spa_ringbuffer_read_update(µphone->ring, idx); + spa_ringbuffer_read_data(&mic->ring, + mic->buffer, RINGBUFFER_SIZE, + idx & RINGBUFFER_MASK, s, len); + idx += len; + spa_ringbuffer_read_update(&mic->ring, idx); pw_thread_loop_unlock(pw->thread_loop); - return size_; + return len; } -static bool pipewire_microphone_mic_alive(const void *driver_context, const void *microphone_context) +static bool pipewire_microphone_mic_alive(const void *driver_context, const void *mic_context) { - const char *error = NULL; - pipewire_microphone_t *microphone = (pipewire_microphone_t*)microphone_context; - (void)driver_context; - - if (!microphone) + const char *error = NULL; + pipewire_microphone_t *mic = (pipewire_microphone_t*)mic_context; + if (!mic) return false; - - return pw_stream_get_state(microphone->stream, &error) == PW_STREAM_STATE_STREAMING; + return pw_stream_get_state(mic->stream, &error) == PW_STREAM_STATE_STREAMING; } static void pipewire_microphone_set_nonblock_state(void *driver_context, bool nonblock) @@ -318,41 +325,38 @@ static struct string_list *pipewire_microphone_device_list_new(const void *drive static void pipewire_microphone_device_list_free(const void *driver_context, struct string_list *devices) { - (void)driver_context; if (devices) string_list_free(devices); } static void *pipewire_microphone_open_mic(void *driver_context, - const char *device, - unsigned rate, - unsigned latency, + const char *device, unsigned rate, unsigned latency, unsigned *new_rate) { - int res; - uint64_t buf_samples; - const struct spa_pod *params[1]; - uint8_t buffer[1024]; - struct pw_properties *props = NULL; - const char *error = NULL; - struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer)); - pipewire_microphone_t *microphone = calloc(1, sizeof(pipewire_microphone_t)); + int res; + uint64_t buf_samples; + uint8_t buffer[1024]; + const struct spa_pod *params[1]; + struct pw_properties *props = NULL; + const char *error = NULL; + struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer)); + pipewire_microphone_t *mic = calloc(1, sizeof(pipewire_microphone_t)); retro_assert(driver_context); - if (!microphone) + if (!mic) goto error; - microphone->is_ready = false; - microphone->pw = (pipewire_core_t*)driver_context; + mic->is_ready = false; + mic->pw = (pipewire_core_t*)driver_context; - pw_thread_loop_lock(microphone->pw->thread_loop); + pw_thread_loop_lock(mic->pw->thread_loop); - microphone->info.format = is_little_endian() ? SPA_AUDIO_FORMAT_F32_LE : SPA_AUDIO_FORMAT_F32_BE; - microphone->info.channels = DEFAULT_CHANNELS; - pipewire_set_position(DEFAULT_CHANNELS, microphone->info.position); - microphone->info.rate = rate; - microphone->frame_size = pipewire_calc_frame_size(microphone->info.format, DEFAULT_CHANNELS); + mic->info.format = is_little_endian() ? SPA_AUDIO_FORMAT_F32_LE : SPA_AUDIO_FORMAT_F32_BE; + mic->info.channels = DEFAULT_CHANNELS; + pipewire_set_position(DEFAULT_CHANNELS, mic->info.position); + mic->info.rate = rate; + mic->frame_size = pipewire_calc_frame_size(mic->info.format, DEFAULT_CHANNELS); props = pw_properties_new(PW_KEY_MEDIA_TYPE, PW_RARCH_MEDIA_TYPE_AUDIO, PW_KEY_MEDIA_CATEGORY, PW_RARCH_MEDIA_CATEGORY_RECORD, @@ -372,97 +376,75 @@ static void *pipewire_microphone_open_mic(void *driver_context, buf_samples = latency * rate / 1000; pw_properties_setf(props, PW_KEY_NODE_LATENCY, "%" PRIu64 "/%u", buf_samples, rate); pw_properties_setf(props, PW_KEY_NODE_RATE, "1/%d", rate); - microphone->stream = pw_stream_new(microphone->pw->core, PW_RARCH_APPNAME, props); - if (!microphone->stream) + if (!(mic->stream = pw_stream_new(mic->pw->core, PW_RARCH_APPNAME, props))) goto unlock_error; - pw_stream_add_listener(microphone->stream, µphone->stream_listener, &capture_stream_events, microphone); + pw_stream_add_listener(mic->stream, &mic->stream_listener, &capture_stream_events, mic); - params[0] = spa_format_audio_raw_build(&b, SPA_PARAM_EnumFormat, µphone->info); + params[0] = spa_format_audio_raw_build(&b, SPA_PARAM_EnumFormat, &mic->info); /* Now connect this stream. We ask that our process function is * called in a realtime thread. */ - res = pw_stream_connect(microphone->stream, - PW_DIRECTION_INPUT, - PW_ID_ANY, - PW_STREAM_FLAG_AUTOCONNECT | - PW_STREAM_FLAG_INACTIVE | - PW_STREAM_FLAG_MAP_BUFFERS | - PW_STREAM_FLAG_RT_PROCESS, - params, 1); + res = pw_stream_connect(mic->stream, PW_DIRECTION_INPUT, PW_ID_ANY, + PW_STREAM_FLAG_AUTOCONNECT + | PW_STREAM_FLAG_INACTIVE + | PW_STREAM_FLAG_MAP_BUFFERS + | PW_STREAM_FLAG_RT_PROCESS, + params, 1); if (res < 0) goto unlock_error; - pw_thread_loop_wait(microphone->pw->thread_loop); - pw_thread_loop_unlock(microphone->pw->thread_loop); + pw_thread_loop_wait(mic->pw->thread_loop); + pw_thread_loop_unlock(mic->pw->thread_loop); - *new_rate = microphone->info.rate; + *new_rate = mic->info.rate; - microphone->is_ready = true; - return microphone; + mic->is_ready = true; + return mic; unlock_error: - pw_thread_loop_unlock(microphone->pw->thread_loop); + pw_thread_loop_unlock(mic->pw->thread_loop); error: RARCH_ERR("[PipeWire]: Failed to initialize microphone...\n"); - pipewire_microphone_close_mic(microphone->pw, microphone); + pipewire_microphone_close_mic(mic->pw, mic); return NULL; } -static void pipewire_microphone_close_mic(void *driver_context, void *microphone_context) -{ - pipewire_core_t *pw = (pipewire_core_t*)driver_context; - pipewire_microphone_t *microphone = (pipewire_microphone_t*)microphone_context; - - if (pw && microphone) - { - pw_thread_loop_lock(pw->thread_loop); - pw_stream_destroy(microphone->stream); - microphone->stream = NULL; - pw_thread_loop_unlock(pw->thread_loop); - free(microphone); - } -} - -static bool pipewire_microphone_start_mic(void *driver_context, void *microphone_context) +static bool pipewire_microphone_start_mic(void *driver_context, void *mic_context) { - pipewire_core_t *pw = (pipewire_core_t*)driver_context; - pipewire_microphone_t *microphone = (pipewire_microphone_t*)microphone_context; - const char *error = NULL; - - if (!pw || !microphone || !microphone->is_ready) + pipewire_core_t *pw = (pipewire_core_t*)driver_context; + pipewire_microphone_t *mic = (pipewire_microphone_t*)mic_context; + const char *error = NULL; + if (!pw || !mic || !mic->is_ready) return false; - if (pw_stream_get_state(microphone->stream, &error) == PW_STREAM_STATE_STREAMING) + if (pw_stream_get_state(mic->stream, &error) == PW_STREAM_STATE_STREAMING) return true; - - return pipewire_stream_set_active(pw->thread_loop, microphone->stream, true); + return pipewire_stream_set_active(pw->thread_loop, mic->stream, true); } -static bool pipewire_microphone_stop_mic(void *driver_context, void *microphone_context) +static bool pipewire_microphone_stop_mic(void *driver_context, void *mic_context) { - pipewire_core_t *pw = (pipewire_core_t*)driver_context; - pipewire_microphone_t *microphone = (pipewire_microphone_t*)microphone_context; - const char *error = NULL; - bool res = false; + pipewire_core_t *pw = (pipewire_core_t*)driver_context; + pipewire_microphone_t *mic = (pipewire_microphone_t*)mic_context; + const char *error = NULL; + bool res = false; - if (!pw || !microphone || !microphone->is_ready) + if (!pw || !mic || !mic->is_ready) return false; - if (pw_stream_get_state(microphone->stream, &error) == PW_STREAM_STATE_PAUSED) + if (pw_stream_get_state(mic->stream, &error) == PW_STREAM_STATE_PAUSED) return true; - res = pipewire_stream_set_active(pw->thread_loop, microphone->stream, false); - spa_ringbuffer_read_update(µphone->ring, 0); - spa_ringbuffer_write_update(µphone->ring, 0); + res = pipewire_stream_set_active(pw->thread_loop, mic->stream, false); + spa_ringbuffer_read_update(&mic->ring, 0); + spa_ringbuffer_write_update(&mic->ring, 0); return res; } -static bool pipewire_microphone_mic_use_float(const void *driver_context, const void *microphone_context) +static bool pipewire_microphone_mic_use_float(const void *a, const void *b) { - (void)driver_context; - (void)microphone_context; return true; } diff --git a/audio/drivers_microphone/sdl_microphone.c b/audio/drivers_microphone/sdl_microphone.c index b414ac6546a6..24e8e03804ca 100644 --- a/audio/drivers_microphone/sdl_microphone.c +++ b/audio/drivers_microphone/sdl_microphone.c @@ -45,9 +45,7 @@ typedef struct sdl_microphone static INLINE int sdl_microphone_find_num_frames(int rate, int latency) { int frames = (rate * latency) / 1000; - /* SDL only likes 2^n sized buffers. */ - return next_pow2(frames); } @@ -55,7 +53,6 @@ static void *sdl_microphone_init(void) { sdl_microphone_t *sdl = NULL; uint32_t sdl_subsystem_flags = SDL_WasInit(0); - /* Initialise audio subsystem, if required */ if (sdl_subsystem_flags == 0) { @@ -67,32 +64,30 @@ static void *sdl_microphone_init(void) if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) return NULL; } - if (!(sdl = (sdl_microphone_t*)calloc(1, sizeof(*sdl)))) return NULL; - return sdl; } -static void sdl_microphone_close_mic(void *driver_context, void *microphone_context) +static void sdl_microphone_close_mic(void *driver_context, void *mic_context) { - sdl_microphone_handle_t *microphone = (sdl_microphone_handle_t *)microphone_context; + sdl_microphone_handle_t *mic = (sdl_microphone_handle_t *)mic_context; - if (microphone) + if (mic) { /* If the microphone was originally initialized successfully... */ - if (microphone->device_id > 0) - SDL_CloseAudioDevice(microphone->device_id); + if (mic->device_id > 0) + SDL_CloseAudioDevice(mic->device_id); - fifo_free(microphone->sample_buffer); + fifo_free(mic->sample_buffer); #ifdef HAVE_THREADS - slock_free(microphone->lock); - scond_free(microphone->cond); + slock_free(mic->lock); + scond_free(mic->cond); #endif - RARCH_LOG("[SDL audio]: Freed microphone with former device ID %u\n", microphone->device_id); - free(microphone); + RARCH_LOG("[SDL audio]: Freed microphone with former device ID %u\n", mic->device_id); + free(mic); } } @@ -109,28 +104,24 @@ static void sdl_microphone_free(void *data) static void sdl_audio_record_cb(void *data, Uint8 *stream, int len) { - sdl_microphone_handle_t *microphone = (sdl_microphone_handle_t*)data; - size_t avail = FIFO_WRITE_AVAIL(microphone->sample_buffer); - size_t read_size = MIN(len, (int)avail); + sdl_microphone_handle_t *mic = (sdl_microphone_handle_t*)data; + size_t avail = FIFO_WRITE_AVAIL(mic->sample_buffer); + size_t read_size = MIN(len, (int)avail); /* If the sample buffer is almost full, just write as much as we can into it*/ - - fifo_write(microphone->sample_buffer, stream, read_size); + fifo_write(mic->sample_buffer, stream, read_size); #ifdef HAVE_THREADS - scond_signal(microphone->cond); + scond_signal(mic->cond); #endif } -static void *sdl_microphone_open_mic(void *driver_context, - const char *device, - unsigned rate, - unsigned latency, - unsigned *new_rate) +static void *sdl_microphone_open_mic(void *driver_context, const char *device, + unsigned rate, unsigned latency, unsigned *new_rate) { int frames; size_t bufsize; - sdl_microphone_handle_t *microphone = NULL; - SDL_AudioSpec desired_spec = {0}; - void *tmp = NULL; + void *tmp = NULL; + sdl_microphone_handle_t *mic = NULL; + SDL_AudioSpec desired_spec = {0}; #if __APPLE__ if (!string_is_equal(audio_driver_get_ident(), "sdl2")) @@ -150,7 +141,7 @@ static void *sdl_microphone_open_mic(void *driver_context, return NULL; } - if (!(microphone = (sdl_microphone_handle_t *) + if (!(mic = (sdl_microphone_handle_t *) calloc(1, sizeof(sdl_microphone_handle_t)))) return NULL; @@ -174,30 +165,31 @@ static void *sdl_microphone_open_mic(void *driver_context, desired_spec.format = AUDIO_F32SYS; desired_spec.channels = 1; /* Microphones only usually provide input in mono */ desired_spec.samples = frames; - desired_spec.userdata = microphone; + desired_spec.userdata = mic; desired_spec.callback = sdl_audio_record_cb; - microphone->device_id = SDL_OpenAudioDevice( + mic->device_id = SDL_OpenAudioDevice( NULL, true, &desired_spec, - µphone->device_spec, - SDL_AUDIO_ALLOW_FREQUENCY_CHANGE | SDL_AUDIO_ALLOW_FORMAT_CHANGE); + &mic->device_spec, + SDL_AUDIO_ALLOW_FREQUENCY_CHANGE + | SDL_AUDIO_ALLOW_FORMAT_CHANGE); - if (microphone->device_id == 0) + if (mic->device_id == 0) { RARCH_ERR("[SDL mic]: Failed to open SDL audio input device: %s\n", SDL_GetError()); goto error; } RARCH_DBG("[SDL mic]: Opened SDL audio input device with ID %u\n", - microphone->device_id); + mic->device_id); RARCH_DBG("[SDL mic]: Requested a microphone frequency of %u Hz, got %u Hz\n", - desired_spec.freq, microphone->device_spec.freq); + desired_spec.freq, mic->device_spec.freq); RARCH_DBG("[SDL mic]: Requested %u channels for microphone, got %u\n", - desired_spec.channels, microphone->device_spec.channels); + desired_spec.channels, mic->device_spec.channels); RARCH_DBG("[SDL mic]: Requested a %u-sample microphone buffer, got %u samples (%u bytes)\n", - frames, microphone->device_spec.samples, microphone->device_spec.size); - RARCH_DBG("[SDL mic]: Got a microphone silence value of %u\n", microphone->device_spec.silence); + frames, mic->device_spec.samples, mic->device_spec.size); + RARCH_DBG("[SDL mic]: Got a microphone silence value of %u\n", mic->device_spec.silence); RARCH_DBG("[SDL mic]: Requested microphone audio format: %u-bit %s %s %s endian\n", SDL_AUDIO_BITSIZE(desired_spec.format), SDL_AUDIO_ISSIGNED(desired_spec.format) ? "signed" : "unsigned", @@ -211,87 +203,85 @@ static void *sdl_microphone_open_mic(void *driver_context, SDL_AUDIO_ISBIGENDIAN(desired_spec.format) ? "big" : "little"); if (new_rate) - *new_rate = microphone->device_spec.freq; + *new_rate = mic->device_spec.freq; #ifdef HAVE_THREADS - microphone->lock = slock_new(); - microphone->cond = scond_new(); + mic->lock = slock_new(); + mic->cond = scond_new(); #endif RARCH_LOG("[SDL audio]: Requested %u ms latency for input device, got %d ms\n", - latency, (int)(microphone->device_spec.samples * 4 * 1000 / microphone->device_spec.freq)); + latency, (int)(mic->device_spec.samples * 4 * 1000 / mic->device_spec.freq)); /* Create a buffer twice as big as needed and prefill the buffer. */ - bufsize = microphone->device_spec.samples * 2 * (SDL_AUDIO_BITSIZE(microphone->device_spec.format) / 8); - tmp = calloc(1, bufsize); - microphone->sample_buffer = fifo_new(bufsize); + bufsize = mic->device_spec.samples * 2 * (SDL_AUDIO_BITSIZE(mic->device_spec.format) / 8); + tmp = calloc(1, bufsize); + mic->sample_buffer = fifo_new(bufsize); RARCH_DBG("[SDL audio]: Initialized microphone sample queue with %u bytes\n", bufsize); if (tmp) { - fifo_write(microphone->sample_buffer, tmp, bufsize); + fifo_write(mic->sample_buffer, tmp, bufsize); free(tmp); } - RARCH_LOG("[SDL audio]: Initialized microphone with device ID %u\n", microphone->device_id); - return microphone; + RARCH_LOG("[SDL audio]: Initialized microphone with device ID %u\n", mic->device_id); + return mic; error: - free(microphone); + free(mic); return NULL; } -static bool sdl_microphone_mic_alive(const void *data, const void *microphone_context) +static bool sdl_microphone_mic_alive(const void *data, const void *mic_context) { - const sdl_microphone_handle_t *microphone = (const sdl_microphone_handle_t*)microphone_context; - if (!microphone) + const sdl_microphone_handle_t *mic = (const sdl_microphone_handle_t*)mic_context; + if (!mic) return false; /* Both params must be non-null */ - return SDL_GetAudioDeviceStatus(microphone->device_id) == SDL_AUDIO_PLAYING; + return SDL_GetAudioDeviceStatus(mic->device_id) == SDL_AUDIO_PLAYING; } -static bool sdl_microphone_start_mic(void *driver_context, void *microphone_context) +static bool sdl_microphone_start_mic(void *driver_context, void *mic_context) { - sdl_microphone_handle_t *microphone = (sdl_microphone_handle_t*)microphone_context; - - if (!microphone) + sdl_microphone_handle_t *mic = (sdl_microphone_handle_t*)mic_context; + if (!mic) return false; - - SDL_PauseAudioDevice(microphone->device_id, false); - - if (SDL_GetAudioDeviceStatus(microphone->device_id) != SDL_AUDIO_PLAYING) + SDL_PauseAudioDevice(mic->device_id, false); + if (SDL_GetAudioDeviceStatus(mic->device_id) != SDL_AUDIO_PLAYING) { - RARCH_ERR("[SDL mic]: Failed to start microphone %u: %s\n", microphone->device_id, SDL_GetError()); + RARCH_ERR("[SDL mic]: Failed to start microphone %u: %s\n", mic->device_id, SDL_GetError()); return false; } - - RARCH_DBG("[SDL mic]: Started microphone %u\n", microphone->device_id); + RARCH_DBG("[SDL mic]: Started microphone %u\n", mic->device_id); return true; } -static bool sdl_microphone_stop_mic(void *driver_context, void *microphone_context) +static bool sdl_microphone_stop_mic(void *driver_context, void *mic_context) { - sdl_microphone_t *sdl = (sdl_microphone_t*)driver_context; - sdl_microphone_handle_t *microphone = (sdl_microphone_handle_t*)microphone_context; + sdl_microphone_t *sdl = (sdl_microphone_t*)driver_context; + sdl_microphone_handle_t *mic = (sdl_microphone_handle_t*)mic_context; - if (!sdl || !microphone) + if (!sdl || !mic) return false; - SDL_PauseAudioDevice(microphone->device_id, true); + SDL_PauseAudioDevice(mic->device_id, true); - switch (SDL_GetAudioDeviceStatus(microphone->device_id)) + switch (SDL_GetAudioDeviceStatus(mic->device_id)) { case SDL_AUDIO_PLAYING: - RARCH_ERR("[SDL mic]: Microphone %u failed to pause\n", microphone->device_id); + RARCH_ERR("[SDL mic]: Microphone %u failed to pause\n", mic->device_id); return false; case SDL_AUDIO_STOPPED: - RARCH_WARN("[SDL mic]: Microphone %u is in state STOPPED; it may not start again\n", microphone->device_id); + RARCH_WARN("[SDL mic]: Microphone %u is in state STOPPED; it may not start again\n", + mic->device_id); /* fall-through */ case SDL_AUDIO_PAUSED: break; default: - RARCH_ERR("[SDL mic]: Microphone %u is in unknown state\n", microphone->device_id); + RARCH_ERR("[SDL mic]: Microphone %u is in unknown state\n", + mic->device_id); return false; } @@ -305,64 +295,68 @@ static void sdl_microphone_set_nonblock_state(void *driver_context, bool state) sdl->nonblock = state; } -static int sdl_microphone_read(void *driver_context, void *microphone_context, void *buf, size_t size) +static int sdl_microphone_read(void *driver_context, void *mic_context, void *s, size_t len) { - int ret = 0; - sdl_microphone_t *sdl = (sdl_microphone_t*)driver_context; - sdl_microphone_handle_t *microphone = (sdl_microphone_handle_t*)microphone_context; + int ret = 0; + sdl_microphone_t *sdl = (sdl_microphone_t*)driver_context; + sdl_microphone_handle_t *mic = (sdl_microphone_handle_t*)mic_context; - if (!sdl || !microphone || !buf) + if (!sdl || !mic || !s) return -1; + /* If we shouldn't block on an empty queue... */ if (sdl->nonblock) - { /* If we shouldn't block on an empty queue... */ + { size_t avail, read_amt; - SDL_LockAudioDevice(microphone->device_id); /* Stop the SDL mic thread */ - avail = FIFO_READ_AVAIL(microphone->sample_buffer); - read_amt = avail > size ? size : avail; + SDL_LockAudioDevice(mic->device_id); /* Stop the SDL mic thread */ + avail = FIFO_READ_AVAIL(mic->sample_buffer); + read_amt = avail > len ? len : avail; if (read_amt > 0) { /* If the incoming queue isn't empty... */ - fifo_read(microphone->sample_buffer, buf, read_amt); + fifo_read(mic->sample_buffer, s, read_amt); /* ...then read as much data as will fit in buf */ } - SDL_UnlockAudioDevice(microphone->device_id); /* Let the mic thread run again */ + SDL_UnlockAudioDevice(mic->device_id); /* Let the mic thread run again */ ret = (int)read_amt; } else { size_t read = 0; - while (read < size) - { /* Until we've given the caller as much data as they've asked for... */ + /* Until we've given the caller as much data as they've asked for... */ + while (read < len) + { size_t avail; - SDL_LockAudioDevice(microphone->device_id); + SDL_LockAudioDevice(mic->device_id); /* Stop the SDL microphone thread from running */ - avail = FIFO_READ_AVAIL(microphone->sample_buffer); + avail = FIFO_READ_AVAIL(mic->sample_buffer); if (avail == 0) { /* If the incoming sample queue is empty... */ - SDL_UnlockAudioDevice(microphone->device_id); - /* Let the SDL microphone thread run so it can push some incoming samples */ + SDL_UnlockAudioDevice(mic->device_id); + /* Let the SDL microphone thread run so it can + * push some incoming samples */ #ifdef HAVE_THREADS - slock_lock(microphone->lock); - /* Let *only* the SDL microphone thread access the incoming sample queue. */ - - scond_wait(microphone->cond, microphone->lock); - /* Wait until the SDL microphone thread tells us it's added some samples. */ - - slock_unlock(microphone->lock); - /* Allow this thread to access the incoming sample queue, which we'll do next iteration */ + slock_lock(mic->lock); + /* Let *only* the SDL microphone thread access + * the incoming sample queue. */ + scond_wait(mic->cond, mic->lock); + /* Wait until the SDL microphone thread tells us + * it's added some samples. */ + slock_unlock(mic->lock); + /* Allow this thread to access the incoming sample queue, + * which we'll do next iteration */ #endif } else { - size_t read_amt = MIN(size - read, avail); - fifo_read(microphone->sample_buffer, buf + read, read_amt); - /* Read as many samples as we have available without underflowing the queue */ - - SDL_UnlockAudioDevice(microphone->device_id); + size_t read_amt = MIN(len - read, avail); + fifo_read(mic->sample_buffer, s + read, read_amt); + /* Read as many samples as we have available without + * underflowing the queue */ + SDL_UnlockAudioDevice(mic->device_id); /* Let the SDL microphone thread run again */ read += read_amt; } @@ -373,10 +367,10 @@ static int sdl_microphone_read(void *driver_context, void *microphone_context, v return ret; } -static bool sdl_microphone_mic_use_float(const void *driver_context, const void *microphone_context) +static bool sdl_microphone_mic_use_float(const void *driver_context, const void *mic_context) { - sdl_microphone_handle_t *microphone = (sdl_microphone_handle_t*)microphone_context; - return SDL_AUDIO_ISFLOAT(microphone->device_spec.format); + sdl_microphone_handle_t *mic = (sdl_microphone_handle_t*)mic_context; + return SDL_AUDIO_ISFLOAT(mic->device_spec.format); } microphone_driver_t microphone_sdl = { diff --git a/audio/drivers_microphone/wasapi.c b/audio/drivers_microphone/wasapi.c index fc51e4f175ff..94bdd74b6340 100644 --- a/audio/drivers_microphone/wasapi.c +++ b/audio/drivers_microphone/wasapi.c @@ -51,8 +51,42 @@ typedef struct wasapi_microphone bool nonblock; } wasapi_microphone_t; +static void wasapi_microphone_close_mic(void *driver_context, void *mic_context) +{ + DWORD ir; + HANDLE write_event; + wasapi_microphone_t *wasapi = (wasapi_microphone_t*)driver_context; + wasapi_microphone_handle_t *mic = (wasapi_microphone_handle_t*)mic_context; + + if (!wasapi || !mic) + return; + + write_event = mic->read_event; + + IFACE_RELEASE(mic->capture); + if (mic->client) + _IAudioClient_Stop(mic->client); + IFACE_RELEASE(mic->client); + IFACE_RELEASE(mic->device); + if (mic->buffer) + fifo_free(mic->buffer); + if (mic->device_name) + free(mic->device_name); + free(mic); + + ir = WaitForSingleObject(write_event, 20); + if (ir == WAIT_FAILED) + { + RARCH_ERR("[WASAPI mic]: WaitForSingleObject failed: %s\n", wasapi_error(GetLastError())); + } + + /* If event isn't signaled log and leak */ + if (ir != WAIT_OBJECT_0) + return; + + CloseHandle(write_event); +} -static void wasapi_microphone_close_mic(void *driver_context, void *microphone_context); static void *wasapi_microphone_init(void) { @@ -74,11 +108,8 @@ static void *wasapi_microphone_init(void) static void wasapi_microphone_free(void *driver_context) { wasapi_microphone_t *wasapi = (wasapi_microphone_t*)driver_context; - - if (!wasapi) - return; - - free(wasapi); + if (wasapi) + free(wasapi); } /** @@ -90,7 +121,7 @@ static void wasapi_microphone_free(void *driver_context) * @return The number of bytes in the queue after fetching input, * or -1 if there was an error. */ -static int wasapi_microphone_fetch_fifo(wasapi_microphone_handle_t *microphone) +static int wasapi_microphone_fetch_fifo(wasapi_microphone_handle_t *mic) { UINT32 next_packet_size = 0; /* Shared-mode capture streams split their input buffer into multiple packets, @@ -106,21 +137,20 @@ static int wasapi_microphone_fetch_fifo(wasapi_microphone_handle_t *microphone) UINT32 frames_read = 0; UINT32 bytes_read = 0; DWORD buffer_status_flags = 0; - HRESULT hr = _IAudioCaptureClient_GetBuffer(microphone->capture, + HRESULT hr = _IAudioCaptureClient_GetBuffer(mic->capture, &mic_input, &frames_read, &buffer_status_flags, NULL, NULL); if (FAILED(hr)) { RARCH_ERR("[WASAPI]: Failed to get capture device \"%s\"'s buffer: %s\n", - microphone->device_name, - hresult_name(hr)); + mic->device_name, hresult_name(hr)); return -1; } - bytes_read = frames_read * microphone->frame_size; + bytes_read = frames_read * mic->frame_size; /* If the queue has room for the packets we just got... */ - if (FIFO_WRITE_AVAIL(microphone->buffer) >= bytes_read && bytes_read > 0) + if (FIFO_WRITE_AVAIL(mic->buffer) >= bytes_read && bytes_read > 0) { - fifo_write(microphone->buffer, mic_input, bytes_read); + fifo_write(mic->buffer, mic_input, bytes_read); /* ...then enqueue the bytes directly from the mic's buffer */ } else /* Not enough space for new frames, so we can't consume this packet right now */ @@ -128,25 +158,23 @@ static int wasapi_microphone_fetch_fifo(wasapi_microphone_handle_t *microphone) /* If there's insufficient room in the queue, then we can't read the packet. * In that case, we leave the packet for next time. */ - hr = _IAudioCaptureClient_ReleaseBuffer(microphone->capture, frames_read); + hr = _IAudioCaptureClient_ReleaseBuffer(mic->capture, frames_read); if (FAILED(hr)) { RARCH_ERR("[WASAPI]: Failed to release capture device \"%s\"'s buffer after consuming %u frames: %s\n", - microphone->device_name, - frames_read, - hresult_name(hr)); + mic->device_name, frames_read, hresult_name(hr)); return -1; } /* If this is a shared-mode stream and we didn't run out of room in the sample queue... */ - if (!microphone->exclusive && frames_read > 0) + if (!mic->exclusive && frames_read > 0) { - hr = _IAudioCaptureClient_GetNextPacketSize(microphone->capture, &next_packet_size); + hr = _IAudioCaptureClient_GetNextPacketSize(mic->capture, &next_packet_size); /* Get the number of frames that the mic has for us. */ if (FAILED(hr)) { RARCH_ERR("[WASAPI]: Failed to get capture device \"%s\"'s next packet size: %s\n", - microphone->device_name, hresult_name(hr)); + mic->device_name, hresult_name(hr)); return -1; } } @@ -156,7 +184,7 @@ static int wasapi_microphone_fetch_fifo(wasapi_microphone_handle_t *microphone) } while (next_packet_size != 0); - return FIFO_READ_AVAIL(microphone->buffer); + return FIFO_READ_AVAIL(mic->buffer); } /** @@ -167,20 +195,20 @@ static int wasapi_microphone_fetch_fifo(wasapi_microphone_handle_t *microphone) * @return \c true if the event was signalled, * \c false if it timed out or there was an error. */ -static bool wasapi_microphone_wait_for_capture_event(wasapi_microphone_handle_t *microphone, DWORD timeout) +static bool wasapi_microphone_wait_for_capture_event(wasapi_microphone_handle_t *mic, DWORD timeout) { /*...then let's wait for the mic to tell us that samples are ready. */ - switch (WaitForSingleObject(microphone->read_event, timeout)) + switch (WaitForSingleObject(mic->read_event, timeout)) { case WAIT_OBJECT_0: /* Okay, there's data available. */ return true; case WAIT_TIMEOUT: /* Time out; there's nothing here for us. */ - RARCH_ERR("[WASAPI]: Failed to wait for capture device \"%s\" event: Timeout after %ums\n", microphone->device_name, timeout); + RARCH_ERR("[WASAPI]: Failed to wait for capture device \"%s\" event: Timeout after %ums\n", mic->device_name, timeout); break; default: - RARCH_ERR("[WASAPI]: Failed to wait for capture device \"%s\" event: %s\n", microphone->device_name, wasapi_error(GetLastError())); + RARCH_ERR("[WASAPI]: Failed to wait for capture device \"%s\" event: %s\n", mic->device_name, wasapi_error(GetLastError())); break; } return false; @@ -202,22 +230,20 @@ static bool wasapi_microphone_wait_for_capture_event(wasapi_microphone_handle_t * or -1 if there was an error (including timeout). */ static int wasapi_microphone_read_buffered( - wasapi_microphone_handle_t *microphone, - void *buffer, - size_t buffer_size, + wasapi_microphone_handle_t *mic, void *s, size_t len, DWORD timeout) { int bytes_read = 0; /* Number of bytes sent to the core */ - int bytes_available = FIFO_READ_AVAIL(microphone->buffer); + int bytes_available = FIFO_READ_AVAIL(mic->buffer); /* If we don't have any queued samples to give to the core... */ if (!bytes_available) { /* If we couldn't wait for the microphone to signal a capture event... */ - if (!wasapi_microphone_wait_for_capture_event(microphone, timeout)) + if (!wasapi_microphone_wait_for_capture_event(mic, timeout)) return -1; - bytes_available = wasapi_microphone_fetch_fifo(microphone); + bytes_available = wasapi_microphone_fetch_fifo(mic); /* If we couldn't fetch samples from the microphone... */ if (bytes_available < 0) return -1; @@ -225,34 +251,33 @@ static int wasapi_microphone_read_buffered( /* Now that we have samples available, let's give them to the core */ - bytes_read = MIN((int)buffer_size, bytes_available); - fifo_read(microphone->buffer, buffer, bytes_read); + bytes_read = MIN((int)len, bytes_available); + fifo_read(mic->buffer, s, bytes_read); /* Read data from the sample queue and store it in the provided buffer */ - return bytes_read; } -static int wasapi_microphone_read(void *driver_context, void *mic_context, void *buffer, size_t buffer_size) +static int wasapi_microphone_read(void *driver_context, void *mic_context, void *s, size_t len) { - int bytes_read = 0; - wasapi_microphone_t *wasapi = (wasapi_microphone_t *)driver_context; - wasapi_microphone_handle_t *microphone = (wasapi_microphone_handle_t*)mic_context; + int bytes_read = 0; + wasapi_microphone_t *wasapi = (wasapi_microphone_t *)driver_context; + wasapi_microphone_handle_t *mic = (wasapi_microphone_handle_t*)mic_context; - if (!wasapi || !microphone || !buffer) + if (!wasapi || !mic || !s) return -1; /* If microphones shouldn't block... */ if (wasapi->nonblock) - return wasapi_microphone_read_buffered(microphone, buffer, buffer_size, 0); + return wasapi_microphone_read_buffered(mic, s, len, 0); - if (microphone->exclusive) + if (mic->exclusive) { int read; - for (read = -1; (size_t)bytes_read < buffer_size; bytes_read += read) + for (read = -1; (size_t)bytes_read < len; bytes_read += read) { - read = wasapi_microphone_read_buffered(microphone, - (char *)buffer + bytes_read, - buffer_size - bytes_read, + read = wasapi_microphone_read_buffered(mic, + (char *)s + bytes_read, + len - bytes_read, INFINITE); if (read == -1) return -1; @@ -261,11 +286,11 @@ static int wasapi_microphone_read(void *driver_context, void *mic_context, void else { int read; - for (read = -1; (size_t)bytes_read < buffer_size; bytes_read += read) + for (read = -1; (size_t)bytes_read < len; bytes_read += read) { - read = wasapi_microphone_read_buffered(microphone, - (char *)buffer + bytes_read, - buffer_size - bytes_read, + read = wasapi_microphone_read_buffered(mic, + (char *)s + bytes_read, + len - bytes_read, INFINITE); if (read == -1) return -1; @@ -278,7 +303,6 @@ static int wasapi_microphone_read(void *driver_context, void *mic_context, void static void wasapi_microphone_set_nonblock_state(void *driver_context, bool nonblock) { wasapi_microphone_t *wasapi = (wasapi_microphone_t*)driver_context; - wasapi->nonblock = nonblock; } @@ -286,81 +310,80 @@ static void *wasapi_microphone_open_mic(void *driver_context, const char *device unsigned latency, unsigned *new_rate) { HRESULT hr; - settings_t *settings = config_get_ptr(); - DWORD flags = 0; - UINT32 frame_count = 0; - REFERENCE_TIME dev_period = 0; - BYTE *dest = NULL; - bool float_format = settings->bools.microphone_wasapi_float_format; - bool exclusive_mode = settings->bools.microphone_wasapi_exclusive_mode; - unsigned sh_buffer_length = settings->uints.microphone_wasapi_sh_buffer_length; - wasapi_microphone_handle_t *microphone = (wasapi_microphone_handle_t*)calloc( + settings_t *settings = config_get_ptr(); + DWORD flags = 0; + UINT32 frame_count = 0; + REFERENCE_TIME dev_period = 0; + BYTE *dest = NULL; + bool float_format = settings->bools.microphone_wasapi_float_format; + bool exclusive_mode = settings->bools.microphone_wasapi_exclusive_mode; + unsigned sh_buffer_length = settings->uints.microphone_wasapi_sh_buffer_length; + wasapi_microphone_handle_t *mic = (wasapi_microphone_handle_t*)calloc( 1, sizeof(wasapi_microphone_handle_t)); - if (!microphone) + if (!mic) return NULL; - microphone->exclusive = exclusive_mode; - microphone->device = wasapi_init_device(device, eCapture); + mic->exclusive = exclusive_mode; + mic->device = wasapi_init_device(device, eCapture); /* If we requested a particular capture device, but couldn't open it... */ - if (device && !microphone->device) + if (device && !mic->device) { RARCH_WARN("[WASAPI]: Failed to open requested capture device \"%s\", attempting to open default device\n", device); - microphone->device = wasapi_init_device(NULL, eCapture); + mic->device = wasapi_init_device(NULL, eCapture); } - if (!microphone->device) + if (!mic->device) { RARCH_ERR("[WASAPI]: Failed to open capture device\n"); goto error; } - microphone->device_name = mmdevice_name(microphone->device); - if (!microphone->device_name) + if (!(mic->device_name = mmdevice_name(mic->device))) { RARCH_ERR("[WASAPI]: Failed to get friendly name of capture device\n"); goto error; } - microphone->client = wasapi_init_client(microphone->device, - µphone->exclusive, &float_format, &rate, latency, 1); - if (!microphone->client) + mic->client = wasapi_init_client(mic->device, + &mic->exclusive, &float_format, &rate, latency, 1); + if (!mic->client) { - RARCH_ERR("[WASAPI]: Failed to open client for capture device \"%s\"\n", microphone->device_name); + RARCH_ERR("[WASAPI]: Failed to open client for capture device \"%s\"\n", mic->device_name); goto error; } - hr = _IAudioClient_GetBufferSize(microphone->client, &frame_count); + hr = _IAudioClient_GetBufferSize(mic->client, &frame_count); if (FAILED(hr)) { RARCH_ERR("[WASAPI]: Failed to get buffer size of IAudioClient for capture device \"%s\": %s\n", - microphone->device_name, hresult_name(hr)); + mic->device_name, hresult_name(hr)); goto error; } - microphone->frame_size = float_format ? sizeof(float) : sizeof(int16_t); - microphone->engine_buffer_size = frame_count * microphone->frame_size; + mic->frame_size = float_format ? sizeof(float) : sizeof(int16_t); + mic->engine_buffer_size = frame_count * mic->frame_size; /* If this mic should be used *exclusively* by RetroArch... */ - if (microphone->exclusive) + if (mic->exclusive) { - microphone->buffer = fifo_new(microphone->engine_buffer_size); - if (!microphone->buffer) + mic->buffer = fifo_new(mic->engine_buffer_size); + if (!mic->buffer) { RARCH_ERR("[WASAPI]: Failed to initialize FIFO queue for capture device.\n"); goto error; } RARCH_LOG("[WASAPI]: Intermediate exclusive-mode capture buffer length is %u frames (%.1fms, %u bytes).\n", - frame_count, (double)frame_count * 1000.0 / rate, microphone->engine_buffer_size); + frame_count, (double)frame_count * 1000.0 / rate, mic->engine_buffer_size); } else { /* If the user selected the "default" shared buffer length... */ if (sh_buffer_length <= 0) { - hr = _IAudioClient_GetDevicePeriod(microphone->client, &dev_period, NULL); + hr = _IAudioClient_GetDevicePeriod(mic->client, &dev_period, NULL); if (FAILED(hr)) goto error; @@ -369,30 +392,29 @@ static void *wasapi_microphone_open_mic(void *driver_context, const char *device * Doubling it seems to work okay. Dunno why. */ } - microphone->buffer = fifo_new(sh_buffer_length * microphone->frame_size); - if (!microphone->buffer) + mic->buffer = fifo_new(sh_buffer_length * mic->frame_size); + if (!mic->buffer) goto error; RARCH_LOG("[WASAPI]: Intermediate shared-mode capture buffer length is %u frames (%.1fms, %u bytes).\n", - sh_buffer_length, (double)sh_buffer_length * 1000.0 / rate, sh_buffer_length * microphone->frame_size); + sh_buffer_length, (double)sh_buffer_length * 1000.0 / rate, sh_buffer_length * mic->frame_size); } - microphone->read_event = CreateEventA(NULL, FALSE, FALSE, NULL); - if (!microphone->read_event) + if (!(mic->read_event = CreateEventA(NULL, FALSE, FALSE, NULL))) { RARCH_ERR("[WASAPI]: Failed to allocate capture device's event handle\n"); goto error; } - hr = _IAudioClient_SetEventHandle(microphone->client, microphone->read_event); + hr = _IAudioClient_SetEventHandle(mic->client, mic->read_event); if (FAILED(hr)) { RARCH_ERR("[WASAPI]: Failed to set capture device's event handle: %s\n", hresult_name(hr)); goto error; } - hr = _IAudioClient_GetService(microphone->client, - IID_IAudioCaptureClient, (void**)µphone->capture); + hr = _IAudioClient_GetService(mic->client, + IID_IAudioCaptureClient, (void**)&mic->capture); if (FAILED(hr)) { RARCH_ERR("[WASAPI]: Failed to get capture device's IAudioCaptureClient service: %s\n", hresult_name(hr)); @@ -400,132 +422,81 @@ static void *wasapi_microphone_open_mic(void *driver_context, const char *device } /* Get and release the buffer, just to ensure that we can. */ - hr = _IAudioCaptureClient_GetBuffer(microphone->capture, &dest, &frame_count, &flags, NULL, NULL); + hr = _IAudioCaptureClient_GetBuffer(mic->capture, &dest, &frame_count, &flags, NULL, NULL); if (FAILED(hr)) { RARCH_ERR("[WASAPI]: Failed to get capture client buffer: %s\n", hresult_name(hr)); goto error; } - hr = _IAudioCaptureClient_ReleaseBuffer(microphone->capture, 0); + hr = _IAudioCaptureClient_ReleaseBuffer(mic->capture, 0); if (FAILED(hr)) { RARCH_ERR("[WASAPI]: Failed to release capture client buffer: %s\n", hresult_name(hr)); goto error; } + /* The rate was (possibly) modified when we initialized the client */ if (new_rate) - { /* The rate was (possibly) modified when we initialized the client */ *new_rate = rate; - } - return microphone; + return mic; error: - IFACE_RELEASE(microphone->capture); - IFACE_RELEASE(microphone->client); - IFACE_RELEASE(microphone->device); - if (microphone->read_event) - CloseHandle(microphone->read_event); - if (microphone->buffer) - fifo_free(microphone->buffer); - if (microphone->device_name) - free(microphone->device_name); - free(microphone); - + IFACE_RELEASE(mic->capture); + IFACE_RELEASE(mic->client); + IFACE_RELEASE(mic->device); + if (mic->read_event) + CloseHandle(mic->read_event); + if (mic->buffer) + fifo_free(mic->buffer); + if (mic->device_name) + free(mic->device_name); + free(mic); return NULL; } -static void wasapi_microphone_close_mic(void *driver_context, void *microphone_context) +static bool wasapi_microphone_start_mic(void *driver_context, void *mic_context) { - DWORD ir; - wasapi_microphone_t *wasapi = (wasapi_microphone_t*)driver_context; - wasapi_microphone_handle_t *microphone = (wasapi_microphone_handle_t*)microphone_context; - HANDLE write_event; - - if (!wasapi || !microphone) - return; - - write_event = microphone->read_event; - - IFACE_RELEASE(microphone->capture); - if (microphone->client) - _IAudioClient_Stop(microphone->client); - IFACE_RELEASE(microphone->client); - IFACE_RELEASE(microphone->device); - if (microphone->buffer) - fifo_free(microphone->buffer); - if (microphone->device_name) - free(microphone->device_name); - free(microphone); - - ir = WaitForSingleObject(write_event, 20); - if (ir == WAIT_FAILED) - { - RARCH_ERR("[WASAPI mic]: WaitForSingleObject failed: %s\n", wasapi_error(GetLastError())); - } - - /* If event isn't signaled log and leak */ - if (ir != WAIT_OBJECT_0) - return; - - CloseHandle(write_event); -} - -static bool wasapi_microphone_start_mic(void *driver_context, void *microphone_context) -{ - wasapi_microphone_handle_t *microphone = (wasapi_microphone_handle_t*)microphone_context; + wasapi_microphone_handle_t *mic = (wasapi_microphone_handle_t*)mic_context; HRESULT hr; - (void)driver_context; - - if (!microphone) + if (!mic) return false; + hr = _IAudioClient_Start(mic->client); - hr = _IAudioClient_Start(microphone->client); - + /* Starting an already-active microphone is not an error */ if (SUCCEEDED(hr) || hr == AUDCLNT_E_NOT_STOPPED) - { /* Starting an already-active microphone is not an error */ - microphone->running = true; - } + mic->running = true; else { RARCH_ERR("[WASAPI mic]: Failed to start capture device \"%s\"'s IAudioClient: %s\n", - microphone->device_name, hresult_name(hr)); - microphone->running = false; + mic->device_name, hresult_name(hr)); + mic->running = false; } - - return microphone->running; + return mic->running; } -static bool wasapi_microphone_stop_mic(void *driver_context, void *microphone_context) +static bool wasapi_microphone_stop_mic(void *driver_context, void *mic_context) { - wasapi_microphone_handle_t *microphone = (wasapi_microphone_handle_t*)microphone_context; + wasapi_microphone_handle_t *mic = (wasapi_microphone_handle_t*)mic_context; HRESULT hr; - (void)driver_context; - - if (!microphone) + if (!mic) return false; - - hr = _IAudioClient_Stop(microphone->client); + hr = _IAudioClient_Stop(mic->client); if (FAILED(hr)) { RARCH_ERR("[WASAPI mic]: Failed to stop capture device \"%s\"'s IAudioClient: %s\n", - microphone->device_name, hresult_name(hr)); + mic->device_name, hresult_name(hr)); return false; } - - RARCH_LOG("[WASAPI mic]: Stopped capture device \"%s\".\n", microphone->device_name); - - microphone->running = false; - + RARCH_LOG("[WASAPI mic]: Stopped capture device \"%s\".\n", mic->device_name); + mic->running = false; return true; } static bool wasapi_microphone_mic_alive(const void *driver_context, const void *mic_context) { - wasapi_microphone_handle_t *microphone = (wasapi_microphone_handle_t *)mic_context; - (void)driver_context; - - return microphone && microphone->running; + wasapi_microphone_handle_t *mic = (wasapi_microphone_handle_t *)mic_context; + return mic && mic->running; } static struct string_list *wasapi_microphone_device_list_new(const void *driver_context) @@ -536,20 +507,14 @@ static struct string_list *wasapi_microphone_device_list_new(const void *driver_ static void wasapi_microphone_device_list_free(const void *driver_context, struct string_list *devices) { struct string_list *sl = (struct string_list*)devices; - if (sl) string_list_free(sl); } -static bool wasapi_microphone_use_float(const void *driver_context, const void *microphone_context) +static bool wasapi_microphone_use_float(const void *driver_context, const void *mic_context) { - wasapi_microphone_handle_t *microphone = (wasapi_microphone_handle_t *)microphone_context; - (void)driver_context; - - if (!microphone) - return false; - - return microphone->frame_size == sizeof(float); + wasapi_microphone_handle_t *mic = (wasapi_microphone_handle_t *)mic_context; + return (mic && (mic->frame_size == sizeof(float))); } microphone_driver_t microphone_wasapi = { diff --git a/input/drivers/udev_input.c b/input/drivers/udev_input.c index 8dcecebf2846..0a1205ad1ef9 100644 --- a/input/drivers/udev_input.c +++ b/input/drivers/udev_input.c @@ -574,7 +574,7 @@ typedef struct udev_input } udev_input_t; #ifdef UDEV_XKB_HANDLING -int init_xkb(int fd, size_t size); +int init_xkb(int fd, size_t len); void free_xkb(void); int handle_xkb(int code, int value); #endif @@ -781,7 +781,7 @@ static int16_t udev_mouse_get_y(const udev_input_mouse_t *mouse) return y + (y < 0 ? -0.5 : 0.5); } -static bool udev_mouse_get_pointer(const udev_input_mouse_t *mouse, +static bool udev_mouse_get_pointer(const udev_input_mouse_t *mouse, bool screen, bool confined, int16_t *ret_x, int16_t *ret_y) { struct video_viewport vp = {0}; @@ -823,7 +823,7 @@ static bool udev_mouse_get_pointer(const udev_input_mouse_t *mouse, { return false; } - + if (screen) { *ret_x = res_screen_x; @@ -1209,14 +1209,14 @@ static const char *udev_mt_code_to_str(uint32_t code) * * @param label Label to prefix the message with. * @param request_data Input data structure to dump. - * @param count Number of elements in the values array. + * @param len Number of elements in the values array. */ -static void udev_dump_mt_request_data(const char *label, const uint8_t *request_data, size_t count) +static void udev_dump_mt_request_data(const char *label, const uint8_t *request_data, size_t len) { uint32_t *mt_req_code = (uint32_t*) request_data; int32_t *mt_req_values = ((int32_t*) request_data) + 1; RARCH_DBG("[udev] %s: Req { %s, [ ", label, udev_mt_code_to_str(*mt_req_code)); - for (; mt_req_values < (((int32_t*) mt_req_code) + count + 1); ++mt_req_values) + for (; mt_req_values < (((int32_t*) mt_req_code) + len + 1); ++mt_req_values) { RARCH_DBG("%d, ", *mt_req_values); } diff --git a/input/drivers_hid/iohidmanager_hid.c b/input/drivers_hid/iohidmanager_hid.c index 74d63006f999..0d347d09d390 100644 --- a/input/drivers_hid/iohidmanager_hid.c +++ b/input/drivers_hid/iohidmanager_hid.c @@ -269,14 +269,14 @@ static bool iohidmanager_hid_joypad_rumble(void *data, unsigned pad, } static void iohidmanager_hid_device_send_control(void *data, - uint8_t* data_buf, size_t len) + uint8_t *s, size_t len) { struct iohidmanager_hid_adapter *adapter = (struct iohidmanager_hid_adapter*)data; if (adapter) IOHIDDeviceSetReport(adapter->handle, - kIOHIDReportTypeOutput, 0x01, data_buf + 1, len - 1); + kIOHIDReportTypeOutput, 0x01, s + 1, len - 1); } static void iohidmanager_hid_device_report(void *data, @@ -1088,19 +1088,19 @@ static void iohidmanager_hid_free(const void *data) static void iohidmanager_hid_poll(void *data) { } -static int32_t iohidmanager_set_report(void *handle, uint8_t report_type, uint8_t report_id, uint8_t *data_buf, size_t len) +static int32_t iohidmanager_set_report(void *handle, uint8_t report_type, uint8_t report_id, uint8_t *s, size_t len) { struct iohidmanager_hid_adapter *adapter = (struct iohidmanager_hid_adapter*)handle; if (adapter) return IOHIDDeviceSetReport(adapter->handle, translate_hid_report_type(report_type), report_id, - data_buf + 1, len - 1); + s + 1, len - 1); return -1; } static int32_t iohidmanager_get_report(void *handle, uint8_t report_type, uint8_t report_id, - uint8_t *data_buf, size_t len) + uint8_t *s, size_t len) { struct iohidmanager_hid_adapter *adapter = (struct iohidmanager_hid_adapter*)handle; @@ -1110,7 +1110,7 @@ static int32_t iohidmanager_get_report(void *handle, uint8_t report_type, uint8_ CFIndex length = len; return IOHIDDeviceGetReport(adapter->handle, translate_hid_report_type(report_type), - report_id, data_buf, &length); + report_id, s, &length); } return -1; diff --git a/input/drivers_hid/libusb_hid.c b/input/drivers_hid/libusb_hid.c index 30ad72b47dbe..46d336e72f2a 100644 --- a/input/drivers_hid/libusb_hid.c +++ b/input/drivers_hid/libusb_hid.c @@ -89,26 +89,26 @@ static void adapter_thread(void *data) while (!adapter->quitting) { - size_t send_command_size; int tmp; + size_t _len; int report_number; int size = 0; slock_lock(adapter->send_control_lock); if (FIFO_READ_AVAIL(adapter->send_control_buffer) - >= sizeof(send_command_size)) + >= sizeof(_len)) { fifo_read(adapter->send_control_buffer, - &send_command_size, sizeof(send_command_size)); + &_len, sizeof(_len)); if (FIFO_READ_AVAIL(adapter->send_control_buffer) - >= sizeof(send_command_size)) + >= sizeof(_len)) { fifo_read(adapter->send_control_buffer, - send_command_buf, send_command_size); + send_command_buf, _len); libusb_interrupt_transfer(adapter->handle, adapter->endpoint_out, send_command_buf, - send_command_size, &tmp, 1000); + _len, &tmp, 1000); } } slock_unlock(adapter->send_control_lock); @@ -124,7 +124,7 @@ static void adapter_thread(void *data) } static void libusb_hid_device_send_control(void *data, - uint8_t* data_buf, size_t len) + uint8_t *s, size_t len) { struct libusb_adapter *adapter = (struct libusb_adapter*)data; @@ -136,7 +136,7 @@ static void libusb_hid_device_send_control(void *data, if (FIFO_WRITE_AVAIL(adapter->send_control_buffer) >= len + sizeof(len)) { fifo_write(adapter->send_control_buffer, &len, sizeof(len)); - fifo_write(adapter->send_control_buffer, data_buf, len); + fifo_write(adapter->send_control_buffer, s, len); } else { diff --git a/input/drivers_hid/wiiusb_hid.c b/input/drivers_hid/wiiusb_hid.c index cb51f75e9d4b..ec29be501de9 100644 --- a/input/drivers_hid/wiiusb_hid.c +++ b/input/drivers_hid/wiiusb_hid.c @@ -120,21 +120,21 @@ static int32_t wiiusb_hid_read_cb(int32_t size, void *data) } static void wiiusb_hid_device_send_control(void *data, - uint8_t* data_buf, size_t len) + uint8_t *s, size_t len) { uint8_t control_type; struct wiiusb_adapter *adapter = (struct wiiusb_adapter*)data; - if (!adapter || !data_buf || !adapter->send_control_buffer) + if (!adapter || !s || !adapter->send_control_buffer) return; /* first byte contains the type of control to use * which can be NONE, INT_MSG, CTRL_MSG, CTRL_MSG2 */ - control_type = data_buf[0]; + control_type = s[0]; /* decrement size by one as we are getting rid of first byte */ adapter->send_control_size = len - 1; /* increase the buffer address so we access the actual data */ - data_buf++; - memcpy(adapter->send_control_buffer, data_buf, adapter->send_control_size); + s++; + memcpy(adapter->send_control_buffer, s, adapter->send_control_size); /* Activate it so it can be processed in the adapter thread */ adapter->send_control_type = control_type; } @@ -143,20 +143,15 @@ static void wiiusb_hid_device_add_autodetect(unsigned idx, const char *device_name, const char *driver_name, uint16_t dev_vid, uint16_t dev_pid) { - input_autoconfigure_connect( - device_name, - NULL, - "hid", - idx, - dev_vid, - dev_pid); + input_autoconfigure_connect(device_name, NULL, "hid", + idx, dev_vid, dev_pid); } static void wiiusb_get_description(usb_device_entry *device, struct wiiusb_adapter *adapter, usb_devdesc *devdesc) { - unsigned char c; unsigned i, k; + unsigned char c; for (c = 0; c < devdesc->bNumConfigurations; c++) { diff --git a/input/drivers_keyboard/keyboard_event_xkb.c b/input/drivers_keyboard/keyboard_event_xkb.c index 2aa32fddbdc5..75f2912f6ca5 100644 --- a/input/drivers_keyboard/keyboard_event_xkb.c +++ b/input/drivers_keyboard/keyboard_event_xkb.c @@ -58,21 +58,17 @@ void free_xkb(void) int init_xkb(int fd, size_t len) { - mod_map_idx = (xkb_mod_index_t *)calloc( + mod_map_idx = (xkb_mod_index_t *)calloc( MOD_MAP_SIZE, sizeof(xkb_mod_index_t)); if (!mod_map_idx) goto error; - mod_map_bit = (uint16_t*) - calloc(MOD_MAP_SIZE, sizeof(uint16_t)); - - if (!mod_map_bit) + if (!(mod_map_bit = (uint16_t*) + calloc(MOD_MAP_SIZE, sizeof(uint16_t)))) goto error; - xkb_ctx = xkb_context_new(XKB_CONTEXT_NO_FLAGS); - - if (xkb_ctx) + if ((xkb_ctx = xkb_context_new(XKB_CONTEXT_NO_FLAGS))) { if (fd >= 0) { diff --git a/input/input_driver.c b/input/input_driver.c index 398d181c62e4..907dfa239903 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -4004,7 +4004,7 @@ void osk_update_last_codepoint( #ifdef HAVE_LANGEXTRA /* combine 3 korean elements. make utf8 character */ -static unsigned get_kr_utf8( int c1,int c2,int c3) +static unsigned get_kr_utf8(int c1, int c2, int c3) { int uv = c1 * (28 * 21) + c2 * 28 + c3 + 0xac00; int tv = (uv >> 12) | ((uv & 0x0f00) << 2) | ((uv & 0xc0) << 2) | ((uv & 0x3f) << 16); @@ -4012,7 +4012,7 @@ static unsigned get_kr_utf8( int c1,int c2,int c3) } /* utf8 korean composition */ -static unsigned get_kr_composition( char* pcur, char* padd) +static unsigned get_kr_composition(char* pcur, char* padd) { size_t _len; static char cc1[] = {"ㄱㄱㄲ ㄷㄷㄸ ã…‚ã…‚ã…ƒ ã……ã……ã…† ㅈㅈㅉ"}; @@ -4296,7 +4296,7 @@ void input_event_osk_append( int ptr, bool show_symbol_pages, const char *word, - size_t word_len) + size_t len) { #ifdef HAVE_LANGEXTRA if (string_is_equal(word, "\xe2\x87\xa6")) /* backspace character */ @@ -4327,7 +4327,7 @@ void input_event_osk_append( else *osk_idx = ((enum osk_type)(OSK_TYPE_UNKNOWN + 1)); } - else if (*osk_idx == OSK_KOREAN_PAGE1 && word && word_len == 3) + else if (*osk_idx == OSK_KOREAN_PAGE1 && word && len == 3) { unsigned character = *((unsigned*)word) | 0x01000000; input_keyboard_line_event(&input_driver_st, keyboard_line, character); @@ -4350,7 +4350,7 @@ void input_event_osk_append( #endif else { - input_keyboard_line_append(keyboard_line, word, word_len); + input_keyboard_line_append(keyboard_line, word, len); osk_update_last_codepoint( osk_last_codepoint, osk_last_codepoint_len, @@ -6212,16 +6212,16 @@ void bsv_movie_next_frame(input_driver_state_t *input_st) { retro_ctx_serialize_info_t serial_info; uint8_t frame_tok = REPLAY_TOKEN_CHECKPOINT_FRAME; - size_t info_size = core_serialize_size(); - uint64_t size = swap_if_big64(info_size); - uint8_t *st = (uint8_t*)malloc(info_size); + size_t _len = core_serialize_size(); + uint64_t size = swap_if_big64(_len); + uint8_t *st = (uint8_t*)malloc(_len); serial_info.data = st; - serial_info.size = info_size; + serial_info.size = _len; core_serialize(&serial_info); /* "next frame is a checkpoint" */ intfstream_write(handle->file, (uint8_t *)(&frame_tok), sizeof(uint8_t)); intfstream_write(handle->file, &size, sizeof(uint64_t)); - intfstream_write(handle->file, st, info_size); + intfstream_write(handle->file, st, _len); free(st); } else diff --git a/input/input_osk.h b/input/input_osk.h index 8c1f9d607e57..a7733bd96646 100644 --- a/input/input_osk.h +++ b/input/input_osk.h @@ -56,7 +56,7 @@ void input_event_osk_append( int ptr, bool show_symbol_pages, const char *word, - size_t word_len); + size_t len); void osk_update_last_codepoint( unsigned *last_codepoint, diff --git a/libretro-db/query.c b/libretro-db/query.c index f8b861d46349..f69d63a473d8 100644 --- a/libretro-db/query.c +++ b/libretro-db/query.c @@ -94,10 +94,8 @@ struct registered_func /* Forward declarations */ static struct buffer query_parse_method_call(char *s, size_t len, - struct buffer buff, - struct invocation *invocation, const char **error); -static struct buffer query_parse_table(char *s, - size_t len, struct buffer buff, + struct buffer buff, struct invocation *invocation, const char **error); +static struct buffer query_parse_table(char *s, size_t len, struct buffer buff, struct invocation *invocation, const char **error); /* Errors */ @@ -349,7 +347,7 @@ static struct buffer query_expect_eof(char *s, size_t len, static int query_peek(struct buffer buff, const char * data, size_t len) { - size_t remain = buff.len - buff.offset; + size_t remain = buff.len - buff.offset; if (remain < len) return 0; return (strncmp(buff.data + buff.offset, data, len) == 0); @@ -466,10 +464,9 @@ static struct buffer query_parse_string( return buff; } -static struct buffer query_parse_value( - char *s, size_t len, - struct buffer buff, - struct rmsgpack_dom_value *value, const char **error) +static struct buffer query_parse_value(char *s, size_t len, + struct buffer buff, struct rmsgpack_dom_value *value, + const char **error) { buff = query_chomp(buff); @@ -502,8 +499,7 @@ static struct buffer query_parse_value( } static void query_peek_char(char *s, size_t len, - struct buffer buff, char *c, - const char **error) + struct buffer buff, char *c, const char **error) { if ((unsigned)buff.offset >= buff.len) { @@ -518,10 +514,8 @@ static void query_peek_char(char *s, size_t len, *c = buff.data[buff.offset]; } -static struct buffer query_get_ident( - char *s, size_t _len, - struct buffer buff, - const char **ident, +static struct buffer query_get_ident(char *s, size_t _len, + struct buffer buff, const char **ident, size_t *len, const char **error) { char c = '\0'; @@ -622,102 +616,6 @@ static struct buffer query_parse_argument( return buff; } -static struct buffer query_parse_method_call( - char *s, size_t len, struct buffer buff, - struct invocation *invocation, const char **error) -{ - size_t func_name_len; - unsigned i; - struct argument args[QUERY_MAX_ARGS]; - unsigned argi = 0; - const char *func_name = NULL; - struct registered_func *rf = registered_functions; - - invocation->func = NULL; - - buff = query_get_ident(s, len, - buff, &func_name, &func_name_len, error); - if (*error) - goto clean; - - buff = query_chomp(buff); - buff = query_expect_char(s, len, buff, '(', error); - if (*error) - goto clean; - - while (rf->name) - { - if (strncmp(rf->name, func_name, func_name_len) == 0) - { - invocation->func = rf->func; - break; - } - rf++; - } - - if (!invocation->func) - { - query_raise_unknown_function(s, len, - buff.offset, func_name, - func_name_len, error); - goto clean; - } - - buff = query_chomp(buff); - while (!query_peek(buff, ")", STRLEN_CONST(")"))) - { - if (argi >= QUERY_MAX_ARGS) - { - strlcpy(s, "Too many arguments in function call.", len); - *error = s; - goto clean; - } - - buff = query_parse_argument(s, len, buff, &args[argi], error); - - if (*error) - goto clean; - - argi++; - buff = query_chomp(buff); - buff = query_expect_char(s, len, buff, ',', error); - - if (*error) - { - *error = NULL; - break; - } - buff = query_chomp(buff); - } - buff = query_expect_char(s, len, buff, ')', error); - - if (*error) - goto clean; - - invocation->argc = argi; - invocation->argv = (argi > 0) ? (struct argument*) - malloc(sizeof(struct argument) * argi) : NULL; - - if (!invocation->argv) - { - s[0] = 'O'; - s[1] = 'O'; - s[2] = 'M'; - s[3] = '\0'; - *error = s; - goto clean; - } - memcpy(invocation->argv, args, - sizeof(struct argument) * argi); - - return buff; - -clean: - for (i = 0; i < argi; i++) - query_argument_free(&args[i]); - return buff; -} - static struct rmsgpack_dom_value query_func_all_map( struct rmsgpack_dom_value input, unsigned argc, const struct argument *argv) @@ -776,10 +674,10 @@ static struct buffer query_parse_table( struct invocation *invocation, const char **error) { unsigned i; - size_t ident_len; + size_t _len; + unsigned argi = 0; struct argument args[QUERY_MAX_ARGS]; const char *ident_name = NULL; - unsigned argi = 0; buff = query_chomp(buff); buff = query_expect_char(s, len, buff, '{', error); @@ -801,25 +699,21 @@ static struct buffer query_parse_table( if (ISALPHA((int)buff.data[buff.offset])) { buff = query_get_ident(s, len, - buff, &ident_name, &ident_len, error); + buff, &ident_name, &_len, error); if (!*error) { args[argi].a.value.type = RDT_STRING; - args[argi].a.value.val.string.len = (uint32_t)ident_len; + args[argi].a.value.val.string.len = (uint32_t)_len; args[argi].a.value.val.string.buff = (char*)calloc( - ident_len + 1, - sizeof(char) - ); + _len + 1, sizeof(char)); if (!args[argi].a.value.val.string.buff) goto clean; strncpy( args[argi].a.value.val.string.buff, - ident_name, - ident_len - ); + ident_name, _len); } } else @@ -892,6 +786,101 @@ static struct buffer query_parse_table( return buff; } +static struct buffer query_parse_method_call( + char *s, size_t len, struct buffer buff, + struct invocation *invocation, const char **error) +{ + unsigned i; + size_t _len; + struct argument args[QUERY_MAX_ARGS]; + unsigned argi = 0; + const char *func_name = NULL; + struct registered_func *rf = registered_functions; + + invocation->func = NULL; + + buff = query_get_ident(s, len, + buff, &func_name, &_len, error); + if (*error) + goto clean; + + buff = query_chomp(buff); + buff = query_expect_char(s, len, buff, '(', error); + if (*error) + goto clean; + + while (rf->name) + { + if (strncmp(rf->name, func_name, _len) == 0) + { + invocation->func = rf->func; + break; + } + rf++; + } + + if (!invocation->func) + { + query_raise_unknown_function(s, len, + buff.offset, func_name, _len, error); + goto clean; + } + + buff = query_chomp(buff); + while (!query_peek(buff, ")", STRLEN_CONST(")"))) + { + if (argi >= QUERY_MAX_ARGS) + { + strlcpy(s, "Too many arguments in function call.", len); + *error = s; + goto clean; + } + + buff = query_parse_argument(s, len, buff, &args[argi], error); + + if (*error) + goto clean; + + argi++; + buff = query_chomp(buff); + buff = query_expect_char(s, len, buff, ',', error); + + if (*error) + { + *error = NULL; + break; + } + buff = query_chomp(buff); + } + buff = query_expect_char(s, len, buff, ')', error); + + if (*error) + goto clean; + + invocation->argc = argi; + invocation->argv = (argi > 0) ? (struct argument*) + malloc(sizeof(struct argument) * argi) : NULL; + + if (!invocation->argv) + { + s[0] = 'O'; + s[1] = 'O'; + s[2] = 'M'; + s[3] = '\0'; + *error = s; + goto clean; + } + memcpy(invocation->argv, args, + sizeof(struct argument) * argi); + + return buff; + +clean: + for (i = 0; i < argi; i++) + query_argument_free(&args[i]); + return buff; +} + void libretrodb_query_free(void *q) { unsigned i; diff --git a/memory/wii/mem2_manager.c b/memory/wii/mem2_manager.c index 11ba935ec655..3f1f6dfdd3e2 100644 --- a/memory/wii/mem2_manager.c +++ b/memory/wii/mem2_manager.c @@ -203,37 +203,37 @@ uint32_t gx_mem2_total(void) return info.used_size + info.free_size; } -void *__real_malloc(size_t size); -void *__real_calloc(size_t n, size_t size); -void *__real_memalign(size_t a, size_t size); +void *__real_malloc(size_t len); +void *__real_calloc(size_t n, size_t len); +void *__real_memalign(size_t a, size_t len); void __real_free(void *p); -void *__real_realloc(void *p, size_t size); +void *__real_realloc(void *p, size_t len); void *__real_strdup(const char *s); void *__real_strndup(const char *s, size_t n); size_t __real_malloc_usable_size(void *p); -__attribute__ ((used)) void *__wrap_malloc(size_t size) +__attribute__ ((used)) void *__wrap_malloc(size_t len) { - void *p = __real_malloc(size); + void *p = __real_malloc(len); if (p != 0) return p; - return _mem2_malloc(size); + return _mem2_malloc(len); } -__attribute__ ((used)) void *__wrap_calloc(size_t n, size_t size) +__attribute__ ((used)) void *__wrap_calloc(size_t n, size_t len) { - void *p = __real_calloc(n, size); + void *p = __real_calloc(n, len); if (p != 0) return p; - return _mem2_calloc(n, size); + return _mem2_calloc(n, len); } -__attribute__ ((used)) void *__wrap_memalign(size_t a, size_t size) +__attribute__ ((used)) void *__wrap_memalign(size_t a, size_t len) { - void *p = __real_memalign(a, size); + void *p = __real_memalign(a, len); if (p != 0) return p; - return _mem2_memalign(a, size); + return _mem2_memalign(a, len); } __attribute__ ((used)) void __wrap_free(void *p) @@ -247,37 +247,37 @@ __attribute__ ((used)) void __wrap_free(void *p) __real_free(p); } -__attribute__ ((used)) void *__wrap_realloc(void *p, size_t size) +__attribute__ ((used)) void *__wrap_realloc(void *p, size_t len) { void *n; /* ptr from mem2 */ if (((uint32_t) p & 0x10000000) != 0) { - n = _mem2_realloc(p, size); + n = _mem2_realloc(p, len); if (n != 0) return n; - n = __real_malloc(size); + n = __real_malloc(len); if (n == 0) return 0; if (p != 0) { size_t heap_size = __lwp_heap_block_size(&gx_mem2_heap, p); - memcpy(n, p, heap_size < size ? heap_size : size); + memcpy(n, p, heap_size < len ? heap_size : len); _mem2_free(p); } return n; } /* ptr from malloc */ - n = __real_realloc(p, size); + n = __real_realloc(p, len); if (n != 0) return n; - n = _mem2_malloc(size); + n = _mem2_malloc(len); if (n == 0) return 0; if (p != 0) { size_t heap_size = __real_malloc_usable_size(p); - memcpy(n, p, heap_size < size ? heap_size : size); + memcpy(n, p, heap_size < len ? heap_size : len); __real_free(p); } return n; diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index ed8f94a7f62a..64e056b16a2f 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -1904,14 +1904,14 @@ int generic_action_ok_displaylist_push( * selection needs to be made from a list, otherwise * returns true and fills in @s with path to core. **/ -static bool menu_content_find_first_core(menu_content_ctx_defer_info_t *def_info, - bool load_content_with_current_core, - char *new_core_path, size_t len) +static bool menu_content_find_first_core( + menu_content_ctx_defer_info_t *def_info, + bool load_content_with_current_core, char *s, size_t len) { - const core_info_t *info = NULL; - size_t supported = 0; - core_info_list_t *core_info = (core_info_list_t*)def_info->data; - const char *default_info_dir = def_info->dir; + const core_info_t *info = NULL; + size_t supported = 0; + core_info_list_t *core_info = (core_info_list_t*)def_info->data; + const char *default_info_dir = def_info->dir; if (!string_is_empty(default_info_dir)) { @@ -1954,7 +1954,7 @@ static bool menu_content_find_first_core(menu_content_ctx_defer_info_t *def_info return false; if (info) - strlcpy(new_core_path, info->path, len); + strlcpy(s, info->path, len); return true; } diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 5e420738b303..8cbd4de76a3f 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -591,7 +591,7 @@ typedef struct materialui_handle } font_data; size_t (*word_wrap)( - char *dst, size_t dst_size, + char *s, size_t len, const char *src, size_t src_len, int line_width, int wideglyph_width, unsigned max_lines); @@ -2189,7 +2189,6 @@ static const char *materialui_texture_path(unsigned id) static void materialui_context_destroy_playlist_icons(materialui_handle_t *mui) { size_t i; - for (i = 0; i < mui->textures.playlist.size; i++) video_driver_texture_unload(&mui->textures.playlist.icons[i].image); } @@ -2198,7 +2197,6 @@ static void materialui_context_reset_playlist_icons( materialui_handle_t *mui) { size_t i; - if (string_is_empty(mui->sysicons_path)) return; @@ -2222,7 +2220,6 @@ static void materialui_context_reset_playlist_icons( static void materialui_free_playlist_icon_list(materialui_handle_t *mui) { size_t i; - for (i = 0; i < mui->textures.playlist.size; i++) { /* Ensure that any textures are unloaded @@ -3133,8 +3130,8 @@ static float materialui_get_scroll(materialui_handle_t *mui, static bool INLINE materialui_entry_onscreen( materialui_handle_t *mui, size_t idx) { - return (idx >= mui->first_onscreen_entry) && - (idx <= mui->last_onscreen_entry); + return (idx >= mui->first_onscreen_entry) + && (idx <= mui->last_onscreen_entry); } /* If currently selected entry is off screen, @@ -3222,9 +3219,9 @@ static INLINE void materialui_kill_scroll_animation( * is detected */ static bool materialui_render_process_entry_default( materialui_handle_t* mui, - struct menu_state *menu_st, - materialui_node_t *node, - size_t entry_idx, size_t selection, size_t playlist_idx, + struct menu_state *menu_st, materialui_node_t *node, + size_t entry_idx, size_t selection, + size_t playlist_idx, bool first_entry_found, bool last_entry_found, unsigned thumbnail_upscale_threshold, bool network_on_demand_thumbnails) @@ -3242,9 +3239,9 @@ static bool materialui_render_process_entry_default( * Always returns true */ static bool materialui_render_process_entry_playlist_thumb_list( materialui_handle_t* mui, - struct menu_state *menu_st, - materialui_node_t *node, - size_t entry_idx, size_t selection, size_t playlist_idx, + struct menu_state *menu_st, materialui_node_t *node, + size_t entry_idx, size_t selection, + size_t playlist_idx, bool first_entry_found, bool last_entry_found, unsigned thumbnail_upscale_threshold, bool network_on_demand_thumbnails) @@ -3285,9 +3282,9 @@ static bool materialui_render_process_entry_playlist_thumb_list( * Always returns true */ static bool materialui_render_process_entry_playlist_dual_icon( materialui_handle_t* mui, - struct menu_state *menu_st, - materialui_node_t *node, - size_t entry_idx, size_t selection, size_t playlist_idx, + struct menu_state *menu_st, materialui_node_t *node, + size_t entry_idx, size_t selection, + size_t playlist_idx, bool first_entry_found, bool last_entry_found, unsigned thumbnail_upscale_threshold, bool network_on_demand_thumbnails) @@ -3319,9 +3316,9 @@ static bool materialui_render_process_entry_playlist_dual_icon( * Always returns true */ static bool materialui_render_process_entry_playlist_desktop( materialui_handle_t* mui, - struct menu_state *menu_st, - materialui_node_t *node, - size_t entry_idx, size_t selection, size_t playlist_idx, + struct menu_state *menu_st, materialui_node_t *node, + size_t entry_idx, size_t selection, + size_t playlist_idx, bool first_entry_found, bool last_entry_found, unsigned thumbnail_upscale_threshold, bool network_on_demand_thumbnails) @@ -3520,9 +3517,9 @@ static bool materialui_render_process_entry_playlist_desktop( static bool (*materialui_render_process_entry)( materialui_handle_t* mui, - struct menu_state *menu_st, - materialui_node_t *node, - size_t entry_idx, size_t selection, size_t playlist_idx, + struct menu_state *menu_st, materialui_node_t *node, + size_t entry_idx, size_t selection, + size_t playlist_idx, bool first_entry_found, bool last_entry_found, unsigned thumbnail_upscale_threshold, bool network_on_demand_thumbnails) = materialui_render_process_entry_default; @@ -4978,22 +4975,22 @@ static void materialui_render_selected_entry_aux_playlist_desktop( file_list_t *list, size_t selection) { math_matrix_4x4 mymat; - materialui_node_t *node = (materialui_node_t*)list->list[selection].userdata; - float background_x = (float)(x_offset + (int)mui->landscape_optimization.border_width); - float background_y = (float)header_height; + materialui_node_t *node = (materialui_node_t*)list->list[selection].userdata; + float background_x = (float)(x_offset + (int)mui->landscape_optimization.border_width); + float background_y = (float)header_height; /* Note: If landscape optimisations are enabled, * need to allow space for a second divider at * the left hand edge of the sidebar */ - int background_width = mui->thumbnail_width_max + (mui->margin * 2) + + int background_width = mui->thumbnail_width_max + (mui->margin * 2) + (mui->entry_divider_width * (mui->landscape_optimization.enabled ? 2 : 1)); - int background_height = (int)video_height - (int)header_height - + int background_height = (int)video_height - (int)header_height - (int)mui->nav_bar_layout_height - (int)mui->status_bar.height; - float thumbnail_x = background_x + (float)mui->margin + + float thumbnail_x = background_x + (float)mui->margin + (mui->landscape_optimization.enabled ? mui->entry_divider_width : 0); - float thumbnail_y = background_y + (float)mui->margin; - gfx_display_t *p_disp = disp_get_ptr(); - settings_t *settings = config_get_ptr(); + float thumbnail_y = background_y + (float)mui->margin; + gfx_display_t *p_disp = disp_get_ptr(); + settings_t *settings = config_get_ptr(); /* Sanity check */ if ( (background_width <= 0) @@ -5233,17 +5230,14 @@ static void (*materialui_render_selected_entry_aux)( /* Draws current menu list */ static void materialui_render_menu_list( - materialui_handle_t *mui, - gfx_display_t *p_disp, - void *userdata, - size_t selection, - unsigned video_width, - unsigned video_height, + materialui_handle_t *mui, gfx_display_t *p_disp, + void *userdata, size_t selection, + unsigned video_width, unsigned video_height, int x_offset) { size_t i; - size_t first_entry; size_t last_entry; + size_t first_entry; struct menu_state *menu_st = menu_state_get_ptr(); menu_list_t *menu_list = menu_st->entries.list; menu_input_t *menu_input = &menu_st->input_state; @@ -5481,8 +5475,7 @@ static void materialui_render_landscape_border( static void materialui_render_selection_highlight( materialui_handle_t *mui, - gfx_display_t *p_disp, - void *userdata, + gfx_display_t *p_disp, void *userdata, unsigned video_width, unsigned video_height, unsigned header_height, int x_offset, size_t selection, float *highlight_color, @@ -5568,8 +5561,7 @@ static void materialui_render_selection_highlight( static void materialui_render_entry_touch_feedback( materialui_handle_t *mui, - gfx_display_t *p_disp, - void *userdata, + gfx_display_t *p_disp, void *userdata, menu_input_t *menu_input, unsigned video_width, unsigned video_height, unsigned header_height, int x_offset, @@ -6095,12 +6087,9 @@ static void materialui_render_header( * bars. This involves substantial code duplication, but if * we try to handle this with a single function then * things get incredibly messy and inefficient... */ -static void materialui_render_nav_bar_bottom( - materialui_handle_t *mui, - gfx_display_t *p_disp, - void *userdata, - unsigned video_width, unsigned video_height, - math_matrix_4x4 *mymat) +static void materialui_render_nav_bar_bottom(materialui_handle_t *mui, + gfx_display_t *p_disp, void *userdata, + unsigned video_width, unsigned video_height, math_matrix_4x4 *mymat) { size_t i; unsigned nav_bar_width = video_width; @@ -6219,12 +6208,9 @@ static void materialui_render_nav_bar_bottom( } } -static void materialui_render_nav_bar_right( - materialui_handle_t *mui, - gfx_display_t *p_disp, - void *userdata, - unsigned video_width, - unsigned video_height, +static void materialui_render_nav_bar_right(materialui_handle_t *mui, + gfx_display_t *p_disp, void *userdata, + unsigned video_width, unsigned video_height, math_matrix_4x4 *mymat) { size_t i; @@ -6345,12 +6331,9 @@ static void materialui_render_nav_bar_right( } } -static void materialui_render_nav_bar( - materialui_handle_t *mui, - gfx_display_t *p_disp, - void *userdata, - unsigned video_width, - unsigned video_height, +static void materialui_render_nav_bar(materialui_handle_t *mui, + gfx_display_t *p_disp, void *userdata, + unsigned video_width, unsigned video_height, math_matrix_4x4 *mymat) { switch (mui->nav_bar.location) @@ -6541,13 +6524,10 @@ static void materialui_show_fullscreen_thumbnails( mui->flags |= MUI_FLAG_SHOW_FULLSCREEN_THUMBNAILS; } -static void materialui_render_fullscreen_thumbnails( - materialui_handle_t *mui, - gfx_display_t *p_disp, - void *userdata, +static void materialui_render_fullscreen_thumbnails(materialui_handle_t *mui, + gfx_display_t *p_disp, void *userdata, unsigned video_width, unsigned video_height, - unsigned header_height, - size_t selection) + unsigned header_height, size_t selection) { /* Check whether fullscreen thumbnails are visible */ if (mui->fullscreen_thumbnail_alpha > 0.0f) @@ -6984,8 +6964,7 @@ static void materialui_colors_reset_transition_alpha(materialui_handle_t *mui) } /* Updates scrollbar draw position */ -static void materialui_update_scrollbar( - materialui_handle_t *mui, +static void materialui_update_scrollbar(materialui_handle_t *mui, unsigned width, unsigned height, unsigned header_height, int x_offset) { @@ -7311,8 +7290,7 @@ static void materialui_frame(void *data, video_frame_info_t *video_info) /* Determines current list view type, based on * whether current menu is a playlist, and whether * user has enabled playlist thumbnails */ -static void materialui_set_list_view_type( - materialui_handle_t *mui, +static void materialui_set_list_view_type(materialui_handle_t *mui, struct menu_state *menu_st, unsigned thumbnail_view_portrait, unsigned thumbnail_view_landscape) @@ -7512,8 +7490,8 @@ static void materialui_set_landscape_optimisations_enable( /* Initialises status bar, determining current * enable state based on view mode and user * configuration */ -static void materialui_status_bar_init( - materialui_handle_t *mui, settings_t *settings) +static void materialui_status_bar_init(materialui_handle_t *mui, + settings_t *settings) { bool playlist_show_sublabels = settings->bools.playlist_show_sublabels; uintptr_t alpha_tag = (uintptr_t)&mui->status_bar.alpha; @@ -7580,19 +7558,14 @@ static void materialui_set_thumbnail_dimensions(materialui_handle_t *mui) switch (mui->list_view_type) { case MUI_LIST_VIEW_PLAYLIST_THUMB_LIST_SMALL: - /* Maximum height is just standard icon size */ mui->thumbnail_height_max = mui->icon_size; - /* Set thumbnail width based on max height */ mui->thumbnail_width_max = (unsigned)(((float)mui->thumbnail_height_max * MUI_THUMBNAIL_DEFAULT_ASPECT_RATIO) + 0.5f); - break; - case MUI_LIST_VIEW_PLAYLIST_THUMB_LIST_MEDIUM: - /* Maximum height corresponds to text height when * showing full playlist sublabel metadata * (core association + runtime info) @@ -7725,8 +7698,7 @@ static void materialui_set_thumbnail_dimensions(materialui_handle_t *mui) * - Returns false if secondary thumbnails cannot be * enabled (due to per-playlist override) */ static bool materialui_force_enable_secondary_thumbnail( - materialui_handle_t *mui, - struct menu_state *menu_st, + materialui_handle_t *mui, struct menu_state *menu_st, settings_t *settings) { /* If secondary thumbnail is already enabled, @@ -7769,10 +7741,8 @@ static bool materialui_force_enable_secondary_thumbnail( /* Determines whether dual thumbnails should be enabled * based on current list view mode, thumbnail dimensions * and screen size */ -static void materialui_set_secondary_thumbnail_enable( - materialui_handle_t *mui, - struct menu_state *menu_st, - settings_t *settings) +static void materialui_set_secondary_thumbnail_enable(materialui_handle_t *mui, + struct menu_state *menu_st, settings_t *settings) { switch (mui->list_view_type) { @@ -7858,8 +7828,7 @@ static void materialui_set_secondary_thumbnail_enable( * Must be called when updating menu layout and * populating menu lists. */ static void materialui_update_list_view(materialui_handle_t *mui, - struct menu_state *menu_st, - settings_t *settings) + struct menu_state *menu_st, settings_t *settings) { materialui_set_list_view_type(mui, menu_st, settings->uints.menu_materialui_thumbnail_view_portrait, @@ -7888,13 +7857,9 @@ static void materialui_update_list_view(materialui_handle_t *mui, mui->flags |= MUI_FLAG_NEED_COMPUTE; } -static void materialui_init_font( - gfx_display_t *p_disp, - font_data_impl_t *font_data, - int font_size, - bool video_is_threaded, - const char *str_latin - ) +static void materialui_init_font(gfx_display_t *p_disp, + font_data_impl_t *font_data, int font_size, + bool video_is_threaded, const char *str_latin) { char tmp_dir[DIR_MAX_LENGTH]; char fontpath[PATH_MAX_LENGTH]; @@ -7944,7 +7909,7 @@ static void materialui_init_font( font_data->font = gfx_display_font_file(p_disp, fontpath, font_size, video_is_threaded); - if (font_data->font) + if (font_data->font) { /* Calculate a more realistic ticker_limit */ int char_width = @@ -7972,12 +7937,9 @@ static void materialui_init_font( } /* Compute the positions of the widgets */ -static void materialui_layout( - materialui_handle_t *mui, - struct menu_state *menu_st, - gfx_display_t *p_disp, - settings_t *settings, - bool video_is_threaded) +static void materialui_layout(materialui_handle_t *mui, + struct menu_state *menu_st, gfx_display_t *p_disp, + settings_t *settings, bool video_is_threaded) { int title_font_size; int list_font_size; @@ -8104,8 +8066,7 @@ static void materialui_init_nav_bar(materialui_handle_t *mui) mui->nav_bar.location = MUI_NAV_BAR_LOCATION_BOTTOM; } -static void materialui_menu_animation_update_time( - float *ticker_pixel_increment, +static void materialui_menu_animation_update_time(float *s, unsigned video_width, unsigned video_height) { gfx_display_t *p_disp = disp_get_ptr(); @@ -8116,8 +8077,7 @@ static void materialui_menu_animation_update_time( * a small correction factor to achieve a * default scroll speed equal to that of the * non-smooth ticker */ - *(ticker_pixel_increment) *= gfx_display_get_dpi_scale( - p_disp, settings, + *(s) *= gfx_display_get_dpi_scale(p_disp, settings, video_width, video_height, false, false) * 0.8f; } @@ -8352,7 +8312,8 @@ static void materialui_context_destroy(void *data) /* Note: This is only used for loading wallpaper * images. Thumbnails are 'streamed' and must be * handled differently */ -static bool materialui_load_image(void *userdata, void *data, enum menu_image_type type) +static bool materialui_load_image(void *userdata, + void *data, enum menu_image_type type) { materialui_handle_t *mui = (materialui_handle_t*)userdata; @@ -8375,8 +8336,8 @@ static void materialui_scroll_animation_end(void *userdata) mui->scroll_animation_selection = 0; } -static void materialui_animate_scroll( - materialui_handle_t *mui, float scroll_pos, float duration) +static void materialui_animate_scroll(materialui_handle_t *mui, + float scroll_pos, float duration) { gfx_animation_ctx_entry_t animation_entry; struct menu_state *menu_st = menu_state_get_ptr(); @@ -8441,13 +8402,8 @@ static void materialui_navigation_clear(void *data, bool pending_push) materialui_handle_t *mui = (materialui_handle_t*)data; if (!mui) return; - menu_st->entries.begin = i; - - materialui_animate_scroll( - mui, - 0.0f, - MUI_ANIM_DURATION_SCROLL_RESET); + materialui_animate_scroll(mui, 0.0f, MUI_ANIM_DURATION_SCROLL_RESET); } static void materialui_navigation_set_last(void *data) @@ -8460,11 +8416,8 @@ static void materialui_navigation_alphabet(void *data, size_t *unused) materialui_navigation_set(data, true); } -static void materialui_populate_nav_bar( - materialui_handle_t *mui, - struct menu_state *menu_st, - const char *label, - settings_t *settings) +static void materialui_populate_nav_bar(materialui_handle_t *mui, + struct menu_state *menu_st, const char *label, settings_t *settings) { size_t menu_tab_index = 0; bool menu_content_show_playlists = @@ -8531,8 +8484,8 @@ static void materialui_populate_nav_bar( mui->nav_bar.num_menu_tabs = menu_tab_index; } -static void materialui_init_transition_animation( - materialui_handle_t *mui, settings_t *settings) +static void materialui_init_transition_animation(materialui_handle_t *mui, + settings_t *settings) { gfx_animation_ctx_entry_t alpha_entry; gfx_animation_ctx_entry_t x_offset_entry; @@ -8646,8 +8599,7 @@ static void materialui_init_transition_animation( } /* A new list has been pushed */ -static void materialui_populate_entries( - void *data, const char *path, +static void materialui_populate_entries(void *data, const char *path, const char *label, unsigned i) { materialui_handle_t *mui = (materialui_handle_t*)data; @@ -8850,8 +8802,8 @@ static void materialui_context_reset(void *data, bool is_threaded) video_driver_monitor_reset(); } -static int materialui_environ(enum menu_environ_cb type, - void *data, void *userdata) +static int materialui_environ(enum menu_environ_cb type, void *data, + void *userdata) { materialui_handle_t *mui = (materialui_handle_t*)userdata; @@ -8903,8 +8855,8 @@ static int materialui_environ(enum menu_environ_cb type, /* Called before we push the new list after: * - Clicking a menu-type tab on the navigation bar * - Using left/right to navigate between top level menus */ -static bool materialui_preswitch_tabs( - materialui_handle_t *mui, materialui_nav_bar_menu_tab_t *target_tab) +static bool materialui_preswitch_tabs(materialui_handle_t *mui, + materialui_nav_bar_menu_tab_t *target_tab) { size_t stack_size = 0; file_list_t *menu_stack = NULL; @@ -8987,9 +8939,8 @@ static bool materialui_preswitch_tabs( * > If tab == NULL, this is a left/right navigation * event - in this case, 'action' is used to determine * target tab */ -static int materialui_switch_tabs( - materialui_handle_t *mui, materialui_nav_bar_menu_tab_t *tab, - enum menu_action action) +static int materialui_switch_tabs(materialui_handle_t *mui, + materialui_nav_bar_menu_tab_t *tab, enum menu_action action) { materialui_nav_bar_menu_tab_t *target_tab = tab; @@ -9078,8 +9029,7 @@ static int materialui_switch_tabs( /* If viewing a playlist with thumbnails enabled, * cycles current thumbnail view mode */ static void materialui_switch_list_view(materialui_handle_t *mui, - struct menu_state *menu_st, - settings_t *settings) + struct menu_state *menu_st, settings_t *settings) { bool secondary_thumbnail_enabled_prev = mui->flags & MUI_FLAG_SECONDARY_THUMBNAIL_ENABLED; @@ -9144,7 +9094,6 @@ static void materialui_switch_list_view(materialui_handle_t *mui, mui->flags |= MUI_FLAG_NEED_COMPUTE; } - /* Material UI requires special handling of certain * menu input functions, due to the fact that navigation * controls are relative to the currently selected item, @@ -9906,7 +9855,8 @@ static int materialui_pointer_up_swipe_horz_plain_list( static int materialui_pointer_up_swipe_horz_default( materialui_handle_t *mui, menu_entry_t *entry, - unsigned ptr, size_t selection, size_t entries_end, enum menu_action action) + unsigned ptr, size_t selection, size_t entries_end, + enum menu_action action) { if ((ptr < entries_end) && (ptr == selection)) { @@ -9969,8 +9919,9 @@ static int materialui_pointer_up_swipe_horz_default( static int materialui_pointer_up_nav_bar( materialui_handle_t *mui, - unsigned x, unsigned y, unsigned width, unsigned height, size_t selection, - menu_file_list_cbs_t *cbs, menu_entry_t *entry, unsigned action) + unsigned x, unsigned y, unsigned width, unsigned height, + size_t selection, menu_file_list_cbs_t *cbs, + menu_entry_t *entry, unsigned action) { unsigned tab_index; size_t num_tabs = mui->nav_bar.num_menu_tabs + MUI_NAV_BAR_NUM_ACTION_TABS; @@ -10285,14 +10236,10 @@ static int materialui_pointer_up(void *userdata, * * This function allocates the materialui_node_t * for the new entry. */ -static void materialui_list_insert( - void *userdata, +static void materialui_list_insert(void *userdata, file_list_t *list, - const char *path, - const char *fullpath, - const char *label, - size_t list_size, - unsigned type) + const char *path, const char *fullpath, + const char *label, size_t list_size, unsigned type) { int i = (int)list_size; materialui_node_t *node = NULL; diff --git a/menu/drivers/ozone.c b/menu/drivers/ozone.c index c14868f0cfc7..de36345ca8f3 100644 --- a/menu/drivers/ozone.c +++ b/menu/drivers/ozone.c @@ -4242,12 +4242,13 @@ static void ozone_update_content_metadata(ozone_handle_t *ozone) core_label = menu_st->thumbnail_path_data->content_core_name; } - _len = strlcpy(ozone->selection_core_name, + _len = strlcpy(ozone->selection_core_name, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_CORE), sizeof(ozone->selection_core_name)); - ozone->selection_core_name[ _len] = ' '; - ozone->selection_core_name[++_len] = '\0'; - strlcpy(ozone->selection_core_name + _len, core_label, sizeof(ozone->selection_core_name) - _len); + _len += strlcpy(ozone->selection_core_name + _len, " ", + sizeof(ozone->selection_core_name) - _len); + strlcpy(ozone->selection_core_name + _len, core_label, + sizeof(ozone->selection_core_name) - _len); if (!scroll_content_metadata) linebreak_after_colon(&ozone->selection_core_name); @@ -4290,20 +4291,18 @@ static void ozone_update_content_metadata(ozone_handle_t *ozone) else { const char *disabled_str = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DISABLED); - size_t _len = - strlcpy(ozone->selection_playtime, + size_t _len = strlcpy(ozone->selection_playtime, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_RUNTIME), sizeof(ozone->selection_playtime)); - ozone->selection_playtime[ _len] = ' '; - ozone->selection_playtime[++_len] = '\0'; + _len += strlcpy(ozone->selection_playtime + _len, " ", + sizeof(ozone->selection_playtime) - _len); strlcpy(ozone->selection_playtime + _len, disabled_str, sizeof(ozone->selection_playtime) - _len); - _len = - strlcpy(ozone->selection_lastplayed, + _len = strlcpy(ozone->selection_lastplayed, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED), sizeof(ozone->selection_lastplayed)); - ozone->selection_lastplayed[ _len] = ' '; - ozone->selection_lastplayed[++_len] = '\0'; + _len += strlcpy(ozone->selection_lastplayed + _len, " ", + sizeof(ozone->selection_lastplayed) - _len); strlcpy(ozone->selection_lastplayed + _len, disabled_str, sizeof(ozone->selection_lastplayed) - _len); } diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 4174676d1dec..e5475ec5f19b 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -1649,9 +1649,9 @@ static void rgui_fill_rect( * this function is frequently used to fill large areas. * We therefore gain significant performance benefits * from using memcpy() tricks... */ - unsigned x_end = (x_end_i <= fb_width) ? x_end_i : fb_width; - unsigned y_end = (y_end_i <= fb_height) ? y_end_i : fb_height; - size_t x_size = (x_end - x_start) * sizeof(uint16_t); + unsigned x_end = (x_end_i <= fb_width) ? x_end_i : fb_width; + unsigned y_end = (y_end_i <= fb_height) ? y_end_i : fb_height; + size_t x_size = (x_end - x_start) * sizeof(uint16_t); /* Sanity check */ if (x_size == 0) @@ -4962,17 +4962,14 @@ static bool gfx_thumbnail_get_label( return true; } -static void rgui_render( - void *data, - unsigned width, - unsigned height, +static void rgui_render(void *data, unsigned width, unsigned height, bool is_idle) { - gfx_animation_ctx_ticker_t ticker; - gfx_animation_ctx_ticker_smooth_t ticker_smooth; unsigned x, y; - size_t i, end, fb_pitch, old_start, new_start; unsigned fb_width, fb_height; + gfx_animation_ctx_ticker_t ticker; + size_t i, end, fb_pitch, old_start, new_start; + gfx_animation_ctx_ticker_smooth_t ticker_smooth; static bool display_kb = false; static const char* const ticker_spacer = RGUI_TICKER_SPACER; @@ -5288,11 +5285,11 @@ static void rgui_render( else { /* Render usual text */ - size_t selection = menu_st->selection_ptr; - size_t title_max_len; - size_t title_len; unsigned title_x; + size_t title_len; + size_t title_max_len; char title_buf[NAME_MAX_LENGTH]; + size_t selection = menu_st->selection_ptr; unsigned title_y = rgui->term_layout.start_y - rgui->font_height_stride; unsigned term_end_x = rgui->term_layout.start_x + (rgui->term_layout.width * rgui->font_width_stride); unsigned timedate_x = term_end_x - (5 * rgui->font_width_stride); @@ -7458,16 +7455,12 @@ static int rgui_environ( /* Forward declaration */ static int rgui_menu_entry_action( - void *userdata, - menu_entry_t *entry, - size_t i, - enum menu_action action); + void *userdata, menu_entry_t *entry, + size_t i, enum menu_action action); static int rgui_pointer_up( void *data, - unsigned x, - unsigned y, - unsigned ptr, + unsigned x, unsigned y, unsigned ptr, enum menu_input_pointer_gesture gesture, menu_file_list_cbs_t *cbs, menu_entry_t *entry, @@ -8156,10 +8149,8 @@ static enum menu_action rgui_parse_menu_entry_action( /* Menu entry action callback */ static int rgui_menu_entry_action( - void *userdata, - menu_entry_t *entry, - size_t i, - enum menu_action action) + void *userdata, menu_entry_t *entry, + size_t i, enum menu_action action) { rgui_t *rgui = (rgui_t*)userdata; diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 2b1797ae3475..cfefd35067fe 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -345,7 +345,7 @@ typedef struct xmb_handle video_font_raster_block_t raster_block2; size_t (*word_wrap)( - char *dst, size_t dst_size, + char *s, size_t len, const char *src, size_t src_len, int line_width, int wideglyph_width, unsigned max_lines); @@ -1168,12 +1168,7 @@ static char *xmb_path_dynamic_wallpaper(xmb_handle_t *xmb) dir_dynamic_wallpapers, xmb->title_name, sizeof(path)); - - path[ _len] = '.'; - path[++_len] = 'p'; - path[++_len] = 'n'; - path[++_len] = 'g'; - path[++_len] = '\0'; + strlcpy(path + _len, ".png", sizeof(path) - _len); } if (!string_is_empty(path) && path_is_valid(path)) @@ -4458,9 +4453,13 @@ static bool xmb_animation_line_ticker_smooth(gfx_animation_t *p_anim, gfx_animat size_t bottom_fade_line_index = bottom_fade_line_offset % (lines.size + 1); /* Is line valid? */ if (top_fade_line_index < lines.size) - strlcpy(line_ticker->top_fade_str, lines.elems[top_fade_line_index].data, line_ticker->top_fade_str_len); + strlcpy(line_ticker->top_fade_str, + lines.elems[top_fade_line_index].data, + line_ticker->top_fade_str_len); if (bottom_fade_line_index < lines.size) - strlcpy(line_ticker->bottom_fade_str, lines.elems[bottom_fade_line_index].data, line_ticker->bottom_fade_str_len); + strlcpy(line_ticker->bottom_fade_str, + lines.elems[bottom_fade_line_index].data, + line_ticker->bottom_fade_str_len); } success = true; @@ -4596,7 +4595,8 @@ static int xmb_draw_item( { char entry_path[PATH_MAX_LENGTH]; strlcpy(entry_path, entry.path, sizeof(entry_path)); - fill_pathname(entry_path, path_basename(entry_path), "", sizeof(entry_path)); + fill_pathname(entry_path, path_basename(entry_path), "", + sizeof(entry_path)); if (!string_is_empty(entry_path)) strlcpy(entry.path, entry_path, sizeof(entry.path)); } @@ -7258,7 +7258,9 @@ static void xmb_frame(void *data, video_frame_info_t *video_info) /* Use alternative title if available */ strlcpy(title_truncated, - !string_is_empty(xmb->title_name_alt) ? xmb->title_name_alt : xmb->title_name, + !string_is_empty(xmb->title_name_alt) + ? xmb->title_name_alt + : xmb->title_name, sizeof(title_truncated)); if (!vertical_fade_factor && selection > 1) diff --git a/menu/menu_contentless_cores.c b/menu/menu_contentless_cores.c index f046e4725939..a87862d0a20f 100644 --- a/menu/menu_contentless_cores.c +++ b/menu/menu_contentless_cores.c @@ -99,8 +99,8 @@ static void contentless_cores_free_info_entries( static void contentless_cores_init_info_entries( contentless_cores_state_t *state) { - core_info_list_t *core_info_list = NULL; size_t i; + core_info_list_t *core_info_list = NULL; if (!state) return; @@ -207,8 +207,8 @@ void menu_contentless_cores_get_info(const char *core_id, void menu_contentless_cores_flush_runtime(void) { - contentless_cores_state_t *state = contentless_cores_state; size_t i, cap; + contentless_cores_state_t *state = contentless_cores_state; if (!state || !state->info_entries) return; diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 02d7d7f3ad4c..070f92cbd436 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -833,7 +833,9 @@ static int menu_displaylist_parse_core_info( /* Show the path that was checked */ #ifdef IOS shortened_path[0] = '\0'; - fill_pathname_abbreviate_special(shortened_path, firmware_info.directory.system, sizeof(shortened_path)); + fill_pathname_abbreviate_special(shortened_path, + firmware_info.directory.system, + sizeof(shortened_path)); snprintf(tmp, sizeof(tmp), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_FIRMWARE_PATH), shortened_path); @@ -887,7 +889,9 @@ static int menu_displaylist_parse_core_info( core_info_list_hide[j] = true; __len = strlcpy(tmp, "- ", sizeof(tmp)); - strlcpy(tmp + __len, core_info->note_list->elems[j].data + pos, sizeof(tmp) - __len); + strlcpy( tmp + __len, + core_info->note_list->elems[j].data + pos, + sizeof(tmp) - __len); if (menu_entries_append(list, tmp, "", MENU_ENUM_LABEL_CORE_INFO_ENTRY, @@ -925,7 +929,8 @@ static int menu_displaylist_parse_core_info( tmp[++_len] = '\0'; #if IOS shortened_path[0] = '\0'; - fill_pathname_abbreviate_special(shortened_path, core_path, sizeof(shortened_path)); + fill_pathname_abbreviate_special(shortened_path, + core_path, sizeof(shortened_path)); strlcpy(tmp + _len, shortened_path, sizeof(tmp) - _len); #else strlcpy(tmp + _len, core_path, sizeof(tmp) - _len); @@ -2653,7 +2658,6 @@ static int create_string_list_rdb_entry_string( const char *label, const char *actual_string, const char *path, - size_t path_len, file_list_t *list) { char tmp[128]; @@ -2679,9 +2683,7 @@ static int create_string_list_rdb_entry_string( static int create_string_list_rdb_entry_int( enum msg_hash_enums enum_idx, const char *desc, const char *label, - int actual_int, - const char *path, size_t path_len, - file_list_t *list) + int actual_int, const char *path, file_list_t *list) { size_t _len; char str[16]; @@ -2733,7 +2735,6 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, menu_displaylist_info_t *info) { size_t _len; - size_t path_len; unsigned i, j, k; char query[256]; char path_base[NAME_MAX_LENGTH]; @@ -2882,15 +2883,13 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, 0, 0, 0, NULL); } - path_len = strlen(info->path); - if (db_info_entry->publisher) { if (create_string_list_rdb_entry_string( MENU_ENUM_LABEL_RDB_ENTRY_PUBLISHER, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_PUBLISHER), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_PUBLISHER), - db_info_entry->publisher, info->path, path_len, info->list) == -1) + db_info_entry->publisher, info->path, info->list) == -1) goto error; } @@ -2900,7 +2899,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, MENU_ENUM_LABEL_RDB_ENTRY_CATEGORY, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_CATEGORY), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_CATEGORY), - db_info_entry->category, info->path, path_len, info->list) == -1) + db_info_entry->category, info->path, info->list) == -1) goto error; } @@ -2910,7 +2909,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, MENU_ENUM_LABEL_RDB_ENTRY_LANGUAGE, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_LANGUAGE), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_LANGUAGE), - db_info_entry->language, info->path, path_len, info->list) == -1) + db_info_entry->language, info->path, info->list) == -1) goto error; } @@ -2920,7 +2919,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, MENU_ENUM_LABEL_RDB_ENTRY_REGION, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_REGION), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_REGION), - db_info_entry->region, info->path, path_len, info->list) == -1) + db_info_entry->region, info->path, info->list) == -1) goto error; } @@ -2930,7 +2929,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, MENU_ENUM_LABEL_RDB_ENTRY_SCORE, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_SCORE), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_SCORE), - db_info_entry->score, info->path, path_len, info->list) == -1) + db_info_entry->score, info->path, info->list) == -1) goto error; } @@ -2940,7 +2939,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, MENU_ENUM_LABEL_RDB_ENTRY_MEDIA, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_MEDIA), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_MEDIA), - db_info_entry->media, info->path, path_len, info->list) == -1) + db_info_entry->media, info->path, info->list) == -1) goto error; } @@ -2950,7 +2949,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, MENU_ENUM_LABEL_RDB_ENTRY_CONTROLS, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_CONTROLS), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_CONTROLS), - db_info_entry->controls, info->path, path_len, info->list) == -1) + db_info_entry->controls, info->path, info->list) == -1) goto error; } @@ -2960,7 +2959,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, MENU_ENUM_LABEL_RDB_ENTRY_ARTSTYLE, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_ARTSTYLE), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_ARTSTYLE), - db_info_entry->artstyle, info->path, path_len, info->list) == -1) + db_info_entry->artstyle, info->path, info->list) == -1) goto error; } @@ -2970,7 +2969,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, MENU_ENUM_LABEL_RDB_ENTRY_GAMEPLAY, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_GAMEPLAY), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_GAMEPLAY), - db_info_entry->gameplay, info->path, path_len, info->list) == -1) + db_info_entry->gameplay, info->path, info->list) == -1) goto error; } @@ -2980,7 +2979,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, MENU_ENUM_LABEL_RDB_ENTRY_NARRATIVE, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_NARRATIVE), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_NARRATIVE), - db_info_entry->narrative, info->path, path_len, info->list) == -1) + db_info_entry->narrative, info->path, info->list) == -1) goto error; } @@ -2990,7 +2989,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, MENU_ENUM_LABEL_RDB_ENTRY_PACING, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_PACING), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_PACING), - db_info_entry->pacing, info->path, path_len, info->list) == -1) + db_info_entry->pacing, info->path, info->list) == -1) goto error; } @@ -3000,7 +2999,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, MENU_ENUM_LABEL_RDB_ENTRY_PERSPECTIVE, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_PERSPECTIVE), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_PERSPECTIVE), - db_info_entry->perspective, info->path, path_len, info->list) == -1) + db_info_entry->perspective, info->path, info->list) == -1) goto error; } @@ -3010,7 +3009,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, MENU_ENUM_LABEL_RDB_ENTRY_SETTING, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_SETTING), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_SETTING), - db_info_entry->setting, info->path, path_len, info->list) == -1) + db_info_entry->setting, info->path, info->list) == -1) goto error; } @@ -3020,7 +3019,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, MENU_ENUM_LABEL_RDB_ENTRY_VISUAL, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_VISUAL), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_VISUAL), - db_info_entry->visual, info->path, path_len, info->list) == -1) + db_info_entry->visual, info->path, info->list) == -1) goto error; } @@ -3030,7 +3029,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, MENU_ENUM_LABEL_RDB_ENTRY_VEHICULAR, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_VEHICULAR), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_VEHICULAR), - db_info_entry->vehicular, info->path, path_len, info->list) == -1) + db_info_entry->vehicular, info->path, info->list) == -1) goto error; } @@ -3048,7 +3047,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, MENU_ENUM_LABEL_RDB_ENTRY_DEVELOPER, val_rdb_entry_dev, rdb_entry_dev, db_info_entry->developer->elems[k].data, - info->path, path_len, info->list) == -1) + info->path, info->list) == -1) goto error; } } @@ -3060,7 +3059,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, MENU_ENUM_LABEL_RDB_ENTRY_ORIGIN, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_ORIGIN), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_ORIGIN), - db_info_entry->origin, info->path, path_len, info->list) == -1) + db_info_entry->origin, info->path, info->list) == -1) goto error; } @@ -3070,7 +3069,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, MENU_ENUM_LABEL_RDB_ENTRY_FRANCHISE, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_FRANCHISE), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_FRANCHISE), - db_info_entry->franchise, info->path, path_len, info->list) == -1) + db_info_entry->franchise, info->path, info->list) == -1) goto error; } @@ -3080,8 +3079,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, MENU_ENUM_LABEL_RDB_ENTRY_MAX_USERS, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_INPUT_MAX_USERS), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_MAX_USERS), - db_info_entry->max_users, - info->path, path_len, info->list) == -1) + db_info_entry->max_users, info->path, info->list) == -1) goto error; } @@ -3091,8 +3089,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, MENU_ENUM_LABEL_RDB_ENTRY_TGDB_RATING, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_TGDB_RATING), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_TGDB_RATING), - db_info_entry->tgdb_rating, - info->path, path_len, info->list) == -1) + db_info_entry->tgdb_rating, info->path, info->list) == -1) goto error; } @@ -3102,8 +3099,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, MENU_ENUM_LABEL_RDB_ENTRY_FAMITSU_MAGAZINE_RATING, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_FAMITSU_MAGAZINE_RATING), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_FAMITSU_MAGAZINE_RATING), - db_info_entry->famitsu_magazine_rating, - info->path, path_len, info->list) == -1) + db_info_entry->famitsu_magazine_rating, info->path, info->list) == -1) goto error; } @@ -3113,7 +3109,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, MENU_ENUM_LABEL_RDB_ENTRY_EDGE_MAGAZINE_REVIEW, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_EDGE_MAGAZINE_REVIEW), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_EDGE_MAGAZINE_REVIEW), - db_info_entry->edge_magazine_review, info->path, path_len, info->list) == -1) + db_info_entry->edge_magazine_review, info->path, info->list) == -1) goto error; } @@ -3123,8 +3119,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, MENU_ENUM_LABEL_RDB_ENTRY_EDGE_MAGAZINE_RATING, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_EDGE_MAGAZINE_RATING), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_EDGE_MAGAZINE_RATING), - db_info_entry->edge_magazine_rating, - info->path, path_len, info->list) == -1) + db_info_entry->edge_magazine_rating, info->path, info->list) == -1) goto error; } @@ -3134,8 +3129,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, MENU_ENUM_LABEL_RDB_ENTRY_EDGE_MAGAZINE_ISSUE, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_EDGE_MAGAZINE_ISSUE), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_EDGE_MAGAZINE_ISSUE), - db_info_entry->edge_magazine_issue, - info->path, path_len, info->list) == -1) + db_info_entry->edge_magazine_issue, info->path, info->list) == -1) goto error; } @@ -3145,8 +3139,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, MENU_ENUM_LABEL_RDB_ENTRY_RELEASE_MONTH, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_RELEASE_MONTH), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_RELEASE_MONTH), - db_info_entry->releasemonth, - info->path, path_len, info->list) == -1) + db_info_entry->releasemonth, info->path, info->list) == -1) goto error; } @@ -3156,8 +3149,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, MENU_ENUM_LABEL_RDB_ENTRY_RELEASE_YEAR, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_RELEASE_YEAR), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_RELEASE_YEAR), - db_info_entry->releaseyear, - info->path, path_len, info->list) == -1) + db_info_entry->releaseyear, info->path, info->list) == -1) goto error; } @@ -3167,7 +3159,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, MENU_ENUM_LABEL_RDB_ENTRY_BBFC_RATING, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_BBFC_RATING), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_BBFC_RATING), - db_info_entry->bbfc_rating, info->path, path_len, info->list) == -1) + db_info_entry->bbfc_rating, info->path, info->list) == -1) goto error; } @@ -3177,7 +3169,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, MENU_ENUM_LABEL_RDB_ENTRY_ESRB_RATING, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_ESRB_RATING), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_ESRB_RATING), - db_info_entry->esrb_rating, info->path, path_len, info->list) == -1) + db_info_entry->esrb_rating, info->path, info->list) == -1) goto error; } @@ -3187,7 +3179,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, MENU_ENUM_LABEL_RDB_ENTRY_ELSPA_RATING, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_ELSPA_RATING), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_ELSPA_RATING), - db_info_entry->elspa_rating, info->path, path_len, info->list) == -1) + db_info_entry->elspa_rating, info->path, info->list) == -1) goto error; } @@ -3197,7 +3189,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, MENU_ENUM_LABEL_RDB_ENTRY_PEGI_RATING, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_PEGI_RATING), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_PEGI_RATING), - db_info_entry->pegi_rating, info->path, path_len, info->list) == -1) + db_info_entry->pegi_rating, info->path, info->list) == -1) goto error; } @@ -3207,7 +3199,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, MENU_ENUM_LABEL_RDB_ENTRY_ENHANCEMENT_HW, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_ENHANCEMENT_HW), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_ENHANCEMENT_HW), - db_info_entry->enhancement_hw, info->path, path_len, info->list) == -1) + db_info_entry->enhancement_hw, info->path, info->list) == -1) goto error; } @@ -3217,7 +3209,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, MENU_ENUM_LABEL_RDB_ENTRY_CERO_RATING, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_CERO_RATING), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_CERO_RATING), - db_info_entry->cero_rating, info->path, path_len, info->list) == -1) + db_info_entry->cero_rating, info->path, info->list) == -1) goto error; } @@ -3227,7 +3219,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, MENU_ENUM_LABEL_RDB_ENTRY_SERIAL, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_SERIAL), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_SERIAL), - db_info_entry->serial, info->path, path_len, info->list) == -1) + db_info_entry->serial, info->path, info->list) == -1) goto error; } @@ -3237,7 +3229,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, MENU_ENUM_LABEL_RDB_ENTRY_ANALOG, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_ANALOG), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_ANALOG), - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_TRUE), info->path, path_len, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_TRUE), info->path, info->list) == -1) goto error; } @@ -3248,7 +3240,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, MENU_ENUM_LABEL_RDB_ENTRY_RUMBLE, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_RUMBLE), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_RUMBLE), - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_TRUE), info->path, path_len, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_TRUE), info->path, info->list) == -1) goto error; } @@ -3259,7 +3251,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, MENU_ENUM_LABEL_RDB_ENTRY_COOP, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_COOP), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_COOP), - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_TRUE), info->path, path_len, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_TRUE), info->path, info->list) == -1) goto error; } @@ -3270,7 +3262,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, MENU_ENUM_LABEL_RDB_ENTRY_ACHIEVEMENTS, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_ACHIEVEMENTS), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_ACHIEVEMENTS), - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_TRUE), info->path, path_len, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_TRUE), info->path, info->list) == -1) goto error; } @@ -3281,7 +3273,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, MENU_ENUM_LABEL_RDB_ENTRY_CONSOLE_EXCLUSIVE, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_CONSOLE_EXCLUSIVE), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_CONSOLE_EXCLUSIVE), - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_TRUE), info->path, path_len, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_TRUE), info->path, info->list) == -1) goto error; } @@ -3292,7 +3284,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, MENU_ENUM_LABEL_RDB_ENTRY_PLATFORM_EXCLUSIVE, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_PLATFORM_EXCLUSIVE), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_PLATFORM_EXCLUSIVE), - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_TRUE), info->path, path_len, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_TRUE), info->path, info->list) == -1) goto error; } @@ -3306,8 +3298,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, MENU_ENUM_LABEL_RDB_ENTRY_CRC32, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_CRC32), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_CRC32), - crc_str, - info->path, path_len, info->list) == -1) + crc_str, info->path, info->list) == -1) goto error; } @@ -3317,8 +3308,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, MENU_ENUM_LABEL_RDB_ENTRY_SHA1, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_SHA1), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_SHA1), - db_info_entry->sha1, - info->path, path_len, info->list) == -1) + db_info_entry->sha1, info->path, info->list) == -1) goto error; } @@ -3328,8 +3318,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, MENU_ENUM_LABEL_RDB_ENTRY_MD5, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_MD5), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_MD5), - db_info_entry->md5, - info->path, path_len, info->list) == -1) + db_info_entry->md5, info->path, info->list) == -1) goto error; } } @@ -6560,7 +6549,7 @@ static int menu_displaylist_parse_disc_info(file_list_t *info_list, unsigned type) { unsigned i; - unsigned count = 0; + unsigned count = 0; struct string_list *list = cdrom_get_available_drives(); const char *msg_drive_number = msg_hash_to_str(MSG_DRIVE_NUMBER); @@ -6594,8 +6583,7 @@ static int menu_displaylist_parse_disc_info(file_list_t *info_list, static unsigned menu_displaylist_populate_subsystem( const struct retro_subsystem_info* subsystem, - settings_t *settings, - file_list_t *list) + settings_t *settings, file_list_t *list) { char star_char[16]; unsigned count = 0; diff --git a/menu/menu_driver.c b/menu/menu_driver.c index e05cba034d23..fff84f92d562 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -542,13 +542,13 @@ static menu_search_terms_t *menu_entries_search_get_terms_internal(void) * 'idx' to the matching list entry index. */ bool menu_entries_list_search(const char *needle, size_t *idx) { + size_t i; struct menu_state *menu_st = &menu_driver_state; menu_list_t *menu_list = menu_st->entries.list; file_list_t *list = MENU_LIST_GET_SELECTION(menu_list, (unsigned)0); bool match_found = false; bool char_search = false; char needle_char = 0; - size_t i; if ( !list || string_is_empty(needle) @@ -640,7 +640,8 @@ bool menu_entries_list_search(const char *needle, size_t *idx) /* Display the date and time - time_mode will influence how * the time representation will look like. * */ -size_t menu_display_timedate(gfx_display_ctx_datetime_t *datetime, char *s, size_t len) +size_t menu_display_timedate(gfx_display_ctx_datetime_t *datetime, + char *s, size_t len) { /* Storage container for current menu datetime * representation string */ @@ -1014,7 +1015,8 @@ size_t menu_display_timedate(gfx_display_ctx_datetime_t *datetime, char *s, size } /* Display current (battery) power state */ -size_t menu_display_powerstate(gfx_display_ctx_powerstate_t *powerstate, char *s, size_t len) +size_t menu_display_powerstate(gfx_display_ctx_powerstate_t *powerstate, + char *s, size_t len) { int percent = 0; struct menu_state *menu_st = &menu_driver_state; @@ -1254,12 +1256,9 @@ static void menu_list_free_list( file_list_free(list); } -static void menu_list_pop_stack( - const menu_ctx_driver_t *menu_driver_ctx, - void *menu_userdata, - menu_list_t *list, - size_t idx, - size_t *directory_ptr) +static void menu_list_pop_stack(const menu_ctx_driver_t *menu_driver_ctx, + void *menu_userdata, menu_list_t *list, + size_t idx, size_t *directory_ptr) { file_list_t *menu_list = MENU_LIST_GET(list, (unsigned)idx); @@ -1292,8 +1291,7 @@ static int menu_list_flush_stack_type(const char *needle, const char *label, static void menu_list_flush_stack( const menu_ctx_driver_t *menu_driver_ctx, - void *menu_userdata, - struct menu_state *menu_st, + void *menu_userdata, struct menu_state *menu_st, menu_list_t *list, size_t idx, const char *needle, unsigned final_type) { @@ -1339,8 +1337,7 @@ static void menu_list_flush_stack( } } -static void menu_list_free( - const menu_ctx_driver_t *menu_driver_ctx, +static void menu_list_free(const menu_ctx_driver_t *menu_driver_ctx, menu_list_t *menu_list) { if (!menu_list) @@ -1431,12 +1428,9 @@ static menu_list_t *menu_list_new(const menu_ctx_driver_t *menu_driver_ctx) return NULL; } -static int menu_input_key_bind_set_mode_common( - struct menu_state *menu_st, - struct menu_bind_state *binds, - enum menu_input_binds_ctl_state state, - rarch_setting_t *setting, - settings_t *settings) +static int menu_input_key_bind_set_mode_common(struct menu_state *menu_st, + struct menu_bind_state *binds, enum menu_input_binds_ctl_state state, + rarch_setting_t *setting, settings_t *settings) { switch (state) { diff --git a/menu/menu_explore.c b/menu/menu_explore.c index 90c10851de8f..1e3e1c3e14e3 100644 --- a/menu/menu_explore.c +++ b/menu/menu_explore.c @@ -314,7 +314,7 @@ static void explore_add_unique_string( for (p = str + 1;; p++) { - size_t _len = 0; + size_t _len = 0; uint32_t hash = 0; explore_string_t* entry = NULL; diff --git a/menu/menu_screensaver.c b/menu/menu_screensaver.c index 3080959cd906..90c933ae63e1 100644 --- a/menu/menu_screensaver.c +++ b/menu/menu_screensaver.c @@ -298,9 +298,9 @@ static INLINE void menu_screensaver_set_dimensions( static bool menu_screensaver_init_effect(menu_screensaver_t *screensaver) { + size_t i; unsigned width; unsigned height; - size_t i; /* Create particle array, if required */ if (!screensaver->particles) @@ -311,7 +311,7 @@ static bool menu_screensaver_init_effect(menu_screensaver_t *screensaver) if (!screensaver->particles) return false; } - + width = screensaver->last_width; height = screensaver->last_height; @@ -518,12 +518,12 @@ void menu_screensaver_iterate( uint32_t particle_tint, unsigned width, unsigned height, const char *dir_assets) { - float base_particle_size; + size_t i; uint32_t tint_r; uint32_t tint_g; uint32_t tint_b; + float base_particle_size; float global_speed_factor; - size_t i; if (!screensaver) return; @@ -532,9 +532,9 @@ void menu_screensaver_iterate( if (!menu_screensaver_update_state( screensaver, p_disp, effect, particle_tint, - width, height, dir_assets) || - (screensaver->effect == MENU_SCREENSAVER_BLANK) || - !screensaver->particles) + width, height, dir_assets) + || (screensaver->effect == MENU_SCREENSAVER_BLANK) + || !screensaver->particles) return; base_particle_size = screensaver->particle_scale * screensaver->font_size; @@ -544,7 +544,7 @@ void menu_screensaver_iterate( /* Set global animation speed */ global_speed_factor = p_anim->delta_time / MENU_SS_EFFECT_PERIOD; - if (effect_speed > 0.0001f) + if (effect_speed > 0.0001f) global_speed_factor *= effect_speed; /* Update particle array */ @@ -784,9 +784,9 @@ void menu_screensaver_frame(menu_screensaver_t *screensaver, && font && screensaver->particles) { + size_t i; float y_centre_offset = screensaver->font_data.y_centre_offset; float particle_scale = screensaver->particle_scale; - size_t i; /* Bind font */ font_driver_bind_block(font, &screensaver->font_data.raster_block); diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 874b6b59a7ec..28c0f81db121 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -2326,7 +2326,7 @@ static void config_float( static void config_path( rarch_setting_t **list, rarch_setting_info_t *list_info, - char *target, size_t len, + char *s, size_t len, enum msg_hash_enums name_enum_idx, enum msg_hash_enums SHORT_enum_idx, const char *default_value, @@ -2338,7 +2338,7 @@ static void config_path( (*list)[list_info->index++] = setting_string_setting(ST_PATH, msg_hash_to_str(name_enum_idx), msg_hash_to_str(SHORT_enum_idx), - target, (unsigned)len, default_value, "", + s, (unsigned)len, default_value, "", group_info->name, subgroup_info->name, parent_group, change_handler, read_handler, false); @@ -2351,7 +2351,7 @@ static void config_path( static void config_dir( rarch_setting_t **list, rarch_setting_info_t *list_info, - char *target, size_t len, + char *s, size_t len, enum msg_hash_enums name_enum_idx, enum msg_hash_enums SHORT_enum_idx, const char *default_value, @@ -2364,7 +2364,7 @@ static void config_dir( (*list)[list_info->index++] = setting_string_setting(ST_DIR, msg_hash_to_str(name_enum_idx), msg_hash_to_str(SHORT_enum_idx), - target, (unsigned)len, default_value, + s, (unsigned)len, default_value, msg_hash_to_str(empty_enum_idx), group_info->name, subgroup_info->name, parent_group, change_handler, read_handler, @@ -2382,7 +2382,7 @@ static void config_dir( static void config_string( rarch_setting_t **list, rarch_setting_info_t *list_info, - char *target, size_t len, + char *s, size_t len, enum msg_hash_enums name_enum_idx, enum msg_hash_enums SHORT_enum_idx, const char *default_value, @@ -2394,7 +2394,7 @@ static void config_string( (*list)[list_info->index++] = setting_string_setting(ST_STRING, msg_hash_to_str(name_enum_idx), msg_hash_to_str(SHORT_enum_idx), - target, (unsigned)len, default_value, "", + s, (unsigned)len, default_value, "", group_info->name, subgroup_info->name, parent_group, change_handler, read_handler, false); MENU_SETTINGS_LIST_CURRENT_ADD_ENUM_IDX_PTR(list, list_info, name_enum_idx); @@ -2404,7 +2404,7 @@ static void config_string( static void config_string_alt( rarch_setting_t **list, rarch_setting_info_t *list_info, - char *target, size_t len, + char *s, size_t len, char *label, char* shortname, const char *default_value, @@ -2414,9 +2414,8 @@ static void config_string_alt( change_handler_t change_handler, change_handler_t read_handler) { (*list)[list_info->index++] = setting_string_setting(ST_STRING, - label, - shortname, - target, (unsigned)len, default_value, "", + label, shortname, + s, (unsigned)len, default_value, "", group_info->name, subgroup_info->name, parent_group, change_handler, read_handler, true); } @@ -2424,7 +2423,7 @@ static void config_string_alt( static void config_string_options( rarch_setting_t **list, rarch_setting_info_t *list_info, - char *target, size_t len, + char *s, size_t len, enum msg_hash_enums name_enum_idx, enum msg_hash_enums SHORT_enum_idx, const char *default_value, const char *values, @@ -2437,7 +2436,7 @@ static void config_string_options( ST_STRING_OPTIONS, msg_hash_to_str(name_enum_idx), msg_hash_to_str(SHORT_enum_idx), - target, (unsigned)len, default_value, "", values, + s, (unsigned)len, default_value, "", values, group_info->name, subgroup_info->name, parent_group, change_handler, read_handler, false); (*list)[list_info->index - 1].ui_type = ST_UI_TYPE_STRING_COMBOBOX; @@ -2452,7 +2451,7 @@ static void config_string_options( static void config_bind_alt( rarch_setting_t **list, rarch_setting_info_t *list_info, - struct retro_keybind *target, + struct retro_keybind *s, uint32_t player, uint32_t player_offset, const char *name, const char *SHORT, const struct retro_keybind *default_value, @@ -2460,7 +2459,7 @@ static void config_bind_alt( rarch_setting_group_info_t *subgroup_info, const char *parent_group) { - (*list)[list_info->index++] = setting_bind_setting(name, SHORT, target, + (*list)[list_info->index++] = setting_bind_setting(name, SHORT, s, player, player_offset, default_value, group_info->name, subgroup_info->name, parent_group, true); @@ -2600,12 +2599,12 @@ static int setting_action_ok_bind_defaults( if (!setting) return -1; - target = &input_config_binds[setting->index_offset][0]; - def_binds = (setting->index_offset) - ? retro_keybinds_rest - : retro_keybinds_1; - binds->begin = MENU_SETTINGS_BIND_BEGIN; - binds->last = MENU_SETTINGS_BIND_LAST; + target = &input_config_binds[setting->index_offset][0]; + def_binds = (setting->index_offset) + ? retro_keybinds_rest + : retro_keybinds_1; + binds->begin = MENU_SETTINGS_BIND_BEGIN; + binds->last = MENU_SETTINGS_BIND_LAST; for ( i = MENU_SETTINGS_BIND_BEGIN; i <= MENU_SETTINGS_BIND_LAST; i++, target++) @@ -3011,8 +3010,7 @@ static void setting_get_string_representation_max_users(rarch_setting_t *setting #if defined(HAVE_CHEEVOS) || defined(HAVE_CLOUDSYNC) static void setting_get_string_representation_password( - rarch_setting_t *setting, - char *s, size_t len) + rarch_setting_t *setting, char *s, size_t len) { if (!setting) return; @@ -3091,8 +3089,7 @@ static void setting_get_string_representation_uint_ai_service_mode( } static void setting_get_string_representation_uint_ai_service_lang( - rarch_setting_t *setting, - char *s, size_t len) + rarch_setting_t *setting, char *s, size_t len) { enum msg_hash_enums enum_idx = MSG_UNKNOWN; if (!setting) @@ -3311,8 +3308,7 @@ static void setting_get_string_representation_uint_ai_service_lang( #endif static void setting_get_string_representation_uint_menu_thumbnails( - rarch_setting_t *setting, - char *s, size_t len) + rarch_setting_t *setting, char *s, size_t len) { if (!setting) return; @@ -3347,8 +3343,7 @@ static void setting_get_string_representation_uint_menu_thumbnails( } static void setting_get_string_representation_uint_menu_left_thumbnails( - rarch_setting_t *setting, - char *s, size_t len) + rarch_setting_t *setting, char *s, size_t len) { if (!setting) return; @@ -3383,8 +3378,7 @@ static void setting_get_string_representation_uint_menu_left_thumbnails( } static void setting_get_string_representation_uint_menu_icon_thumbnails( - rarch_setting_t *setting, - char *s, size_t len) + rarch_setting_t *setting, char *s, size_t len) { if (!setting) return; @@ -3406,9 +3400,9 @@ static void setting_get_string_representation_uint_menu_icon_thumbnails( static void setting_set_string_representation_timedate_date_separator(char *s) { settings_t *settings = config_get_ptr(); - unsigned menu_timedate_date_separator = settings ? - settings->uints.menu_timedate_date_separator : - MENU_TIMEDATE_DATE_SEPARATOR_HYPHEN; + unsigned menu_timedate_date_separator = settings + ? settings->uints.menu_timedate_date_separator + : MENU_TIMEDATE_DATE_SEPARATOR_HYPHEN; switch (menu_timedate_date_separator) { @@ -3425,8 +3419,7 @@ static void setting_set_string_representation_timedate_date_separator(char *s) } static void setting_get_string_representation_uint_menu_timedate_style( - rarch_setting_t *setting, - char *s, size_t len) + rarch_setting_t *setting, char *s, size_t len) { if (!setting) return; @@ -3566,8 +3559,7 @@ static void setting_get_string_representation_uint_menu_timedate_style( } static void setting_get_string_representation_uint_menu_timedate_date_separator( - rarch_setting_t *setting, - char *s, size_t len) + rarch_setting_t *setting, char *s, size_t len) { if (!setting) return; @@ -3587,8 +3579,7 @@ static void setting_get_string_representation_uint_menu_timedate_date_separator( } static void setting_get_string_representation_uint_menu_add_content_entry_display_type( - rarch_setting_t *setting, - char *s, size_t len) + rarch_setting_t *setting, char *s, size_t len) { if (!setting) return; @@ -3617,8 +3608,7 @@ static void setting_get_string_representation_uint_menu_add_content_entry_displa } static void setting_get_string_representation_uint_menu_contentless_cores_display_type( - rarch_setting_t *setting, - char *s, size_t len) + rarch_setting_t *setting, char *s, size_t len) { if (!setting) return; @@ -3653,8 +3643,7 @@ static void setting_get_string_representation_uint_menu_contentless_cores_displa } static void setting_get_string_representation_uint_rgui_menu_color_theme( - rarch_setting_t *setting, - char *s, size_t len) + rarch_setting_t *setting, char *s, size_t len) { if (!setting) return; @@ -3887,8 +3876,7 @@ static void setting_get_string_representation_uint_rgui_menu_color_theme( } static void setting_get_string_representation_uint_rgui_thumbnail_scaler( - rarch_setting_t *setting, - char *s, size_t len) + rarch_setting_t *setting, char *s, size_t len) { if (!setting) return; @@ -3917,8 +3905,7 @@ static void setting_get_string_representation_uint_rgui_thumbnail_scaler( } static void setting_get_string_representation_uint_rgui_internal_upscale_level( - rarch_setting_t *setting, - char *s, size_t len) + rarch_setting_t *setting, char *s, size_t len) { if (!setting) return; @@ -3990,8 +3977,7 @@ static void setting_get_string_representation_uint_rgui_internal_upscale_level( #if !defined(DINGUX) static void setting_get_string_representation_uint_rgui_aspect_ratio( - rarch_setting_t *setting, - char *s, size_t len) + rarch_setting_t *setting, char *s, size_t len) { if (!setting) return; @@ -4075,8 +4061,7 @@ static void setting_get_string_representation_uint_rgui_aspect_ratio( } static void setting_get_string_representation_uint_rgui_aspect_ratio_lock( - rarch_setting_t *setting, - char *s, size_t len) + rarch_setting_t *setting, char *s, size_t len) { if (!setting) return; @@ -4112,8 +4097,7 @@ static void setting_get_string_representation_uint_rgui_aspect_ratio_lock( #endif static void setting_get_string_representation_uint_rgui_particle_effect( - rarch_setting_t *setting, - char *s, size_t len) + rarch_setting_t *setting, char *s, size_t len) { if (!setting) return; @@ -4161,8 +4145,7 @@ static void setting_get_string_representation_uint_rgui_particle_effect( #ifdef HAVE_XMB static void setting_get_string_representation_uint_menu_xmb_animation_move_up_down( - rarch_setting_t *setting, - char *s, size_t len) + rarch_setting_t *setting, char *s, size_t len) { if (!setting) return; @@ -4182,8 +4165,7 @@ static void setting_get_string_representation_uint_menu_xmb_animation_move_up_do } static void setting_get_string_representation_uint_menu_xmb_animation_opening_main_menu( - rarch_setting_t *setting, - char *s, size_t len) + rarch_setting_t *setting, char *s, size_t len) { if (!setting) return; @@ -4206,8 +4188,7 @@ static void setting_get_string_representation_uint_menu_xmb_animation_opening_ma } static void setting_get_string_representation_uint_menu_xmb_animation_horizontal_highlight( - rarch_setting_t *setting, - char *s, size_t len) + rarch_setting_t *setting, char *s, size_t len) { if (!setting) return; @@ -4228,8 +4209,7 @@ static void setting_get_string_representation_uint_menu_xmb_animation_horizontal #endif static void setting_get_string_representation_uint_menu_ticker_type( - rarch_setting_t *setting, - char *s, size_t len) + rarch_setting_t *setting, char *s, size_t len) { if (!setting) return; @@ -4253,8 +4233,7 @@ static void setting_get_string_representation_uint_menu_ticker_type( #ifdef HAVE_XMB static void setting_get_string_representation_uint_xmb_icon_theme( - rarch_setting_t *setting, - char *s, size_t len) + rarch_setting_t *setting, char *s, size_t len) { if (!setting) return; @@ -4313,8 +4292,7 @@ static void setting_get_string_representation_uint_xmb_icon_theme( } static void setting_get_string_representation_uint_xmb_layout( - rarch_setting_t *setting, - char *s, size_t len) + rarch_setting_t *setting, char *s, size_t len) { if (!setting) return; @@ -4334,8 +4312,7 @@ static void setting_get_string_representation_uint_xmb_layout( } static void setting_get_string_representation_uint_xmb_menu_color_theme( - rarch_setting_t *setting, - char *s, size_t len) + rarch_setting_t *setting, char *s, size_t len) { if (!setting) return; @@ -4468,8 +4445,7 @@ static void setting_get_string_representation_uint_xmb_menu_color_theme( #ifdef HAVE_MATERIALUI static void setting_get_string_representation_uint_materialui_menu_color_theme( - rarch_setting_t *setting, - char *s, size_t len) + rarch_setting_t *setting, char *s, size_t len) { if (!setting) return; @@ -4602,8 +4578,7 @@ static void setting_get_string_representation_uint_materialui_menu_color_theme( } static void setting_get_string_representation_uint_materialui_menu_transition_animation( - rarch_setting_t *setting, - char *s, size_t len) + rarch_setting_t *setting, char *s, size_t len) { if (!setting) return; @@ -4636,8 +4611,7 @@ static void setting_get_string_representation_uint_materialui_menu_transition_an } static void setting_get_string_representation_uint_materialui_menu_thumbnail_view_portrait( - rarch_setting_t *setting, - char *s, size_t len) + rarch_setting_t *setting, char *s, size_t len) { if (!setting) return; @@ -4670,8 +4644,7 @@ static void setting_get_string_representation_uint_materialui_menu_thumbnail_vie } static void setting_get_string_representation_uint_materialui_menu_thumbnail_view_landscape( - rarch_setting_t *setting, - char *s, size_t len) + rarch_setting_t *setting, char *s, size_t len) { if (!setting) return; @@ -4709,8 +4682,7 @@ static void setting_get_string_representation_uint_materialui_menu_thumbnail_vie } static void setting_get_string_representation_uint_materialui_landscape_layout_optimization( - rarch_setting_t *setting, - char *s, size_t len) + rarch_setting_t *setting, char *s, size_t len) { if (!setting) return; @@ -4740,8 +4712,7 @@ static void setting_get_string_representation_uint_materialui_landscape_layout_o #ifdef HAVE_OZONE static void setting_get_string_representation_uint_ozone_menu_color_theme( - rarch_setting_t *setting, - char *s, size_t len) + rarch_setting_t *setting, char *s, size_t len) { if (!setting) return; @@ -4826,8 +4797,7 @@ static void setting_get_string_representation_uint_ozone_menu_color_theme( #if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL) #if defined(HAVE_XMB) && defined(HAVE_SHADERPIPELINE) static void setting_get_string_representation_uint_xmb_shader_pipeline( - rarch_setting_t *setting, - char *s, size_t len) + rarch_setting_t *setting, char *s, size_t len) { if (!setting) return; @@ -4875,8 +4845,7 @@ static void setting_get_string_representation_uint_xmb_shader_pipeline( #ifdef HAVE_SCREENSHOTS #ifdef HAVE_GFX_WIDGETS static void setting_get_string_representation_uint_notification_show_screenshot_duration( - rarch_setting_t *setting, - char *s, size_t len) + rarch_setting_t *setting, char *s, size_t len) { if (!setting) return; @@ -4899,8 +4868,7 @@ static void setting_get_string_representation_uint_notification_show_screenshot_ } static void setting_get_string_representation_uint_notification_show_screenshot_flash( - rarch_setting_t *setting, - char *s, size_t len) + rarch_setting_t *setting, char *s, size_t len) { if (!setting) return; @@ -4922,8 +4890,7 @@ static void setting_get_string_representation_uint_notification_show_screenshot_ #endif static void setting_get_string_representation_uint_video_autoswitch_refresh_rate( - rarch_setting_t *setting, - char *s, size_t len) + rarch_setting_t *setting, char *s, size_t len) { if (!setting) return; diff --git a/network/cloud_sync/webdav.c b/network/cloud_sync/webdav.c index 075c2fb34725..433f54d1084b 100644 --- a/network/cloud_sync/webdav.c +++ b/network/cloud_sync/webdav.c @@ -501,11 +501,11 @@ static void webdav_stat_cb(retro_task_t *task, void *task_data, void *user_data, static bool webdav_sync_begin(cloud_sync_complete_handler_t cb, void *user_data) { + char *auth_header; + size_t _len = 0; settings_t *settings = config_get_ptr(); const char *url = settings->arrays.webdav_url; webdav_state_t *webdav_st = webdav_state_get_ptr(); - size_t len = 0; - char *auth_header; if (string_is_empty(url)) return false; @@ -517,18 +517,18 @@ static bool webdav_sync_begin(cloud_sync_complete_handler_t cb, void *user_data) /* TODO: LOCK? */ if (!strstr(url, "://")) - len += strlcpy(webdav_st->url, "http://", STRLEN_CONST("http://")); - strlcpy(webdav_st->url + len, url, sizeof(webdav_st->url) - len); + _len += strlcpy(webdav_st->url, "http://", STRLEN_CONST("http://")); + strlcpy(webdav_st->url + _len, url, sizeof(webdav_st->url) - _len); fill_pathname_slash(webdav_st->url, sizeof(webdav_st->url)); /* url/username/password may have changed, redo auth check */ webdav_st->basic = true; - auth_header = webdav_get_auth_header(NULL, NULL); + auth_header = webdav_get_auth_header(NULL, NULL); if (auth_header) { webdav_cb_state_t *webdav_cb_st = (webdav_cb_state_t*)calloc(1, sizeof(webdav_cb_state_t)); - webdav_cb_st->cb = cb; + webdav_cb_st->cb = cb; webdav_cb_st->user_data = user_data; task_push_webdav_stat(webdav_st->url, true, auth_header, webdav_stat_cb, webdav_cb_st); free(auth_header);