* Naming convention changes for variable names/function arguments

* Try to fit lines within ANSI 80-char limit
This commit is contained in:
LibretroAdmin 2025-01-19 20:19:14 +01:00
parent 274cd419fa
commit cde82f532c
55 changed files with 1215 additions and 1500 deletions

View File

@ -73,14 +73,36 @@ error:
#define BYTES_TO_FRAMES(bytes, frame_bits) ((bytes) * 8 / frame_bits) #define BYTES_TO_FRAMES(bytes, frame_bits) ((bytes) * 8 / frame_bits)
#define FRAMES_TO_BYTES(frames, frame_bits) ((frames) * frame_bits / 8) #define FRAMES_TO_BYTES(frames, frame_bits) ((frames) * frame_bits / 8)
static bool alsa_start(void *data, bool is_shutdown); static bool alsa_start(void *data, bool is_shutdown)
static ssize_t alsa_write(void *data, const void *buf_, size_t size_)
{ {
alsa_t *alsa = (alsa_t*)data; alsa_t *alsa = (alsa_t*)data;
const uint8_t *buf = (const uint8_t*)buf_; if (!alsa->is_paused)
snd_pcm_sframes_t written = 0; return true;
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); 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. /* Workaround buggy menu code.
* If a write happens while we're paused, we might never progress. */ * 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; 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) static void alsa_free(void *data)
{ {
alsa_t *alsa = (alsa_t*)data; alsa_t *alsa = (alsa_t*)data;

View File

@ -219,14 +219,14 @@ static int check_pcm_status(void *data, int channel_type)
return ret; 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; alsa_qsa_t *alsa = (alsa_qsa_t*)data;
snd_pcm_sframes_t written = 0; ssize_t written = 0;
while (size) 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) 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; alsa->buffer_ptr += avail_write;
buf = (void*)((uint8_t*)buf + avail_write); buf = (void*)((uint8_t*)buf + avail_write);
size -= avail_write; len -= avail_write;
written += 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 -1;
} }
} }
} }
return written; return written;

View File

@ -157,8 +157,9 @@ error:
return NULL; 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; alsa_thread_t *alsa = (alsa_thread_t*)data;
if (alsa->info.thread_dead) 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) if (alsa->nonblock)
{ {
size_t avail; size_t avail;
size_t write_amt;
slock_lock(alsa->info.fifo_lock); slock_lock(alsa->info.fifo_lock);
avail = FIFO_WRITE_AVAIL(alsa->info.buffer); 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); slock_unlock(alsa->info.fifo_lock);
return write_amt;
} }
else else
{ {
size_t written = 0; while (written < len && !alsa->info.thread_dead)
while (written < size && !alsa->info.thread_dead)
{ {
size_t avail; size_t avail;
slock_lock(alsa->info.fifo_lock); 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 else
{ {
size_t write_amt = MIN(size - written, avail); size_t write_amt = MIN(len - written, avail);
fifo_write(alsa->info.buffer, fifo_write(alsa->info.buffer,
(const char*)buf + written, write_amt); (const char*)buf + written, write_amt);
slock_unlock(alsa->info.fifo_lock); slock_unlock(alsa->info.fifo_lock);
written += write_amt; written += write_amt;
} }
} }
return written;
} }
return written;
} }
static bool alsa_thread_alive(void *data) static bool alsa_thread_alive(void *data)

View File

@ -82,15 +82,15 @@ error:
return NULL; 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; int *fd = (int*)data;
if (size == 0) if (len == 0)
return 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)) if (errno == EAGAIN && (fcntl(*fd, F_GETFL) & O_NONBLOCK))
return 0; return 0;
@ -98,7 +98,7 @@ static ssize_t audioio_write(void *data, const void *buf, size_t size)
return -1; return -1;
} }
return ret; return written;
} }
static bool audioio_stop(void *data) static bool audioio_stop(void *data)

View File

@ -312,26 +312,26 @@ error:
return NULL; 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; coreaudio_t *dev = (coreaudio_t*)data;
const uint8_t *buf = (const uint8_t*)buf_; const uint8_t *buf = (const uint8_t*)buf_;
size_t written = 0; size_t written = 0;
while (!dev->is_paused && size > 0) while (!dev->is_paused && len > 0)
{ {
size_t write_avail; size_t write_avail;
slock_lock(dev->lock); slock_lock(dev->lock);
write_avail = FIFO_WRITE_AVAIL(dev->buffer); write_avail = FIFO_WRITE_AVAIL(dev->buffer);
if (write_avail > size) if (write_avail > len)
write_avail = size; write_avail = len;
fifo_write(dev->buffer, buf, write_avail); fifo_write(dev->buffer, buf, write_avail);
buf += write_avail; buf += write_avail;
written += write_avail; written += write_avail;
size -= write_avail; len -= write_avail;
if (dev->nonblock) if (dev->nonblock)
{ {
@ -409,16 +409,9 @@ static size_t coreaudio_buffer_size(void *data)
return dev->buffer_size; return dev->buffer_size;
} }
static void *coreaudio_device_list_new(void *data) /* TODO/FIXME - implement */
{ static void *coreaudio_device_list_new(void *data) { return NULL; }
/* TODO/FIXME */ static void coreaudio_device_list_free(void *data, void *array_list_data) { }
return NULL;
}
static void coreaudio_device_list_free(void *data, void *array_list_data)
{
/* TODO/FIXME */
}
audio_driver_t audio_coreaudio = { audio_driver_t audio_coreaudio = {
coreaudio_init, coreaudio_init,

View File

@ -307,12 +307,11 @@ static void *coreaudio3_init(const char *device,
return (__bridge_retained void *)dev; return (__bridge_retained void *)dev;
} }
static ssize_t coreaudio3_write(void *data, static ssize_t coreaudio3_write(void *data, const void *buf_, size_t len)
const void *buf_, size_t size)
{ {
CoreAudio3 *dev = (__bridge CoreAudio3 *)data; CoreAudio3 *dev = (__bridge CoreAudio3 *)data;
return [dev writeFloat:(const float *) 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) static void coreaudio3_set_nonblock_state(void *data, bool state)

View File

@ -162,19 +162,19 @@ static void ctr_csnd_audio_free(void *data)
free(ctr); 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; int i;
uint32_t samples_played = 0; uint32_t samples_played = 0;
uint64_t current_tick = 0; uint64_t current_tick = 0;
const uint16_t *src = buf; const uint16_t *src = buf;
ctr_csnd_audio_t *ctr = (ctr_csnd_audio_t*)data; ctr_csnd_audio_t *ctr = (ctr_csnd_audio_t*)data;
ctr_csnd_audio_update_playpos(ctr); ctr_csnd_audio_update_playpos(ctr);
if ((((ctr->playpos - ctr->pos) & CTR_CSND_AUDIO_COUNT_MASK) < (CTR_CSND_AUDIO_COUNT >> 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->pos - ctr->playpos) & CTR_CSND_AUDIO_COUNT_MASK) < (CTR_CSND_AUDIO_COUNT >> 4))
(((ctr->playpos - ctr->pos) & CTR_CSND_AUDIO_COUNT_MASK) < (size >> 2))) || (((ctr->playpos - ctr->pos) & CTR_CSND_AUDIO_COUNT_MASK) < (len >> 2)))
{ {
if (ctr->nonblock) if (ctr->nonblock)
ctr->pos = (ctr->playpos + (CTR_CSND_AUDIO_COUNT >> 1)) & CTR_CSND_AUDIO_COUNT_MASK; 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->l[ctr->pos] = src[i];
ctr->r[ctr->pos] = src[i + 1]; 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->l, CTR_CSND_AUDIO_SIZE);
GSPGPU_FlushDataCache(ctr->r, CTR_CSND_AUDIO_SIZE); GSPGPU_FlushDataCache(ctr->r, CTR_CSND_AUDIO_SIZE);
return size; return len;
} }
static bool ctr_csnd_audio_stop(void *data) 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; ctr->nonblock = state;
} }
static bool ctr_csnd_audio_use_float(void *data) static bool ctr_csnd_audio_use_float(void *data) { return false; }
{
(void)data;
return false;
}
static size_t ctr_csnd_audio_write_avail(void *data) static size_t ctr_csnd_audio_write_avail(void *data)
{ {

View File

@ -91,15 +91,15 @@ static void ctr_dsp_audio_free(void *data)
ndspExit(); 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; u32 pos;
ctr_dsp_audio_t * ctr = (ctr_dsp_audio_t*)data; ctr_dsp_audio_t *ctr = (ctr_dsp_audio_t*)data;
uint32_t sample_pos = ndspChnGetSamplePos(ctr->channel); uint32_t sample_pos = ndspChnGetSamplePos(ctr->channel);
if ((((sample_pos - ctr->pos) & CTR_DSP_AUDIO_COUNT_MASK) < (CTR_DSP_AUDIO_COUNT >> 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)) || || (((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))) || (((sample_pos - ctr->pos) & CTR_DSP_AUDIO_COUNT_MASK) < (len >> 2)))
{ {
if (ctr->nonblock) if (ctr->nonblock)
ctr->pos = (sample_pos + (CTR_DSP_AUDIO_COUNT >> 1)) & CTR_DSP_AUDIO_COUNT_MASK; 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); 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))); || (((ctr->pos - (CTR_DSP_AUDIO_COUNT >> 4) - sample_pos) & CTR_DSP_AUDIO_COUNT_MASK) > (CTR_DSP_AUDIO_COUNT >> 1)));
} }
} }
pos = ctr->pos << 2; 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, memcpy(ctr->dsp_buf.data_pcm8 + pos, buf,
(CTR_DSP_AUDIO_SIZE - pos)); (CTR_DSP_AUDIO_SIZE - pos));
DSP_FlushDataCache(ctr->dsp_buf.data_pcm8 + pos, (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), memcpy(ctr->dsp_buf.data_pcm8, (uint8_t*) buf + (CTR_DSP_AUDIO_SIZE - pos),
(pos + size - CTR_DSP_AUDIO_SIZE)); (pos + len - CTR_DSP_AUDIO_SIZE));
DSP_FlushDataCache(ctr->dsp_buf.data_pcm8, (pos + size - CTR_DSP_AUDIO_SIZE)); DSP_FlushDataCache(ctr->dsp_buf.data_pcm8, (pos + len - CTR_DSP_AUDIO_SIZE));
} }
else else
{ {
memcpy(ctr->dsp_buf.data_pcm8 + pos, buf, size); memcpy(ctr->dsp_buf.data_pcm8 + pos, buf, len);
DSP_FlushDataCache(ctr->dsp_buf.data_pcm8 + pos, size); DSP_FlushDataCache(ctr->dsp_buf.data_pcm8 + pos, len);
} }
ctr->pos += size >> 2; ctr->pos += len >> 2;
ctr->pos &= CTR_DSP_AUDIO_COUNT_MASK; ctr->pos &= CTR_DSP_AUDIO_COUNT_MASK;
return size; return len;
} }
static bool ctr_dsp_audio_stop(void *data) 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; ctr->nonblock = state;
} }
static bool ctr_dsp_audio_use_float(void *data) static bool ctr_dsp_audio_use_float(void *data) { return false; }
{
(void)data;
return false;
}
static size_t ctr_dsp_audio_write_avail(void *data) static size_t ctr_dsp_audio_write_avail(void *data)
{ {

View File

@ -198,7 +198,7 @@ static void ctr_dsp_thread_audio_free(void *data)
ctr = NULL; 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; size_t avail, written;
ctr_dsp_thread_audio_t * ctr = (ctr_dsp_thread_audio_t*)data; 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); slock_lock(ctr->fifo_lock);
avail = FIFO_WRITE_AVAIL(ctr->fifo); avail = FIFO_WRITE_AVAIL(ctr->fifo);
written = MIN(avail, size); written = MIN(avail, len);
if (written > 0) if (written > 0)
{ {
fifo_write(ctr->fifo, buf, written); 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 else
{ {
written = 0; written = 0;
while (written < size && ctr->running) while (written < len && ctr->running)
{ {
slock_lock(ctr->fifo_lock); slock_lock(ctr->fifo_lock);
avail = FIFO_WRITE_AVAIL(ctr->fifo); 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 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); fifo_write(ctr->fifo, (const char*)buf + written, write_amt);
scond_signal(ctr->fifo_avail); scond_signal(ctr->fifo_avail);
slock_unlock(ctr->fifo_lock); slock_unlock(ctr->fifo_lock);

View File

@ -205,7 +205,7 @@ static DWORD CALLBACK dsound_thread(PVOID data)
IDirectSoundBuffer_Unlock(ds->dsb, region.chunk1, IDirectSoundBuffer_Unlock(ds->dsb, region.chunk1,
region.size1, region.chunk2, region.size2); 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; % ds->buffer_size;
if (is_pull) if (is_pull)
@ -501,7 +501,7 @@ static void dsound_set_nonblock_state(void *data, bool state)
ds->nonblock = 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; size_t written = 0;
dsound_t *ds = (dsound_t*)data; 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 (ds->nonblock)
{ {
if (size > 0) if (len > 0)
{ {
size_t avail; size_t avail;
EnterCriticalSection(&ds->crit); EnterCriticalSection(&ds->crit);
avail = FIFO_WRITE_AVAIL(ds->buffer); avail = FIFO_WRITE_AVAIL(ds->buffer);
if (avail > size) if (avail > len)
avail = size; avail = len;
fifo_write(ds->buffer, buf, avail); fifo_write(ds->buffer, buf, avail);
LeaveCriticalSection(&ds->crit); LeaveCriticalSection(&ds->crit);
buf += avail; buf += avail;
size -= avail; len -= avail;
written += avail; written += avail;
} }
} }
else else
{ {
while (size > 0) while (len > 0)
{ {
size_t avail; size_t avail;
EnterCriticalSection(&ds->crit); EnterCriticalSection(&ds->crit);
avail = FIFO_WRITE_AVAIL(ds->buffer); avail = FIFO_WRITE_AVAIL(ds->buffer);
if (avail > size) if (avail > len)
avail = size; avail = len;
fifo_write(ds->buffer, buf, avail); fifo_write(ds->buffer, buf, avail);
LeaveCriticalSection(&ds->crit); LeaveCriticalSection(&ds->crit);
buf += avail; buf += avail;
size -= avail; len -= avail;
written += avail; written += avail;
if (!ds->thread_alive) if (!ds->thread_alive)

View File

@ -79,7 +79,7 @@ static void *gx_audio_init(const char *device,
AIInit(NULL); AIInit(NULL);
AIRegisterDMACallback(dma_callback); 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 */ (in settings going down from 48000) -> set to 32000 hz */
if (rate <= 32000 || (rate >= 40000 && rate < 48000)) 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. */ /* Wii uses silly R, L, R, L interleaving. */
static INLINE void copy_swapped(uint32_t * restrict dst, 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 do
{ {
uint32_t s = *src++; uint32_t s = *src++;
*dst++ = (s >> 16) | (s << 16); *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_; const uint32_t *buf = buf_;
gx_audio_t *wa = data; 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); wa->dma_write = (wa->dma_write + 1) & (BLOCKS - 1);
} }
} }
return len;
return size;
} }
static bool gx_audio_stop(void *data) static bool gx_audio_stop(void *data)
@ -209,18 +208,9 @@ static size_t gx_audio_write_avail(void *data)
& (BLOCKS - 1)) * CHUNK_SIZE; & (BLOCKS - 1)) * CHUNK_SIZE;
} }
static size_t gx_audio_buffer_size(void *data) static size_t gx_audio_buffer_size(void *data) { return BLOCKS * CHUNK_SIZE; }
{ /* TODO/FIXME - implement/verify? */
(void)data; static bool gx_audio_use_float(void *data) { return false; }
return BLOCKS * CHUNK_SIZE;
}
static bool gx_audio_use_float(void *data)
{
/* TODO/FIXME - verify */
(void)data;
return false;
}
audio_driver_t audio_gx = { audio_driver_t audio_gx = {
gx_audio_init, gx_audio_init,

View File

@ -252,13 +252,13 @@ error:
return NULL; 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; jack_t *jd = (jack_t*)data;
const char *buf = (const char *)buf_; const char *buf = (const char *)buf_;
size_t written = 0; size_t written = 0;
while (size > 0) while (len > 0)
{ {
size_t avail, to_write; 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); 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 */ /* make sure to only write multiples of the sample size */
to_write = (to_write / sizeof(float)) * sizeof(float); 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); jack_ringbuffer_write(jd->buffer, buf, to_write);
buf += to_write; buf += to_write;
size -= to_write; len -= to_write;
written += to_write; written += to_write;
} }
else if (!jd->nonblock) else if (!jd->nonblock)
@ -350,11 +350,7 @@ static void ja_free(void *data)
free(jd); free(jd);
} }
static bool ja_use_float(void *data) static bool ja_use_float(void *data) { return true; }
{
(void)data;
return true;
}
static size_t ja_write_avail(void *data) static size_t ja_write_avail(void *data)
{ {

View File

@ -103,15 +103,15 @@ error:
return NULL; 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; ssize_t ret;
oss_audio_t *ossaudio = (oss_audio_t*)data; oss_audio_t *ossaudio = (oss_audio_t*)data;
if (size == 0) if (len == 0)
return 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)) if (errno == EAGAIN && (fcntl(ossaudio->fd, F_GETFL) & O_NONBLOCK))
return 0; return 0;
@ -169,7 +169,7 @@ static void oss_free(void *data)
{ {
oss_audio_t *ossaudio = (oss_audio_t*)data; oss_audio_t *ossaudio = (oss_audio_t*)data;
/*RETROFW IOCTL always returns EINVAL*/ /*RETROFW IOCTL always returns EINVAL*/
#if !defined(RETROFW) #if !defined(RETROFW)
if (ioctl(ossaudio->fd, SNDCTL_DSP_RESET, 0) < 0) if (ioctl(ossaudio->fd, SNDCTL_DSP_RESET, 0) < 0)
return; return;
@ -209,7 +209,6 @@ static size_t oss_buffer_size(void *data)
static bool oss_use_float(void *data) static bool oss_use_float(void *data)
{ {
(void)data;
return false; return false;
} }

View File

@ -278,7 +278,7 @@ error:
return NULL; 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; int32_t filled, avail;
uint32_t idx; 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) if (pw_stream_get_state(audio->stream, &error) != PW_STREAM_STATE_STREAMING)
return 0; /* wait for stream to become ready */ 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"); RARCH_ERR("[PipeWire]: Buffer too small! Please try increasing the latency.\n");
return 0; 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); pw_thread_loop_lock(audio->pw->thread_loop);
while (size) while (len)
{ {
filled = spa_ringbuffer_get_write_index(&audio->ring, &idx); filled = spa_ringbuffer_get_write_index(&audio->ring, &idx);
avail = audio->highwater_mark - filled; avail = audio->highwater_mark - filled;
#if 0 /* Useful for tracing */ #if 0 /* Useful for tracing */
RARCH_DBG("[PipeWire]: Ringbuffer utilization: filled %d, avail %d, index %d, size %d\n", RARCH_DBG("[PipeWire]: Ringbuffer utilization: filled %d, avail %d, index %d, size %d\n",
filled, avail, idx, size); filled, avail, idx, len);
#endif #endif
/* in non-blocking mode we play as much as we can /* 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 */ * 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) if (audio->pw->nonblock)
{ {
size = avail; len = avail;
break; 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); RARCH_ERR("[Pipewire]: %p: underrun write:%u filled:%d\n", audio, idx, filled);
else 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", 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, spa_ringbuffer_write_data(&audio->ring,
audio->buffer, RINGBUFFER_SIZE, audio->buffer, RINGBUFFER_SIZE,
idx & RINGBUFFER_MASK, buf_, size); idx & RINGBUFFER_MASK, buf_, len);
idx += size; idx += len;
spa_ringbuffer_write_update(&audio->ring, idx); spa_ringbuffer_write_update(&audio->ring, idx);
pw_thread_loop_unlock(audio->pw->thread_loop); pw_thread_loop_unlock(audio->pw->thread_loop);
return size; return len;
} }
static bool pipewire_stop(void *data) static bool pipewire_stop(void *data)
@ -426,11 +426,7 @@ static void pipewire_free(void *data)
pw_deinit(); pw_deinit();
} }
static bool pipewire_use_float(void *data) static bool pipewire_use_float(void *data) { return true; }
{
(void)data;
return true;
}
static void *pipewire_device_list_new(void *data) static void *pipewire_device_list_new(void *data)
{ {

View File

@ -71,14 +71,12 @@ static void ps2_audio_free(void *data)
free(ps2); 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; ps2_audio_t* ps2 = (ps2_audio_t*)data;
if (!ps2->running) if (!ps2->running)
return -1; return -1;
return audsrv_play_audio(buf, len);
return audsrv_play_audio(buf, size);
} }
static bool ps2_audio_alive(void *data) static bool ps2_audio_alive(void *data)

View File

@ -142,24 +142,24 @@ static void *ps3_audio_init(const char *device,
return data; 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; ps3_audio_t *aud = data;
if (aud->nonblock) if (aud->nonblock)
{ {
if (FIFO_WRITE_AVAIL(aud->buffer) < size) if (FIFO_WRITE_AVAIL(aud->buffer) < len)
return 0; return 0;
} }
while (FIFO_WRITE_AVAIL(aud->buffer) < size) while (FIFO_WRITE_AVAIL(aud->buffer) < len)
sysLwCondWait(&aud->cond, 0); sysLwCondWait(&aud->cond, 0);
sysLwMutexLock(&aud->lock, PS3_SYS_NO_TIMEOUT); sysLwMutexLock(&aud->lock, PS3_SYS_NO_TIMEOUT);
fifo_write(aud->buffer, buf, size); fifo_write(aud->buffer, buf, len);
sysLwMutexUnlock(&aud->lock); sysLwMutexUnlock(&aud->lock);
return size; return len;
} }
static bool ps3_audio_stop(void *data) static bool ps3_audio_stop(void *data)
@ -220,10 +220,7 @@ static void ps3_audio_free(void *data)
free(data); free(data);
} }
static bool ps3_audio_use_float(void *data) static bool ps3_audio_use_float(void *data) { return true; }
{
return true;
}
static size_t ps3_audio_write_avail(void *data) static size_t ps3_audio_write_avail(void *data)
{ {

View File

@ -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; psp_audio_t* psp = (psp_audio_t*)data;
uint16_t write_pos = psp->write_pos; uint16_t write_pos = psp->write_pos;
uint16_t sampleCount = size / sizeof(uint32_t); uint16_t sampleCount = len / sizeof(uint32_t);
if (!psp->running) if (!psp->running)
return -1; return -1;
@ -214,13 +214,13 @@ static ssize_t psp_audio_write(void *data, const void *buf, size_t size)
if (psp->nonblock) if (psp->nonblock)
{ {
if (AUDIO_BUFFER_SIZE - ((uint16_t) 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; return 0;
} }
slock_lock(psp->cond_lock); slock_lock(psp->cond_lock);
while (AUDIO_BUFFER_SIZE - ((uint16_t) 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); scond_wait(psp->cond, psp->cond_lock);
slock_unlock(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)); (write_pos + sampleCount - AUDIO_BUFFER_SIZE) * sizeof(uint32_t));
} }
else else
memcpy(psp->buffer + write_pos, buf, size); memcpy(psp->buffer + write_pos, buf, len);
write_pos += sampleCount; write_pos += sampleCount;
write_pos &= AUDIO_BUFFER_SIZE_MASK; write_pos &= AUDIO_BUFFER_SIZE_MASK;
psp->write_pos = write_pos; psp->write_pos = write_pos;
slock_unlock(psp->fifo_lock); slock_unlock(psp->fifo_lock);
return size; return len;
} }
static bool psp_audio_alive(void *data) static bool psp_audio_alive(void *data)

View File

@ -56,19 +56,19 @@ static void *ra_init(const char *device, unsigned rate, unsigned latency,
return roar; 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; int err;
size_t written = 0; size_t written = 0;
roar_t *roar = (roar_t*)data; roar_t *roar = (roar_t*)data;
if (size == 0) if (len == 0)
return 0; return 0;
while (written < size) while (written < len)
{ {
ssize_t rc; ssize_t rc;
size_t write_amt = size - written; size_t write_amt = len - written;
if ((rc = roar_vs_write(roar->vss, if ((rc = roar_vs_write(roar->vss,
(const char*)buf + written, write_amt, &err)) < (ssize_t)write_amt) (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; written += rc;
} }
return size; return len;
} }
static bool ra_stop(void *data) static bool ra_stop(void *data)

View File

@ -101,7 +101,7 @@ error:
return NULL; 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; 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); rsd_callback_lock(rsd->rd);
avail = FIFO_WRITE_AVAIL(rsd->buffer); 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); fifo_write(rsd->buffer, buf, write_amt);
rsd_callback_unlock(rsd->rd); rsd_callback_unlock(rsd->rd);
@ -124,7 +124,7 @@ static ssize_t rs_write(void *data, const void *buf, size_t size)
else else
{ {
size_t written = 0; size_t written = 0;
while (written < size && !rsd->has_error) while (written < len && !rsd->has_error)
{ {
size_t avail; size_t avail;
rsd_callback_lock(rsd->rd); rsd_callback_lock(rsd->rd);
@ -143,7 +143,7 @@ static ssize_t rs_write(void *data, const void *buf, size_t size)
} }
else 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); fifo_write(rsd->buffer, (const char*)buf + written, write_amt);
rsd_callback_unlock(rsd->rd); rsd_callback_unlock(rsd->rd);
written += write_amt; written += write_amt;

View File

@ -82,30 +82,25 @@ static void sdl_audio_playback_cb(void *data, Uint8 *stream, int len)
{ {
sdl_audio_t *sdl = (sdl_audio_t*)data; sdl_audio_t *sdl = (sdl_audio_t*)data;
size_t avail = FIFO_READ_AVAIL(sdl->speaker_buffer); size_t avail = FIFO_READ_AVAIL(sdl->speaker_buffer);
size_t write_size = (len > (int)avail) ? avail : (size_t)len; size_t _len = (len > (int)avail) ? avail : (size_t)len;
fifo_read(sdl->speaker_buffer, stream, _len);
fifo_read(sdl->speaker_buffer, stream, write_size);
#ifdef HAVE_THREADS #ifdef HAVE_THREADS
scond_signal(sdl->cond); scond_signal(sdl->cond);
#endif #endif
/* If underrun, fill rest with silence. */ /* 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) static INLINE int sdl_audio_find_num_frames(int rate, int latency)
{ {
int frames = (rate * latency) / 1000; int frames = (rate * latency) / 1000;
/* SDL only likes 2^n sized buffers. */ /* SDL only likes 2^n sized buffers. */
return next_pow2(frames); return next_pow2(frames);
} }
static void *sdl_audio_init(const char *device, static void *sdl_audio_init(const char *device,
unsigned rate, unsigned latency, unsigned rate, unsigned latency,
unsigned block_frames, unsigned block_frames, unsigned *new_rate)
unsigned *new_rate)
{ {
int frames; int frames;
size_t bufsize; size_t bufsize;
@ -215,52 +210,52 @@ error:
return NULL; 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; ssize_t ret = 0;
sdl_audio_t *sdl = (sdl_audio_t*)data; 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 (sdl->nonblock)
{ /* If we shouldn't wait for space in a full outgoing sample queue... */ {
size_t avail, write_amt; size_t avail, write_amt;
SDL_LockAudioDevice(sdl->speaker_device); /* Stop the SDL speaker thread from running */ SDL_LockAudioDevice(sdl->speaker_device); /* Stop the SDL speaker thread from running */
avail = FIFO_WRITE_AVAIL(sdl->speaker_buffer); avail = FIFO_WRITE_AVAIL(sdl->speaker_buffer);
write_amt = avail > size ? size : avail; /* Enqueue as much data as we can */ write_amt = (avail > len) ? len : avail; /* Enqueue as much data as we can */
fifo_write(sdl->speaker_buffer, buf, write_amt); fifo_write(sdl->speaker_buffer, buf, write_amt);
SDL_UnlockAudioDevice(sdl->speaker_device); /* Let the speaker thread run again */ 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 else
{ {
size_t written = 0; size_t written = 0;
/* Until we've written all the sample data we have available... */
while (written < size) while (written < len)
{ /* Until we've written all the sample data we have available... */ {
size_t avail; 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); avail = FIFO_WRITE_AVAIL(sdl->speaker_buffer);
/* If the outgoing sample queue is full... */
if (avail == 0) if (avail == 0)
{ /* If the outgoing sample queue is full... */ {
SDL_UnlockAudioDevice(sdl->speaker_device); SDL_UnlockAudioDevice(sdl->speaker_device);
/* Let the SDL speaker thread run so it can play the enqueued samples, /* Let the SDL speaker thread run so it can play the enqueued samples,
* which will free up space for us to write new ones. */ * which will free up space for us to write new ones. */
#ifdef HAVE_THREADS #ifdef HAVE_THREADS
slock_lock(sdl->lock); slock_lock(sdl->lock);
/* Let *only* the SDL speaker thread touch the outgoing sample queue */ /* Let *only* the SDL speaker thread touch the outgoing sample queue */
scond_wait(sdl->cond, sdl->lock); scond_wait(sdl->cond, sdl->lock);
/* Block until SDL tells us that it's made room for new samples */ /* Block until SDL tells us that it's made room for new samples */
slock_unlock(sdl->lock); slock_unlock(sdl->lock);
/* Now let this thread use the outgoing sample queue (which we'll do next iteration) */ /* Now let this thread use the outgoing sample queue (which we'll do next iteration) */
#endif #endif
} }
else 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); fifo_write(sdl->speaker_buffer, (const char*)buf + written, write_amt);
/* Enqueue as many samples as we have available without overflowing the queue */ /* Enqueue as many samples as we have available without overflowing the queue */
SDL_UnlockAudioDevice(sdl->speaker_device); /* Let the SDL speaker thread run again */ 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) static bool sdl_audio_stop(void *data)
{ {
sdl_audio_t *sdl = (sdl_audio_t*)data; sdl_audio_t *sdl = (sdl_audio_t*)data;
sdl->is_paused = true; sdl->is_paused = true;
SDL_PauseAudioDevice(sdl->speaker_device, true); SDL_PauseAudioDevice(sdl->speaker_device, true);
return true; return true;
} }
@ -293,10 +287,8 @@ static bool sdl_audio_alive(void *data)
static bool sdl_audio_start(void *data, bool is_shutdown) static bool sdl_audio_start(void *data, bool is_shutdown)
{ {
sdl_audio_t *sdl = (sdl_audio_t*)data; sdl_audio_t *sdl = (sdl_audio_t*)data;
sdl->is_paused = false; sdl->is_paused = false;
SDL_PauseAudioDevice(sdl->speaker_device, false); SDL_PauseAudioDevice(sdl->speaker_device, false);
return true; return true;
} }
@ -319,9 +311,7 @@ static void sdl_audio_free(void *data)
} }
if (sdl->speaker_buffer) if (sdl->speaker_buffer)
{
fifo_free(sdl->speaker_buffer); fifo_free(sdl->speaker_buffer);
}
#ifdef HAVE_THREADS #ifdef HAVE_THREADS
slock_free(sdl->lock); slock_free(sdl->lock);
@ -333,18 +323,9 @@ static void sdl_audio_free(void *data)
free(sdl); free(sdl);
} }
static bool sdl_audio_use_float(void *data) /* TODO/FIXME - implement */
{ static bool sdl_audio_use_float(void *data) { return false; }
(void)data; static size_t sdl_audio_write_avail(void *data) { return 0; }
return false;
}
static size_t sdl_audio_write_avail(void *data)
{
/* stub */
(void)data;
return 0;
}
audio_driver_t audio_sdl = { audio_driver_t audio_sdl = {
sdl_audio_init, sdl_audio_init,

View File

@ -73,9 +73,9 @@ static size_t switch_audio_buffer_size(void *data)
#endif #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; switch_audio_t *swa = (switch_audio_t*) data;
if (!swa) if (!swa)

View File

@ -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( 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; void *dstbuf = NULL;
ssize_t free_idx = -1; ssize_t free_idx = -1;
@ -202,14 +202,14 @@ static size_t libnx_audren_audio_append(
aud->current_size = 0; aud->current_size = 0;
} }
if (size > aud->buffer_size - aud->current_size) if (len > aud->buffer_size - aud->current_size)
size = aud->buffer_size - aud->current_size; len = aud->buffer_size - aud->current_size;
dstbuf = aud->current_pool_ptr + aud->current_size; dstbuf = aud->current_pool_ptr + aud->current_size;
memcpy(dstbuf, buf, size); memcpy(dstbuf, buf, len);
armDCacheFlush(dstbuf, size); armDCacheFlush(dstbuf, len);
aud->current_size += size; aud->current_size += len;
if (aud->current_size == aud->buffer_size) if (aud->current_size == aud->buffer_size)
{ {
@ -227,7 +227,7 @@ static size_t libnx_audren_audio_append(
aud->current_wavebuf = NULL; aud->current_wavebuf = NULL;
} }
return size; return len;
} }
static ssize_t libnx_audren_audio_write(void *data, static ssize_t libnx_audren_audio_write(void *data,

View File

@ -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->buffer_size = (real_latency * sample_rate / 1000);
aud->samples = (aud->buffer_size / num_channels / sizeof(int16_t)); 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); (AUDREN_MEMPOOL_ALIGNMENT-1)) &~ (AUDREN_MEMPOOL_ALIGNMENT-1);
aud->mempool = memalign(AUDREN_MEMPOOL_ALIGNMENT, mempool_size); 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, 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; libnx_audren_thread_t *aud = (libnx_audren_thread_t*)data;
size_t available, written, written_tmp; size_t available, written, written_tmp;
@ -297,7 +297,7 @@ static ssize_t libnx_audren_thread_audio_write(void *data,
{ {
mutexLock(&aud->fifo_lock); mutexLock(&aud->fifo_lock);
available = FIFO_WRITE_AVAIL(aud->fifo); available = FIFO_WRITE_AVAIL(aud->fifo);
written = MIN(available, size); written = MIN(available, len);
if (written > 0) if (written > 0)
fifo_write(aud->fifo, buf, written); fifo_write(aud->fifo, buf, written);
mutexUnlock(&aud->fifo_lock); mutexUnlock(&aud->fifo_lock);
@ -305,13 +305,13 @@ static ssize_t libnx_audren_thread_audio_write(void *data,
else else
{ {
written = 0; written = 0;
while (written < size && aud->running) while (written < len && aud->running)
{ {
mutexLock(&aud->fifo_lock); mutexLock(&aud->fifo_lock);
available = FIFO_WRITE_AVAIL(aud->fifo); available = FIFO_WRITE_AVAIL(aud->fifo);
if (available) if (available)
{ {
written_tmp = MIN(size - written, available); written_tmp = MIN(len - written, available);
fifo_write(aud->fifo, (const char*)buf + written, written_tmp); fifo_write(aud->fifo, (const char*)buf + written, written_tmp);
mutexUnlock(&aud->fifo_lock); mutexUnlock(&aud->fifo_lock);
written += written_tmp; written += written_tmp;

View File

@ -338,7 +338,7 @@ static void switch_thread_audio_free(void *data)
swa = NULL; 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; size_t avail, written;
switch_thread_audio_t *swa = (switch_thread_audio_t *)data; 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); compat_mutex_lock(&swa->fifoLock);
avail = FIFO_WRITE_AVAIL(swa->fifo); avail = FIFO_WRITE_AVAIL(swa->fifo);
written = MIN(avail, size); written = MIN(avail, len);
if (written > 0) if (written > 0)
fifo_write(swa->fifo, buf, written); fifo_write(swa->fifo, buf, written);
compat_mutex_unlock(&swa->fifoLock); 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 else
{ {
written = 0; written = 0;
while (written < size && swa->running) while (written < len && swa->running)
{ {
compat_mutex_lock(&swa->fifoLock); compat_mutex_lock(&swa->fifoLock);
avail = FIFO_WRITE_AVAIL(swa->fifo); 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 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); fifo_write(swa->fifo, (const char*)buf + written, write_amt);
compat_mutex_unlock(&swa->fifoLock); compat_mutex_unlock(&swa->fifoLock);
written += write_amt; written += write_amt;

View File

@ -2275,12 +2275,12 @@ error:
} }
static ssize_t 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; tinyalsa_t *tinyalsa = (tinyalsa_t*)data;
const uint8_t *buf = (const uint8_t*)buf_; const uint8_t *buf = (const uint8_t*)buf_;
snd_pcm_sframes_t written = 0; 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); size_t frames_size = tinyalsa->has_float ? sizeof(float) : sizeof(int16_t);
if (tinyalsa->nonblock) if (tinyalsa->nonblock)

View File

@ -163,7 +163,7 @@ error:
return NULL; 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; size_t written = 0;
wasapi_t *w = (wasapi_t*)wh; 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; return -1;
write_avail = w->engine_buffer_size; 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); fifo_write(w->buffer, data, written);
} }
else else
{ {
ssize_t ir; ssize_t ir;
for (ir = -1; written < size; written += ir) for (ir = -1; written < len; written += ir)
{ {
const void *_data = (char*)data + written; 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); size_t write_avail = FIFO_WRITE_AVAIL(w->buffer);
if (!write_avail) 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; 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); 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); write_avail = FIFO_WRITE_AVAIL(w->buffer);
written = size < write_avail ? size : write_avail; written = len < write_avail ? len : write_avail;
if (written) if (written)
fifo_write(w->buffer, data, 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; return -1;
if (!(write_avail = w->engine_buffer_size - padding * w->frame_size)) if (!(write_avail = w->engine_buffer_size - padding * w->frame_size))
return 0; return 0;
written = size < write_avail ? size : write_avail; written = (len < write_avail) ? len : write_avail;
if (written) if (written)
{ {
BYTE *dest = NULL; BYTE *dest = NULL;
@ -285,10 +285,10 @@ static ssize_t wasapi_write(void *wh, const void *data, size_t size)
else if (w->buffer) else if (w->buffer)
{ {
ssize_t ir; ssize_t ir;
for (ir = -1; written < size; written += ir) for (ir = -1; written < len; written += ir)
{ {
const void *_data = (char*)data + written; 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); size_t write_avail = FIFO_WRITE_AVAIL(w->buffer);
UINT32 padding = 0; UINT32 padding = 0;
if (!write_avail) 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); write_avail = FIFO_WRITE_AVAIL(w->buffer);
ir = (_size < write_avail) ? _size : write_avail; ir = (_len < write_avail) ? _len : write_avail;
if (ir) if (ir)
fifo_write(w->buffer, _data, 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 else
{ {
ssize_t ir; ssize_t ir;
for (ir = -1; written < size; written += ir) for (ir = -1; written < len; written += ir)
{ {
const void *_data = (char*)data + written; const void *_data = (char*)data + written;
size_t _size = size - written; size_t _len = len - written;
size_t write_avail = 0; size_t write_avail = 0;
UINT32 padding = 0; UINT32 padding = 0;
if (!(WaitForSingleObject(w->write_event, WASAPI_TIMEOUT) == WAIT_OBJECT_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; ir = 0;
else else
{ {
ir = (_size < write_avail) ? _size : write_avail; ir = (_len < write_avail) ? _len : write_avail;
if (ir) if (ir)
{ {
BYTE *dest = NULL; BYTE *dest = NULL;
@ -427,8 +427,7 @@ static void wasapi_free(void *wh)
static bool wasapi_use_float(void *wh) static bool wasapi_use_float(void *wh)
{ {
wasapi_t *w = (wasapi_t*)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) static void wasapi_device_list_free(void *u, void *slp)

View File

@ -194,23 +194,23 @@ static bool ax_audio_start(void* data, bool is_shutdown)
return true; 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; uint32_t i;
size_t count_avail = 0; size_t count_avail = 0;
ax_audio_t* ax = (ax_audio_t*)data; ax_audio_t* ax = (ax_audio_t*)data;
const uint16_t* src = buf; 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; return 0;
if (count > AX_AUDIO_MAX_FREE) if (count > AX_AUDIO_MAX_FREE)
count = AX_AUDIO_MAX_FREE; count = AX_AUDIO_MAX_FREE;
count_avail = ( count_avail = (
(ax->written > AX_AUDIO_MAX_FREE) (ax->written > AX_AUDIO_MAX_FREE)
? 0 ? 0
: (AX_AUDIO_MAX_FREE - ax->written)); : (AX_AUDIO_MAX_FREE - ax->written));
if (ax->nonblock) if (ax->nonblock)

View File

@ -341,9 +341,9 @@ static void *xa_init(const char *device, unsigned rate, unsigned latency,
return xa; 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; xa_t *xa = (xa_t*)data;
xaudio2_t *handle = xa->xa; xaudio2_t *handle = xa->xa;
const uint8_t *buffer = (const uint8_t*)buf; 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) if (avail == 0)
return 0; return 0;
if (avail < size) if (avail < len)
bytes = size = avail; bytes = len = avail;
} }
while (bytes) while (bytes)
@ -391,7 +391,7 @@ static ssize_t xa_write(void *data, const void *buf, size_t size)
if (FAILED(IXAudio2SourceVoice_SubmitSourceBuffer( if (FAILED(IXAudio2SourceVoice_SubmitSourceBuffer(
handle->pSourceVoice, &xa2buffer, NULL))) handle->pSourceVoice, &xa2buffer, NULL)))
{ {
if (size > 0) if (len > 0)
return -1; return -1;
return 0; 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) static bool xa_stop(void *data)

View File

@ -57,21 +57,21 @@ static INLINE uint32_t bswap_32(uint32_t val)
((val >> 8) & 0xff00) | ((val << 8) & 0xff0000); ((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; size_t written = 0, i;
const uint32_t *in_buf = buf; const uint32_t *in_buf = buf;
xenon_audio_t *xa = data; 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]); xa->buffer[i] = bswap_32(in_buf[i]);
if (xa->nonblock) if (xa->nonblock)
{ {
if (xenon_sound_get_unplayed() < MAX_BUFFER) if (xenon_sound_get_unplayed() < MAX_BUFFER)
{ {
xenon_sound_submit(xa->buffer, size); xenon_sound_submit(xa->buffer, len);
written = size; written = len;
} }
} }
else else
@ -83,8 +83,8 @@ static ssize_t xenon360_audio_write(void *data, const void *buf, size_t size)
udelay(50); udelay(50);
} }
xenon_sound_submit(xa->buffer, size); xenon_sound_submit(xa->buffer, len);
written = size; written = len;
} }
return written; return written;

View File

@ -51,7 +51,7 @@ static void *alsa_microphone_init(void)
return alsa; 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) static void alsa_microphone_free(void *driver_context)
{ {
alsa_microphone_t *alsa = (alsa_microphone_t*)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 bool alsa_microphone_start_mic(void *driver_context, void *mic_context);
static int alsa_microphone_read(void *driver_context, void *microphone_context, void *buf_, size_t size_)
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; size_t frames_size;
alsa_microphone_handle_t *microphone = (alsa_microphone_handle_t*)microphone_context; snd_pcm_sframes_t size;
uint8_t *buf = (uint8_t*)buf_; 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; snd_pcm_sframes_t read = 0;
int errnum = 0; int errnum = 0;
snd_pcm_sframes_t size;
size_t frames_size;
snd_pcm_state_t state;
if (!alsa || !microphone || !buf) if (!alsa || !mic || !buf)
return -1; return -1;
size = BYTES_TO_FRAMES(size_, microphone->stream_info.frame_bits); size = BYTES_TO_FRAMES(len, mic->stream_info.frame_bits);
frames_size = microphone->stream_info.has_float ? sizeof(float) : sizeof(int16_t); 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) if (state != SND_PCM_STATE_RUNNING)
{ {
RARCH_WARN("[ALSA]: Expected microphone \"%s\" to be in state RUNNING, was in state %s\n", 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)); snd_pcm_state_name(state));
errnum = snd_pcm_start(microphone->pcm); errnum = snd_pcm_start(mic->pcm);
if (errnum < 0) if (errnum < 0)
{ {
RARCH_ERR("[ALSA]: Failed to start microphone \"%s\": %s\n", RARCH_ERR("[ALSA]: Failed to start microphone \"%s\": %s\n",
snd_pcm_name(microphone->pcm), snd_pcm_name(mic->pcm),
snd_strerror(errnum)); snd_strerror(errnum));
return -1; return -1;
@ -104,11 +105,11 @@ static int alsa_microphone_read(void *driver_context, void *microphone_context,
{ {
while (size) 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) 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) if (errnum < 0)
{ {
RARCH_ERR("[ALSA]: Failed to read from microphone: %s\n", snd_strerror(frames)); 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) while (size)
{ {
snd_pcm_sframes_t frames; 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 (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; return -1;
continue; 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 (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; return -1;
break; 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; (void)driver_context;
if (!microphone) if (!mic)
return false; 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) 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) static struct string_list *alsa_microphone_device_list_new(const void *data)
{ {
(void)data;
return alsa_device_list_type_new("Input"); return alsa_device_list_type_new("Input");
} }
@ -211,72 +211,63 @@ static void *alsa_microphone_open_mic(void *driver_context,
unsigned latency, unsigned latency,
unsigned *new_rate) unsigned *new_rate)
{ {
alsa_microphone_t *alsa = (alsa_microphone_t*)driver_context; alsa_microphone_t *alsa = (alsa_microphone_t*)driver_context;
alsa_microphone_handle_t *microphone = NULL; alsa_microphone_handle_t *mic = NULL;
if (!alsa) /* If we weren't given a valid ALSA context... */ if (!alsa) /* If we weren't given a valid ALSA context... */
return NULL; 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; return NULL;
/* channels hardcoded to 1, because we only support mono mic input */ /* channels hardcoded to 1, because we only support mono mic input */
if (alsa_init_pcm(&microphone->pcm, device, SND_PCM_STREAM_CAPTURE, rate, latency, 1, &microphone->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; goto error;
}
return microphone; return mic;
error: error:
RARCH_ERR("[ALSA]: Failed to initialize microphone...\n"); RARCH_ERR("[ALSA]: Failed to initialize microphone...\n");
alsa_microphone_close_mic(alsa, microphone); alsa_microphone_close_mic(alsa, mic);
return NULL; 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; (void)driver_context;
if (microphone) if (mic)
{ {
alsa_free_pcm(microphone->pcm); alsa_free_pcm(mic->pcm);
free(microphone); 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; alsa_microphone_handle_t *mic = (alsa_microphone_handle_t*)mic_context;
(void)driver_context; if (!mic)
if (!microphone)
return false; return false;
return alsa_start_pcm(mic->pcm);
return alsa_start_pcm(microphone->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; alsa_microphone_handle_t *mic = (alsa_microphone_handle_t*)mic_context;
(void)driver_context; if (!mic)
if (!microphone)
return false; return false;
return alsa_stop_pcm(mic->pcm);
return alsa_stop_pcm(microphone->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; alsa_microphone_handle_t *mic = (alsa_microphone_handle_t*)mic_context;
(void)driver_context;
return microphone->stream_info.has_float; return microphone->stream_info.has_float;
} }

View File

@ -49,27 +49,27 @@ static void *alsa_thread_microphone_init(void)
return alsa; 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) static void alsa_thread_microphone_free(void *driver_context)
{ {
alsa_thread_microphone_t *alsa = (alsa_thread_microphone_t*)driver_context; alsa_thread_microphone_t *alsa = (alsa_thread_microphone_t*)driver_context;
if (alsa) if (alsa)
{
free(alsa); free(alsa);
}
} }
/** @see alsa_thread_read_microphone() */ /** @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; alsa_thread_microphone_handle_t *mic = (alsa_thread_microphone_handle_t*)mic_context;
uint8_t *buf = NULL; uint8_t *buf = NULL;
uintptr_t thread_id = sthread_get_current_thread_id(); uintptr_t thread_id = sthread_get_current_thread_id();
retro_assert(microphone != NULL); retro_assert(mic != NULL);
buf = (uint8_t *)calloc(1, microphone->info.stream_info.period_size);
if (!buf) 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); RARCH_ERR("[ALSA] [capture thread %p]: Failed to allocate audio buffer\n", thread_id);
goto end; 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]: Beginning microphone worker thread\n", thread_id);
RARCH_DBG("[ALSA] [capture thread %p]: Microphone \"%s\" is in state %s\n", RARCH_DBG("[ALSA] [capture thread %p]: Microphone \"%s\" is in state %s\n",
thread_id, thread_id,
snd_pcm_name(microphone->info.pcm), snd_pcm_name(mic->info.pcm),
snd_pcm_state_name(snd_pcm_state(microphone->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 avail;
size_t fifo_size; size_t fifo_size;
snd_pcm_sframes_t frames; snd_pcm_sframes_t frames;
int errnum = 0; int errnum = 0;
/* Lock the incoming sample queue (the main thread may block) */ /* 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 */ /* Fill the incoming sample queue with whatever we recently read */
avail = FIFO_WRITE_AVAIL(microphone->info.buffer); avail = FIFO_WRITE_AVAIL(mic->info.buffer);
fifo_size = MIN(microphone->info.stream_info.period_size, avail); fifo_size = MIN(mic->info.stream_info.period_size, avail);
fifo_write(microphone->info.buffer, buf, fifo_size); fifo_write(mic->info.buffer, buf, fifo_size);
/* Tell the main thread that it's okay to query the mic again */ /* 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) */ /* 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. */ /* 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) if (errnum == 0)
{ {
@ -118,7 +119,7 @@ static void alsa_microphone_worker_thread(void *microphone_context)
thread_id, thread_id,
snd_strerror(errnum)); 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", RARCH_ERR("[ALSA] [capture thread %p]: Failed to recover from prior wait error: %s\n",
thread_id, thread_id,
@ -130,7 +131,7 @@ static void alsa_microphone_worker_thread(void *microphone_context)
continue; 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) if (frames == -EPIPE || frames == -EINTR || frames == -ESTRPIPE)
{ {
@ -138,7 +139,7 @@ static void alsa_microphone_worker_thread(void *microphone_context)
thread_id, thread_id,
snd_strerror(frames)); 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", RARCH_ERR("[ALSA] [capture thread %p]: Failed to recover from prior read error: %s\n",
thread_id, thread_id,
@ -158,103 +159,104 @@ static void alsa_microphone_worker_thread(void *microphone_context)
} }
end: end:
slock_lock(microphone->info.cond_lock); slock_lock(mic->info.cond_lock);
microphone->info.thread_dead = true; mic->info.thread_dead = true;
scond_signal(microphone->info.cond); scond_signal(mic->info.cond);
slock_unlock(microphone->info.cond_lock); slock_unlock(mic->info.cond_lock);
free(buf); free(buf);
RARCH_DBG("[ALSA] [capture thread %p]: Ending microphone worker thread\n", thread_id); 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_t *alsa = (alsa_thread_microphone_t*)driver_context;
alsa_thread_microphone_handle_t *microphone = (alsa_thread_microphone_handle_t*)microphone_context; alsa_thread_microphone_handle_t *mic = (alsa_thread_microphone_handle_t*)mic_context;
snd_pcm_state_t state; 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; 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; return -1;
state = snd_pcm_state(microphone->info.pcm); state = snd_pcm_state(mic->info.pcm);
if (state != SND_PCM_STATE_RUNNING) if (state != SND_PCM_STATE_RUNNING)
{ {
int errnum; int errnum;
RARCH_WARN("[ALSA]: Expected microphone \"%s\" to be in state RUNNING, was in state %s\n", RARCH_WARN("[ALSA]: Expected microphone \"%s\" to be in state RUNNING, was in state %s\n",
snd_pcm_name(microphone->info.pcm), snd_pcm_name(mic->info.pcm), snd_pcm_state_name(state));
snd_pcm_state_name(state));
errnum = snd_pcm_start(microphone->info.pcm); errnum = snd_pcm_start(mic->info.pcm);
if (errnum < 0) if (errnum < 0)
{ {
RARCH_ERR("[ALSA]: Failed to start microphone \"%s\": %s\n", RARCH_ERR("[ALSA]: Failed to start microphone \"%s\": %s\n",
snd_pcm_name(microphone->info.pcm), snd_pcm_name(mic->info.pcm), snd_strerror(errnum));
snd_strerror(errnum));
return -1; return -1;
} }
} }
/* If driver interactions shouldn't block... */
if (alsa->nonblock) if (alsa->nonblock)
{ /* If driver interactions shouldn't block... */ {
size_t avail; size_t avail;
size_t write_amt; size_t write_amt;
/* "Hey, I'm gonna borrow the queue." */ /* "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);
write_amt = MIN(avail, size); write_amt = MIN(avail, len);
/* "It's okay if you don't have any new samples, I'll just check in on you later." */ /* "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." */ /* "Here, take this queue back." */
slock_unlock(microphone->info.fifo_lock); slock_unlock(mic->info.fifo_lock);
return (int)write_amt; return (int)write_amt;
} }
else else
{ {
size_t read = 0; 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; size_t avail;
/* "Hey, I'm gonna borrow the queue." */ /* "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) if (avail == 0)
{ /* "Oh, wait, it's empty." */ { /* "Oh, wait, it's empty." */
/* "Here, take it back..." */ /* "Here, take it back..." */
slock_unlock(microphone->info.fifo_lock); slock_unlock(mic->info.fifo_lock);
/* "...I'll just wait right here." */ /* "...I'll just wait right here." */
slock_lock(microphone->info.cond_lock); slock_lock(mic->info.cond_lock);
/* "Unless we're closing up shop..." */ /* "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." */ /* "...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." */ /* "Oh, you're ready? Okay, I'm gonna continue." */
slock_unlock(microphone->info.cond_lock); slock_unlock(mic->info.cond_lock);
} }
else 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..." /* "I'll just go ahead and consume all these samples..."
* (As many as will fit in buf, or as many as are available.) */ * (As many as will fit in s, or as many as are available.) */
fifo_read(microphone->info.buffer,buf + read, read_amt); fifo_read(mic->info.buffer,s + read, read_amt);
/* "I'm done, you can take the queue back now." */ /* "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; 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, static void *alsa_thread_microphone_open_mic(void *driver_context,
const char *device, const char *device, unsigned rate, unsigned latency, unsigned *new_rate)
unsigned rate,
unsigned latency,
unsigned *new_rate)
{ {
alsa_thread_microphone_t *alsa = (alsa_thread_microphone_t*)driver_context; alsa_thread_microphone_t *alsa = (alsa_thread_microphone_t*)driver_context;
alsa_thread_microphone_handle_t *microphone = NULL; alsa_thread_microphone_handle_t *mic = NULL;
if (!alsa) /* If we weren't given a valid ALSA context... */ if (!alsa) /* If we weren't given a valid ALSA context... */
return NULL; return NULL;
microphone = calloc(1, sizeof(alsa_thread_microphone_handle_t)); /* If the microphone context couldn't be allocated... */
if (!(mic = calloc(1, sizeof(alsa_thread_microphone_handle_t))))
if (!microphone) {
{ /* If the microphone context couldn't be allocated... */
RARCH_ERR("[ALSA] Failed to allocate microphone context\n"); RARCH_ERR("[ALSA] Failed to allocate microphone context\n");
return NULL; return NULL;
} }
if (alsa_init_pcm(&microphone->info.pcm, device, SND_PCM_STREAM_CAPTURE, rate, latency, 1, &microphone->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)
goto error; goto error;
microphone->info.worker_thread = sthread_create(alsa_microphone_worker_thread, microphone); mic->info.fifo_lock = slock_new();
if (!microphone->info.worker_thread) 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;
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"); RARCH_ERR("[ALSA]: Failed to initialize microphone worker thread\n");
goto error; goto error;
} }
RARCH_DBG("[ALSA]: Initialized microphone worker thread\n"); RARCH_DBG("[ALSA]: Initialized microphone worker thread\n");
return microphone; return mic;
error: error:
RARCH_ERR("[ALSA]: Failed to initialize microphone...\n"); 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); snd_pcm_close(microphone->info.pcm);
}
alsa_thread_microphone_close_mic(alsa, microphone); alsa_thread_microphone_close_mic(alsa, mic);
} }
return NULL; 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; alsa_thread_microphone_handle_t *mic = (alsa_thread_microphone_handle_t*)mic_context;
(void)driver_context; if (mic)
if (microphone)
{ {
alsa_thread_free_info_members(&microphone->info); alsa_thread_free_info_members(&mic->info);
free(microphone); 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; alsa_thread_microphone_handle_t *mic = (alsa_thread_microphone_handle_t *)mic_context;
(void)driver_context; if (!mic)
if (!microphone)
return false; return false;
return snd_pcm_state(mic->info.pcm) == SND_PCM_STATE_RUNNING;
return snd_pcm_state(microphone->info.pcm) == SND_PCM_STATE_RUNNING;
} }
static void alsa_thread_microphone_set_nonblock_state(void *driver_context, bool state) 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) static struct string_list *alsa_thread_microphone_device_list_new(const void *data)
{ {
(void)data;
return alsa_device_list_type_new("Input"); return alsa_device_list_type_new("Input");
} }
static void alsa_thread_microphone_device_list_free(const void *driver_context, struct string_list *devices) static void alsa_thread_microphone_device_list_free(const void *driver_context, struct string_list *devices)
{ {
(void)driver_context;
string_list_free(devices); string_list_free(devices);
/* Does nothing if devices is NULL */ /* 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; alsa_thread_microphone_handle_t *mic = (alsa_thread_microphone_handle_t*)mic_context;
(void)driver_context; if (!mic)
if (!microphone)
return false; return false;
return alsa_start_pcm(mic->info.pcm);
return alsa_start_pcm(microphone->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; alsa_thread_microphone_handle_t *mic = (alsa_thread_microphone_handle_t*)mic_context;
(void)driver_context; if (!mic)
if (!microphone)
return false; return false;
return alsa_stop_pcm(mic->info.pcm);
return alsa_stop_pcm(microphone->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; alsa_thread_microphone_handle_t *mic = (alsa_thread_microphone_handle_t*)mic_context;
return mic->info.stream_info.has_float;
return microphone->info.stream_info.has_float;
} }
microphone_driver_t microphone_alsathread = { microphone_driver_t microphone_alsathread = {

View File

@ -27,9 +27,9 @@
#include <retro_miscellaneous.h> #include <retro_miscellaneous.h>
#include <retro_endianness.h> #include <retro_endianness.h>
#include "audio/common/pipewire.h" #include "../common/pipewire.h"
#include "audio/microphone_driver.h" #include "../microphone_driver.h"
#include "verbosity.h" #include "../../verbosity.h"
#define DEFAULT_CHANNELS 1 #define DEFAULT_CHANNELS 1
@ -51,22 +51,22 @@ typedef struct pipewire_microphone
static void stream_state_changed_cb(void *data, static void stream_state_changed_cb(void *data,
enum pw_stream_state old, enum pw_stream_state state, const char *error) 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", 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)); pw_stream_state_as_string(state));
switch(state) switch(state)
{ {
case PW_STREAM_STATE_UNCONNECTED: case PW_STREAM_STATE_UNCONNECTED:
microphone->is_ready = false; mic->is_ready = false;
pw_thread_loop_stop(microphone->pw->thread_loop); pw_thread_loop_stop(mic->pw->thread_loop);
break; break;
case PW_STREAM_STATE_STREAMING: case PW_STREAM_STATE_STREAMING:
case PW_STREAM_STATE_ERROR: case PW_STREAM_STATE_ERROR:
case PW_STREAM_STATE_PAUSED: case PW_STREAM_STATE_PAUSED:
pw_thread_loop_signal(microphone->pw->thread_loop, false); pw_thread_loop_signal(mic->pw->thread_loop, false);
break; break;
default: default:
break; break;
@ -75,24 +75,23 @@ static void stream_state_changed_cb(void *data,
static void stream_destroy_cb(void *data) static void stream_destroy_cb(void *data)
{ {
pipewire_microphone_t *microphone = (pipewire_microphone_t*)data; pipewire_microphone_t *mic = (pipewire_microphone_t*)data;
spa_hook_remove(&microphone->stream_listener); spa_hook_remove(&mic->stream_listener);
microphone->stream = NULL; mic->stream = NULL;
} }
static void capture_process_cb(void *data) static void capture_process_cb(void *data)
{ {
pipewire_microphone_t *microphone = (pipewire_microphone_t *)data;
void *p; void *p;
int32_t filled;
struct pw_buffer *b; struct pw_buffer *b;
struct spa_buffer *buf; struct spa_buffer *buf;
int32_t filled;
uint32_t idx, offs, n_bytes; 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 = pw_stream_dequeue_buffer(mic->stream)))
if (b == NULL)
{ {
RARCH_ERR("[PipeWire]: out of buffers: %s\n", strerror(errno)); RARCH_ERR("[PipeWire]: out of buffers: %s\n", strerror(errno));
return; return;
@ -102,11 +101,10 @@ static void capture_process_cb(void *data)
if ((p = buf->datas[0].data) == NULL) if ((p = buf->datas[0].data) == NULL)
goto done; 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); n_bytes = SPA_MIN(buf->datas[0].chunk->size, buf->datas[0].maxsize - offs);
filled = spa_ringbuffer_get_write_index(&microphone->ring, &idx); if ((filled = spa_ringbuffer_get_write_index(&mic->ring, &idx)) < 0)
if (filled < 0)
RARCH_ERR("[PipeWire]: %p: underrun write:%u filled:%d\n", p, idx, filled); RARCH_ERR("[PipeWire]: %p: underrun write:%u filled:%d\n", p, idx, filled);
else 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", RARCH_ERR("[PipeWire]: %p: overrun write:%u filled:%d + size:%u > max:%u\n",
p, idx, filled, n_bytes, RINGBUFFER_SIZE); p, idx, filled, n_bytes, RINGBUFFER_SIZE);
} }
spa_ringbuffer_write_data(&microphone->ring, spa_ringbuffer_write_data(&mic->ring,
microphone->buffer, RINGBUFFER_SIZE, mic->buffer, RINGBUFFER_SIZE,
idx & RINGBUFFER_MASK, idx & RINGBUFFER_MASK,
SPA_PTROFF(p, offs, void), n_bytes); SPA_PTROFF(p, offs, void), n_bytes);
idx += n_bytes; idx += n_bytes;
spa_ringbuffer_write_update(&microphone->ring, idx); spa_ringbuffer_write_update(&mic->ring, idx);
done: done:
pw_stream_queue_buffer(microphone->stream, b); pw_stream_queue_buffer(mic->stream, b);
pw_thread_loop_signal(microphone->pw->thread_loop, false); pw_thread_loop_signal(mic->pw->thread_loop, false);
} }
static const struct pw_stream_events capture_stream_events = { 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, static void registry_event_global(void *data, uint32_t id,
uint32_t permissions, const char *type, uint32_t version, uint32_t permissions, const char *type, uint32_t version,
const struct spa_dict *props) const struct spa_dict *props)
{ {
union string_list_elem_attr attr; union string_list_elem_attr attr;
const struct spa_dict_item *item; const struct spa_dict_item *item;
@ -170,14 +168,44 @@ static const struct pw_registry_events registry_events = {
.global = registry_event_global, .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) static void *pipewire_microphone_init(void)
{ {
int res; int res;
uint64_t buf_samples; uint8_t buffer[1024];
uint64_t buf_samples;
const struct spa_pod *params[1]; const struct spa_pod *params[1];
uint8_t buffer[1024];
struct pw_properties *props = NULL; struct pw_properties *props = NULL;
const char *error = NULL; const char *error = NULL;
pipewire_core_t *pw = (pipewire_core_t*)calloc(1, sizeof(*pw)); pipewire_core_t *pw = (pipewire_core_t*)calloc(1, sizeof(*pw));
@ -211,63 +239,45 @@ error:
return NULL; return NULL;
} }
static void pipewire_microphone_close_mic(void *driver_context, void *microphone_context); static void pipewire_microphone_close_mic(void *driver_context, void *mic_context)
static void pipewire_microphone_free(void *driver_context)
{ {
pipewire_core_t *pw = (pipewire_core_t*)driver_context; pipewire_core_t *pw = (pipewire_core_t*)driver_context;
pipewire_microphone_t *mic = (pipewire_microphone_t*)mic_context;
if (!pw) if (pw && mic)
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); pw_thread_loop_lock(pw->thread_loop);
spa_zero(pw->core_listener); pw_stream_destroy(mic->stream);
pw_core_disconnect(pw->core); 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;
uint32_t idx; int32_t readable;
const char *error = NULL; const char *error = NULL;
pipewire_core_t *pw = (pipewire_core_t*)driver_context; pipewire_core_t *pw = (pipewire_core_t*)driver_context;
pipewire_microphone_t *microphone = (pipewire_microphone_t*)microphone_context; pipewire_microphone_t *mic = (pipewire_microphone_t*)mic_context;
if ( !microphone->is_ready if ( !mic->is_ready
|| pw_stream_get_state(microphone->stream, &error) != PW_STREAM_STATE_STREAMING) || pw_stream_get_state(mic->stream, &error) != PW_STREAM_STATE_STREAMING)
return -1; return -1;
pw_thread_loop_lock(pw->thread_loop); pw_thread_loop_lock(pw->thread_loop);
while (size_) while (len)
{ {
/* get no of available bytes to read data from buffer */ /* get no of available bytes to read data from buffer */
readable = spa_ringbuffer_get_read_index(&microphone->ring, &idx); readable = spa_ringbuffer_get_read_index(&mic->ring, &idx);
if (readable < (int32_t)size_) if (readable < (int32_t)len)
{ {
if (pw->nonblock) if (pw->nonblock)
{ {
size_ = readable; len = readable;
break; break;
} }
@ -277,26 +287,23 @@ static int pipewire_microphone_read(void *driver_context, void *microphone_conte
break; break;
} }
spa_ringbuffer_read_data(&microphone->ring, spa_ringbuffer_read_data(&mic->ring,
microphone->buffer, RINGBUFFER_SIZE, mic->buffer, RINGBUFFER_SIZE,
idx & RINGBUFFER_MASK, buf_, size_); idx & RINGBUFFER_MASK, s, len);
idx += size_; idx += len;
spa_ringbuffer_read_update(&microphone->ring, idx); spa_ringbuffer_read_update(&mic->ring, idx);
pw_thread_loop_unlock(pw->thread_loop); 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; const char *error = NULL;
pipewire_microphone_t *microphone = (pipewire_microphone_t*)microphone_context; pipewire_microphone_t *mic = (pipewire_microphone_t*)mic_context;
(void)driver_context; if (!mic)
if (!microphone)
return false; return false;
return pw_stream_get_state(mic->stream, &error) == PW_STREAM_STATE_STREAMING;
return pw_stream_get_state(microphone->stream, &error) == PW_STREAM_STATE_STREAMING;
} }
static void pipewire_microphone_set_nonblock_state(void *driver_context, bool nonblock) 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) static void pipewire_microphone_device_list_free(const void *driver_context, struct string_list *devices)
{ {
(void)driver_context;
if (devices) if (devices)
string_list_free(devices); string_list_free(devices);
} }
static void *pipewire_microphone_open_mic(void *driver_context, static void *pipewire_microphone_open_mic(void *driver_context,
const char *device, const char *device, unsigned rate, unsigned latency,
unsigned rate,
unsigned latency,
unsigned *new_rate) unsigned *new_rate)
{ {
int res; int res;
uint64_t buf_samples; uint64_t buf_samples;
const struct spa_pod *params[1]; uint8_t buffer[1024];
uint8_t buffer[1024]; const struct spa_pod *params[1];
struct pw_properties *props = NULL; struct pw_properties *props = NULL;
const char *error = NULL; const char *error = NULL;
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer)); struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer));
pipewire_microphone_t *microphone = calloc(1, sizeof(pipewire_microphone_t)); pipewire_microphone_t *mic = calloc(1, sizeof(pipewire_microphone_t));
retro_assert(driver_context); retro_assert(driver_context);
if (!microphone) if (!mic)
goto error; goto error;
microphone->is_ready = false; mic->is_ready = false;
microphone->pw = (pipewire_core_t*)driver_context; 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; mic->info.format = is_little_endian() ? SPA_AUDIO_FORMAT_F32_LE : SPA_AUDIO_FORMAT_F32_BE;
microphone->info.channels = DEFAULT_CHANNELS; mic->info.channels = DEFAULT_CHANNELS;
pipewire_set_position(DEFAULT_CHANNELS, microphone->info.position); pipewire_set_position(DEFAULT_CHANNELS, mic->info.position);
microphone->info.rate = rate; mic->info.rate = rate;
microphone->frame_size = pipewire_calc_frame_size(microphone->info.format, DEFAULT_CHANNELS); 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, props = pw_properties_new(PW_KEY_MEDIA_TYPE, PW_RARCH_MEDIA_TYPE_AUDIO,
PW_KEY_MEDIA_CATEGORY, PW_RARCH_MEDIA_CATEGORY_RECORD, 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; 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_LATENCY, "%" PRIu64 "/%u", buf_samples, rate);
pw_properties_setf(props, PW_KEY_NODE_RATE, "1/%d", 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; goto unlock_error;
pw_stream_add_listener(microphone->stream, &microphone->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, &microphone->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 /* Now connect this stream. We ask that our process function is
* called in a realtime thread. */ * called in a realtime thread. */
res = pw_stream_connect(microphone->stream, res = pw_stream_connect(mic->stream, PW_DIRECTION_INPUT, PW_ID_ANY,
PW_DIRECTION_INPUT, PW_STREAM_FLAG_AUTOCONNECT
PW_ID_ANY, | PW_STREAM_FLAG_INACTIVE
PW_STREAM_FLAG_AUTOCONNECT | | PW_STREAM_FLAG_MAP_BUFFERS
PW_STREAM_FLAG_INACTIVE | | PW_STREAM_FLAG_RT_PROCESS,
PW_STREAM_FLAG_MAP_BUFFERS | params, 1);
PW_STREAM_FLAG_RT_PROCESS,
params, 1);
if (res < 0) if (res < 0)
goto unlock_error; goto unlock_error;
pw_thread_loop_wait(microphone->pw->thread_loop); pw_thread_loop_wait(mic->pw->thread_loop);
pw_thread_loop_unlock(microphone->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; mic->is_ready = true;
return microphone; return mic;
unlock_error: unlock_error:
pw_thread_loop_unlock(microphone->pw->thread_loop); pw_thread_loop_unlock(mic->pw->thread_loop);
error: error:
RARCH_ERR("[PipeWire]: Failed to initialize microphone...\n"); RARCH_ERR("[PipeWire]: Failed to initialize microphone...\n");
pipewire_microphone_close_mic(microphone->pw, microphone); pipewire_microphone_close_mic(mic->pw, mic);
return NULL; return NULL;
} }
static void pipewire_microphone_close_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_core_t *pw = (pipewire_core_t*)driver_context;
pipewire_microphone_t *microphone = (pipewire_microphone_t*)microphone_context; pipewire_microphone_t *mic = (pipewire_microphone_t*)mic_context;
const char *error = NULL;
if (pw && microphone) if (!pw || !mic || !mic->is_ready)
{ return false;
pw_thread_loop_lock(pw->thread_loop); if (pw_stream_get_state(mic->stream, &error) == PW_STREAM_STATE_STREAMING)
pw_stream_destroy(microphone->stream); return true;
microphone->stream = NULL; return pipewire_stream_set_active(pw->thread_loop, mic->stream, true);
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_stop_mic(void *driver_context, void *mic_context)
{ {
pipewire_core_t *pw = (pipewire_core_t*)driver_context; pipewire_core_t *pw = (pipewire_core_t*)driver_context;
pipewire_microphone_t *microphone = (pipewire_microphone_t*)microphone_context; pipewire_microphone_t *mic = (pipewire_microphone_t*)mic_context;
const char *error = NULL; const char *error = NULL;
bool res = false;
if (!pw || !microphone || !microphone->is_ready) if (!pw || !mic || !mic->is_ready)
return false; 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_PAUSED)
return true; return true;
return pipewire_stream_set_active(pw->thread_loop, microphone->stream, true); 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);
static bool pipewire_microphone_stop_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;
const char *error = NULL;
bool res = false;
if (!pw || !microphone || !microphone->is_ready)
return false;
if (pw_stream_get_state(microphone->stream, &error) == PW_STREAM_STATE_PAUSED)
return true;
res = pipewire_stream_set_active(pw->thread_loop, microphone->stream, false);
spa_ringbuffer_read_update(&microphone->ring, 0);
spa_ringbuffer_write_update(&microphone->ring, 0);
return res; 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; return true;
} }

View File

@ -45,9 +45,7 @@ typedef struct sdl_microphone
static INLINE int sdl_microphone_find_num_frames(int rate, int latency) static INLINE int sdl_microphone_find_num_frames(int rate, int latency)
{ {
int frames = (rate * latency) / 1000; int frames = (rate * latency) / 1000;
/* SDL only likes 2^n sized buffers. */ /* SDL only likes 2^n sized buffers. */
return next_pow2(frames); return next_pow2(frames);
} }
@ -55,7 +53,6 @@ static void *sdl_microphone_init(void)
{ {
sdl_microphone_t *sdl = NULL; sdl_microphone_t *sdl = NULL;
uint32_t sdl_subsystem_flags = SDL_WasInit(0); uint32_t sdl_subsystem_flags = SDL_WasInit(0);
/* Initialise audio subsystem, if required */ /* Initialise audio subsystem, if required */
if (sdl_subsystem_flags == 0) if (sdl_subsystem_flags == 0)
{ {
@ -67,32 +64,30 @@ static void *sdl_microphone_init(void)
if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0)
return NULL; return NULL;
} }
if (!(sdl = (sdl_microphone_t*)calloc(1, sizeof(*sdl)))) if (!(sdl = (sdl_microphone_t*)calloc(1, sizeof(*sdl))))
return NULL; return NULL;
return sdl; 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 the microphone was originally initialized successfully... */
if (microphone->device_id > 0) if (mic->device_id > 0)
SDL_CloseAudioDevice(microphone->device_id); SDL_CloseAudioDevice(mic->device_id);
fifo_free(microphone->sample_buffer); fifo_free(mic->sample_buffer);
#ifdef HAVE_THREADS #ifdef HAVE_THREADS
slock_free(microphone->lock); slock_free(mic->lock);
scond_free(microphone->cond); scond_free(mic->cond);
#endif #endif
RARCH_LOG("[SDL audio]: Freed microphone with former device ID %u\n", microphone->device_id); RARCH_LOG("[SDL audio]: Freed microphone with former device ID %u\n", mic->device_id);
free(microphone); 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) static void sdl_audio_record_cb(void *data, Uint8 *stream, int len)
{ {
sdl_microphone_handle_t *microphone = (sdl_microphone_handle_t*)data; sdl_microphone_handle_t *mic = (sdl_microphone_handle_t*)data;
size_t avail = FIFO_WRITE_AVAIL(microphone->sample_buffer); size_t avail = FIFO_WRITE_AVAIL(mic->sample_buffer);
size_t read_size = MIN(len, (int)avail); size_t read_size = MIN(len, (int)avail);
/* If the sample buffer is almost full, just write as much as we can into it*/ /* If the sample buffer is almost full, just write as much as we can into it*/
fifo_write(mic->sample_buffer, stream, read_size);
fifo_write(microphone->sample_buffer, stream, read_size);
#ifdef HAVE_THREADS #ifdef HAVE_THREADS
scond_signal(microphone->cond); scond_signal(mic->cond);
#endif #endif
} }
static void *sdl_microphone_open_mic(void *driver_context, static void *sdl_microphone_open_mic(void *driver_context, const char *device,
const char *device, unsigned rate, unsigned latency, unsigned *new_rate)
unsigned rate,
unsigned latency,
unsigned *new_rate)
{ {
int frames; int frames;
size_t bufsize; size_t bufsize;
sdl_microphone_handle_t *microphone = NULL; void *tmp = NULL;
SDL_AudioSpec desired_spec = {0}; sdl_microphone_handle_t *mic = NULL;
void *tmp = NULL; SDL_AudioSpec desired_spec = {0};
#if __APPLE__ #if __APPLE__
if (!string_is_equal(audio_driver_get_ident(), "sdl2")) if (!string_is_equal(audio_driver_get_ident(), "sdl2"))
@ -150,7 +141,7 @@ static void *sdl_microphone_open_mic(void *driver_context,
return NULL; return NULL;
} }
if (!(microphone = (sdl_microphone_handle_t *) if (!(mic = (sdl_microphone_handle_t *)
calloc(1, sizeof(sdl_microphone_handle_t)))) calloc(1, sizeof(sdl_microphone_handle_t))))
return NULL; return NULL;
@ -174,30 +165,31 @@ static void *sdl_microphone_open_mic(void *driver_context,
desired_spec.format = AUDIO_F32SYS; desired_spec.format = AUDIO_F32SYS;
desired_spec.channels = 1; /* Microphones only usually provide input in mono */ desired_spec.channels = 1; /* Microphones only usually provide input in mono */
desired_spec.samples = frames; desired_spec.samples = frames;
desired_spec.userdata = microphone; desired_spec.userdata = mic;
desired_spec.callback = sdl_audio_record_cb; desired_spec.callback = sdl_audio_record_cb;
microphone->device_id = SDL_OpenAudioDevice( mic->device_id = SDL_OpenAudioDevice(
NULL, NULL,
true, true,
&desired_spec, &desired_spec,
&microphone->device_spec, &mic->device_spec,
SDL_AUDIO_ALLOW_FREQUENCY_CHANGE | SDL_AUDIO_ALLOW_FORMAT_CHANGE); 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()); RARCH_ERR("[SDL mic]: Failed to open SDL audio input device: %s\n", SDL_GetError());
goto error; goto error;
} }
RARCH_DBG("[SDL mic]: Opened SDL audio input device with ID %u\n", 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", 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", 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", 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); frames, mic->device_spec.samples, mic->device_spec.size);
RARCH_DBG("[SDL mic]: Got a microphone silence value of %u\n", microphone->device_spec.silence); 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", RARCH_DBG("[SDL mic]: Requested microphone audio format: %u-bit %s %s %s endian\n",
SDL_AUDIO_BITSIZE(desired_spec.format), SDL_AUDIO_BITSIZE(desired_spec.format),
SDL_AUDIO_ISSIGNED(desired_spec.format) ? "signed" : "unsigned", 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"); SDL_AUDIO_ISBIGENDIAN(desired_spec.format) ? "big" : "little");
if (new_rate) if (new_rate)
*new_rate = microphone->device_spec.freq; *new_rate = mic->device_spec.freq;
#ifdef HAVE_THREADS #ifdef HAVE_THREADS
microphone->lock = slock_new(); mic->lock = slock_new();
microphone->cond = scond_new(); mic->cond = scond_new();
#endif #endif
RARCH_LOG("[SDL audio]: Requested %u ms latency for input device, got %d ms\n", 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. */ /* 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); bufsize = mic->device_spec.samples * 2 * (SDL_AUDIO_BITSIZE(mic->device_spec.format) / 8);
tmp = calloc(1, bufsize); tmp = calloc(1, bufsize);
microphone->sample_buffer = fifo_new(bufsize); mic->sample_buffer = fifo_new(bufsize);
RARCH_DBG("[SDL audio]: Initialized microphone sample queue with %u bytes\n", bufsize); RARCH_DBG("[SDL audio]: Initialized microphone sample queue with %u bytes\n", bufsize);
if (tmp) if (tmp)
{ {
fifo_write(microphone->sample_buffer, tmp, bufsize); fifo_write(mic->sample_buffer, tmp, bufsize);
free(tmp); free(tmp);
} }
RARCH_LOG("[SDL audio]: Initialized microphone with device ID %u\n", microphone->device_id); RARCH_LOG("[SDL audio]: Initialized microphone with device ID %u\n", mic->device_id);
return microphone; return mic;
error: error:
free(microphone); free(mic);
return NULL; 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; const sdl_microphone_handle_t *mic = (const sdl_microphone_handle_t*)mic_context;
if (!microphone) if (!mic)
return false; return false;
/* Both params must be non-null */ /* 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; sdl_microphone_handle_t *mic = (sdl_microphone_handle_t*)mic_context;
if (!mic)
if (!microphone)
return false; return false;
SDL_PauseAudioDevice(mic->device_id, false);
SDL_PauseAudioDevice(microphone->device_id, false); if (SDL_GetAudioDeviceStatus(mic->device_id) != SDL_AUDIO_PLAYING)
if (SDL_GetAudioDeviceStatus(microphone->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; return false;
} }
RARCH_DBG("[SDL mic]: Started microphone %u\n", mic->device_id);
RARCH_DBG("[SDL mic]: Started microphone %u\n", microphone->device_id);
return true; 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_t *sdl = (sdl_microphone_t*)driver_context;
sdl_microphone_handle_t *microphone = (sdl_microphone_handle_t*)microphone_context; sdl_microphone_handle_t *mic = (sdl_microphone_handle_t*)mic_context;
if (!sdl || !microphone) if (!sdl || !mic)
return false; 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: 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; return false;
case SDL_AUDIO_STOPPED: 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 */ /* fall-through */
case SDL_AUDIO_PAUSED: case SDL_AUDIO_PAUSED:
break; break;
default: 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; return false;
} }
@ -305,64 +295,68 @@ static void sdl_microphone_set_nonblock_state(void *driver_context, bool state)
sdl->nonblock = 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; int ret = 0;
sdl_microphone_t *sdl = (sdl_microphone_t*)driver_context; sdl_microphone_t *sdl = (sdl_microphone_t*)driver_context;
sdl_microphone_handle_t *microphone = (sdl_microphone_handle_t*)microphone_context; sdl_microphone_handle_t *mic = (sdl_microphone_handle_t*)mic_context;
if (!sdl || !microphone || !buf) if (!sdl || !mic || !s)
return -1; return -1;
/* If we shouldn't block on an empty queue... */
if (sdl->nonblock) if (sdl->nonblock)
{ /* If we shouldn't block on an empty queue... */ {
size_t avail, read_amt; size_t avail, read_amt;
SDL_LockAudioDevice(microphone->device_id); /* Stop the SDL mic thread */ SDL_LockAudioDevice(mic->device_id); /* Stop the SDL mic thread */
avail = FIFO_READ_AVAIL(microphone->sample_buffer); avail = FIFO_READ_AVAIL(mic->sample_buffer);
read_amt = avail > size ? size : avail; read_amt = avail > len ? len : avail;
if (read_amt > 0) if (read_amt > 0)
{ /* If the incoming queue isn't empty... */ { /* 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 */ /* ...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; ret = (int)read_amt;
} }
else else
{ {
size_t read = 0; 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; size_t avail;
SDL_LockAudioDevice(microphone->device_id); SDL_LockAudioDevice(mic->device_id);
/* Stop the SDL microphone thread from running */ /* 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 (avail == 0)
{ /* If the incoming sample queue is empty... */ { /* If the incoming sample queue is empty... */
SDL_UnlockAudioDevice(microphone->device_id); SDL_UnlockAudioDevice(mic->device_id);
/* Let the SDL microphone thread run so it can push some incoming samples */ /* Let the SDL microphone thread run so it can
* push some incoming samples */
#ifdef HAVE_THREADS #ifdef HAVE_THREADS
slock_lock(microphone->lock); slock_lock(mic->lock);
/* Let *only* the SDL microphone thread access the incoming sample queue. */ /* Let *only* the SDL microphone thread access
* the incoming sample queue. */
scond_wait(microphone->cond, microphone->lock); scond_wait(mic->cond, mic->lock);
/* Wait until the SDL microphone thread tells us it's added some samples. */ /* Wait until the SDL microphone thread tells us
* it's added some samples. */
slock_unlock(microphone->lock); slock_unlock(mic->lock);
/* Allow this thread to access the incoming sample queue, which we'll do next iteration */ /* Allow this thread to access the incoming sample queue,
* which we'll do next iteration */
#endif #endif
} }
else else
{ {
size_t read_amt = MIN(size - read, avail); size_t read_amt = MIN(len - read, avail);
fifo_read(microphone->sample_buffer, buf + read, read_amt); fifo_read(mic->sample_buffer, s + read, read_amt);
/* Read as many samples as we have available without underflowing the queue */ /* Read as many samples as we have available without
* underflowing the queue */
SDL_UnlockAudioDevice(microphone->device_id); SDL_UnlockAudioDevice(mic->device_id);
/* Let the SDL microphone thread run again */ /* Let the SDL microphone thread run again */
read += read_amt; read += read_amt;
} }
@ -373,10 +367,10 @@ static int sdl_microphone_read(void *driver_context, void *microphone_context, v
return ret; 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; sdl_microphone_handle_t *mic = (sdl_microphone_handle_t*)mic_context;
return SDL_AUDIO_ISFLOAT(microphone->device_spec.format); return SDL_AUDIO_ISFLOAT(mic->device_spec.format);
} }
microphone_driver_t microphone_sdl = { microphone_driver_t microphone_sdl = {

View File

@ -51,8 +51,42 @@ typedef struct wasapi_microphone
bool nonblock; bool nonblock;
} wasapi_microphone_t; } 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) static void *wasapi_microphone_init(void)
{ {
@ -74,11 +108,8 @@ static void *wasapi_microphone_init(void)
static void wasapi_microphone_free(void *driver_context) static void wasapi_microphone_free(void *driver_context)
{ {
wasapi_microphone_t *wasapi = (wasapi_microphone_t*)driver_context; wasapi_microphone_t *wasapi = (wasapi_microphone_t*)driver_context;
if (wasapi)
if (!wasapi) free(wasapi);
return;
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, * @return The number of bytes in the queue after fetching input,
* or -1 if there was an error. * 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; UINT32 next_packet_size = 0;
/* Shared-mode capture streams split their input buffer into multiple packets, /* 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 frames_read = 0;
UINT32 bytes_read = 0; UINT32 bytes_read = 0;
DWORD buffer_status_flags = 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); &mic_input, &frames_read, &buffer_status_flags, NULL, NULL);
if (FAILED(hr)) if (FAILED(hr))
{ {
RARCH_ERR("[WASAPI]: Failed to get capture device \"%s\"'s buffer: %s\n", RARCH_ERR("[WASAPI]: Failed to get capture device \"%s\"'s buffer: %s\n",
microphone->device_name, mic->device_name, hresult_name(hr));
hresult_name(hr));
return -1; 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 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 */ /* ...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 */ 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. /* 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. */ * 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)) if (FAILED(hr))
{ {
RARCH_ERR("[WASAPI]: Failed to release capture device \"%s\"'s buffer after consuming %u frames: %s\n", RARCH_ERR("[WASAPI]: Failed to release capture device \"%s\"'s buffer after consuming %u frames: %s\n",
microphone->device_name, mic->device_name, frames_read, hresult_name(hr));
frames_read,
hresult_name(hr));
return -1; return -1;
} }
/* If this is a shared-mode stream and we didn't run out of room in the sample queue... */ /* 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. */ /* Get the number of frames that the mic has for us. */
if (FAILED(hr)) if (FAILED(hr))
{ {
RARCH_ERR("[WASAPI]: Failed to get capture device \"%s\"'s next packet size: %s\n", 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; return -1;
} }
} }
@ -156,7 +184,7 @@ static int wasapi_microphone_fetch_fifo(wasapi_microphone_handle_t *microphone)
} }
while (next_packet_size != 0); 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, * @return \c true if the event was signalled,
* \c false if it timed out or there was an error. * \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. */ /*...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: case WAIT_OBJECT_0:
/* Okay, there's data available. */ /* Okay, there's data available. */
return true; return true;
case WAIT_TIMEOUT: case WAIT_TIMEOUT:
/* Time out; there's nothing here for us. */ /* 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; break;
default: 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; break;
} }
return false; 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). * or -1 if there was an error (including timeout).
*/ */
static int wasapi_microphone_read_buffered( static int wasapi_microphone_read_buffered(
wasapi_microphone_handle_t *microphone, wasapi_microphone_handle_t *mic, void *s, size_t len,
void *buffer,
size_t buffer_size,
DWORD timeout) DWORD timeout)
{ {
int bytes_read = 0; /* Number of bytes sent to the core */ 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 we don't have any queued samples to give to the core... */
if (!bytes_available) if (!bytes_available)
{ {
/* If we couldn't wait for the microphone to signal a capture event... */ /* 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; 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 we couldn't fetch samples from the microphone... */
if (bytes_available < 0) if (bytes_available < 0)
return -1; 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 */ /* Now that we have samples available, let's give them to the core */
bytes_read = MIN((int)buffer_size, bytes_available); bytes_read = MIN((int)len, bytes_available);
fifo_read(microphone->buffer, buffer, bytes_read); fifo_read(mic->buffer, s, bytes_read);
/* Read data from the sample queue and store it in the provided buffer */ /* Read data from the sample queue and store it in the provided buffer */
return bytes_read; 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; int bytes_read = 0;
wasapi_microphone_t *wasapi = (wasapi_microphone_t *)driver_context; wasapi_microphone_t *wasapi = (wasapi_microphone_t *)driver_context;
wasapi_microphone_handle_t *microphone = (wasapi_microphone_handle_t*)mic_context; wasapi_microphone_handle_t *mic = (wasapi_microphone_handle_t*)mic_context;
if (!wasapi || !microphone || !buffer) if (!wasapi || !mic || !s)
return -1; return -1;
/* If microphones shouldn't block... */ /* If microphones shouldn't block... */
if (wasapi->nonblock) 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; 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, read = wasapi_microphone_read_buffered(mic,
(char *)buffer + bytes_read, (char *)s + bytes_read,
buffer_size - bytes_read, len - bytes_read,
INFINITE); INFINITE);
if (read == -1) if (read == -1)
return -1; return -1;
@ -261,11 +286,11 @@ static int wasapi_microphone_read(void *driver_context, void *mic_context, void
else else
{ {
int read; 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, read = wasapi_microphone_read_buffered(mic,
(char *)buffer + bytes_read, (char *)s + bytes_read,
buffer_size - bytes_read, len - bytes_read,
INFINITE); INFINITE);
if (read == -1) if (read == -1)
return -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) static void wasapi_microphone_set_nonblock_state(void *driver_context, bool nonblock)
{ {
wasapi_microphone_t *wasapi = (wasapi_microphone_t*)driver_context; wasapi_microphone_t *wasapi = (wasapi_microphone_t*)driver_context;
wasapi->nonblock = nonblock; wasapi->nonblock = nonblock;
} }
@ -286,81 +310,80 @@ static void *wasapi_microphone_open_mic(void *driver_context, const char *device
unsigned latency, unsigned *new_rate) unsigned latency, unsigned *new_rate)
{ {
HRESULT hr; HRESULT hr;
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
DWORD flags = 0; DWORD flags = 0;
UINT32 frame_count = 0; UINT32 frame_count = 0;
REFERENCE_TIME dev_period = 0; REFERENCE_TIME dev_period = 0;
BYTE *dest = NULL; BYTE *dest = NULL;
bool float_format = settings->bools.microphone_wasapi_float_format; bool float_format = settings->bools.microphone_wasapi_float_format;
bool exclusive_mode = settings->bools.microphone_wasapi_exclusive_mode; bool exclusive_mode = settings->bools.microphone_wasapi_exclusive_mode;
unsigned sh_buffer_length = settings->uints.microphone_wasapi_sh_buffer_length; unsigned sh_buffer_length = settings->uints.microphone_wasapi_sh_buffer_length;
wasapi_microphone_handle_t *microphone = (wasapi_microphone_handle_t*)calloc( wasapi_microphone_handle_t *mic = (wasapi_microphone_handle_t*)calloc(
1, sizeof(wasapi_microphone_handle_t)); 1, sizeof(wasapi_microphone_handle_t));
if (!microphone) if (!mic)
return NULL; return NULL;
microphone->exclusive = exclusive_mode; mic->exclusive = exclusive_mode;
microphone->device = wasapi_init_device(device, eCapture); mic->device = wasapi_init_device(device, eCapture);
/* If we requested a particular capture device, but couldn't open it... */ /* 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); 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"); RARCH_ERR("[WASAPI]: Failed to open capture device\n");
goto error; goto error;
} }
microphone->device_name = mmdevice_name(microphone->device); if (!(mic->device_name = mmdevice_name(mic->device)))
if (!microphone->device_name)
{ {
RARCH_ERR("[WASAPI]: Failed to get friendly name of capture device\n"); RARCH_ERR("[WASAPI]: Failed to get friendly name of capture device\n");
goto error; goto error;
} }
microphone->client = wasapi_init_client(microphone->device, mic->client = wasapi_init_client(mic->device,
&microphone->exclusive, &float_format, &rate, latency, 1); &mic->exclusive, &float_format, &rate, latency, 1);
if (!microphone->client) 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; goto error;
} }
hr = _IAudioClient_GetBufferSize(microphone->client, &frame_count); hr = _IAudioClient_GetBufferSize(mic->client, &frame_count);
if (FAILED(hr)) if (FAILED(hr))
{ {
RARCH_ERR("[WASAPI]: Failed to get buffer size of IAudioClient for capture device \"%s\": %s\n", 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; goto error;
} }
microphone->frame_size = float_format ? sizeof(float) : sizeof(int16_t); mic->frame_size = float_format ? sizeof(float) : sizeof(int16_t);
microphone->engine_buffer_size = frame_count * microphone->frame_size; mic->engine_buffer_size = frame_count * mic->frame_size;
/* If this mic should be used *exclusively* by RetroArch... */ /* If this mic should be used *exclusively* by RetroArch... */
if (microphone->exclusive) if (mic->exclusive)
{ {
microphone->buffer = fifo_new(microphone->engine_buffer_size); mic->buffer = fifo_new(mic->engine_buffer_size);
if (!microphone->buffer) if (!mic->buffer)
{ {
RARCH_ERR("[WASAPI]: Failed to initialize FIFO queue for capture device.\n"); RARCH_ERR("[WASAPI]: Failed to initialize FIFO queue for capture device.\n");
goto error; goto error;
} }
RARCH_LOG("[WASAPI]: Intermediate exclusive-mode capture buffer length is %u frames (%.1fms, %u bytes).\n", 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 else
{ {
/* If the user selected the "default" shared buffer length... */ /* If the user selected the "default" shared buffer length... */
if (sh_buffer_length <= 0) if (sh_buffer_length <= 0)
{ {
hr = _IAudioClient_GetDevicePeriod(microphone->client, &dev_period, NULL); hr = _IAudioClient_GetDevicePeriod(mic->client, &dev_period, NULL);
if (FAILED(hr)) if (FAILED(hr))
goto error; 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. */ * Doubling it seems to work okay. Dunno why. */
} }
microphone->buffer = fifo_new(sh_buffer_length * microphone->frame_size); mic->buffer = fifo_new(sh_buffer_length * mic->frame_size);
if (!microphone->buffer) if (!mic->buffer)
goto error; goto error;
RARCH_LOG("[WASAPI]: Intermediate shared-mode capture buffer length is %u frames (%.1fms, %u bytes).\n", 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 (!(mic->read_event = CreateEventA(NULL, FALSE, FALSE, NULL)))
if (!microphone->read_event)
{ {
RARCH_ERR("[WASAPI]: Failed to allocate capture device's event handle\n"); RARCH_ERR("[WASAPI]: Failed to allocate capture device's event handle\n");
goto error; goto error;
} }
hr = _IAudioClient_SetEventHandle(microphone->client, microphone->read_event); hr = _IAudioClient_SetEventHandle(mic->client, mic->read_event);
if (FAILED(hr)) if (FAILED(hr))
{ {
RARCH_ERR("[WASAPI]: Failed to set capture device's event handle: %s\n", hresult_name(hr)); RARCH_ERR("[WASAPI]: Failed to set capture device's event handle: %s\n", hresult_name(hr));
goto error; goto error;
} }
hr = _IAudioClient_GetService(microphone->client, hr = _IAudioClient_GetService(mic->client,
IID_IAudioCaptureClient, (void**)&microphone->capture); IID_IAudioCaptureClient, (void**)&mic->capture);
if (FAILED(hr)) if (FAILED(hr))
{ {
RARCH_ERR("[WASAPI]: Failed to get capture device's IAudioCaptureClient service: %s\n", hresult_name(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. */ /* 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)) if (FAILED(hr))
{ {
RARCH_ERR("[WASAPI]: Failed to get capture client buffer: %s\n", hresult_name(hr)); RARCH_ERR("[WASAPI]: Failed to get capture client buffer: %s\n", hresult_name(hr));
goto error; goto error;
} }
hr = _IAudioCaptureClient_ReleaseBuffer(microphone->capture, 0); hr = _IAudioCaptureClient_ReleaseBuffer(mic->capture, 0);
if (FAILED(hr)) if (FAILED(hr))
{ {
RARCH_ERR("[WASAPI]: Failed to release capture client buffer: %s\n", hresult_name(hr)); RARCH_ERR("[WASAPI]: Failed to release capture client buffer: %s\n", hresult_name(hr));
goto error; goto error;
} }
/* The rate was (possibly) modified when we initialized the client */
if (new_rate) if (new_rate)
{ /* The rate was (possibly) modified when we initialized the client */
*new_rate = rate; *new_rate = rate;
} return mic;
return microphone;
error: error:
IFACE_RELEASE(microphone->capture); IFACE_RELEASE(mic->capture);
IFACE_RELEASE(microphone->client); IFACE_RELEASE(mic->client);
IFACE_RELEASE(microphone->device); IFACE_RELEASE(mic->device);
if (microphone->read_event) if (mic->read_event)
CloseHandle(microphone->read_event); CloseHandle(mic->read_event);
if (microphone->buffer) if (mic->buffer)
fifo_free(microphone->buffer); fifo_free(mic->buffer);
if (microphone->device_name) if (mic->device_name)
free(microphone->device_name); free(mic->device_name);
free(microphone); free(mic);
return NULL; 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_handle_t *mic = (wasapi_microphone_handle_t*)mic_context;
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;
HRESULT hr; HRESULT hr;
(void)driver_context; if (!mic)
if (!microphone)
return false; 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) if (SUCCEEDED(hr) || hr == AUDCLNT_E_NOT_STOPPED)
{ /* Starting an already-active microphone is not an error */ mic->running = true;
microphone->running = true;
}
else else
{ {
RARCH_ERR("[WASAPI mic]: Failed to start capture device \"%s\"'s IAudioClient: %s\n", RARCH_ERR("[WASAPI mic]: Failed to start capture device \"%s\"'s IAudioClient: %s\n",
microphone->device_name, hresult_name(hr)); mic->device_name, hresult_name(hr));
microphone->running = false; mic->running = false;
} }
return mic->running;
return microphone->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; HRESULT hr;
(void)driver_context; if (!mic)
if (!microphone)
return false; return false;
hr = _IAudioClient_Stop(mic->client);
hr = _IAudioClient_Stop(microphone->client);
if (FAILED(hr)) if (FAILED(hr))
{ {
RARCH_ERR("[WASAPI mic]: Failed to stop capture device \"%s\"'s IAudioClient: %s\n", 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; return false;
} }
RARCH_LOG("[WASAPI mic]: Stopped capture device \"%s\".\n", mic->device_name);
RARCH_LOG("[WASAPI mic]: Stopped capture device \"%s\".\n", microphone->device_name); mic->running = false;
microphone->running = false;
return true; return true;
} }
static bool wasapi_microphone_mic_alive(const void *driver_context, const void *mic_context) 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; wasapi_microphone_handle_t *mic = (wasapi_microphone_handle_t *)mic_context;
(void)driver_context; return mic && mic->running;
return microphone && microphone->running;
} }
static struct string_list *wasapi_microphone_device_list_new(const void *driver_context) 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) static void wasapi_microphone_device_list_free(const void *driver_context, struct string_list *devices)
{ {
struct string_list *sl = (struct string_list*)devices; struct string_list *sl = (struct string_list*)devices;
if (sl) if (sl)
string_list_free(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; wasapi_microphone_handle_t *mic = (wasapi_microphone_handle_t *)mic_context;
(void)driver_context; return (mic && (mic->frame_size == sizeof(float)));
if (!microphone)
return false;
return microphone->frame_size == sizeof(float);
} }
microphone_driver_t microphone_wasapi = { microphone_driver_t microphone_wasapi = {

View File

@ -574,7 +574,7 @@ typedef struct udev_input
} udev_input_t; } udev_input_t;
#ifdef UDEV_XKB_HANDLING #ifdef UDEV_XKB_HANDLING
int init_xkb(int fd, size_t size); int init_xkb(int fd, size_t len);
void free_xkb(void); void free_xkb(void);
int handle_xkb(int code, int value); int handle_xkb(int code, int value);
#endif #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); 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) bool screen, bool confined, int16_t *ret_x, int16_t *ret_y)
{ {
struct video_viewport vp = {0}; struct video_viewport vp = {0};
@ -823,7 +823,7 @@ static bool udev_mouse_get_pointer(const udev_input_mouse_t *mouse,
{ {
return false; return false;
} }
if (screen) if (screen)
{ {
*ret_x = res_screen_x; *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 label Label to prefix the message with.
* @param request_data Input data structure to dump. * @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; uint32_t *mt_req_code = (uint32_t*) request_data;
int32_t *mt_req_values = ((int32_t*) request_data) + 1; 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)); 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); RARCH_DBG("%d, ", *mt_req_values);
} }

View File

@ -269,14 +269,14 @@ static bool iohidmanager_hid_joypad_rumble(void *data, unsigned pad,
} }
static void iohidmanager_hid_device_send_control(void *data, 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 *adapter =
(struct iohidmanager_hid_adapter*)data; (struct iohidmanager_hid_adapter*)data;
if (adapter) if (adapter)
IOHIDDeviceSetReport(adapter->handle, IOHIDDeviceSetReport(adapter->handle,
kIOHIDReportTypeOutput, 0x01, data_buf + 1, len - 1); kIOHIDReportTypeOutput, 0x01, s + 1, len - 1);
} }
static void iohidmanager_hid_device_report(void *data, 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 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 *adapter =
(struct iohidmanager_hid_adapter*)handle; (struct iohidmanager_hid_adapter*)handle;
if (adapter) if (adapter)
return IOHIDDeviceSetReport(adapter->handle, return IOHIDDeviceSetReport(adapter->handle,
translate_hid_report_type(report_type), report_id, translate_hid_report_type(report_type), report_id,
data_buf + 1, len - 1); s + 1, len - 1);
return -1; return -1;
} }
static int32_t iohidmanager_get_report(void *handle, uint8_t report_type, uint8_t report_id, 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 *adapter =
(struct iohidmanager_hid_adapter*)handle; (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; CFIndex length = len;
return IOHIDDeviceGetReport(adapter->handle, return IOHIDDeviceGetReport(adapter->handle,
translate_hid_report_type(report_type), translate_hid_report_type(report_type),
report_id, data_buf, &length); report_id, s, &length);
} }
return -1; return -1;

View File

@ -89,26 +89,26 @@ static void adapter_thread(void *data)
while (!adapter->quitting) while (!adapter->quitting)
{ {
size_t send_command_size;
int tmp; int tmp;
size_t _len;
int report_number; int report_number;
int size = 0; int size = 0;
slock_lock(adapter->send_control_lock); slock_lock(adapter->send_control_lock);
if (FIFO_READ_AVAIL(adapter->send_control_buffer) if (FIFO_READ_AVAIL(adapter->send_control_buffer)
>= sizeof(send_command_size)) >= sizeof(_len))
{ {
fifo_read(adapter->send_control_buffer, fifo_read(adapter->send_control_buffer,
&send_command_size, sizeof(send_command_size)); &_len, sizeof(_len));
if (FIFO_READ_AVAIL(adapter->send_control_buffer) if (FIFO_READ_AVAIL(adapter->send_control_buffer)
>= sizeof(send_command_size)) >= sizeof(_len))
{ {
fifo_read(adapter->send_control_buffer, fifo_read(adapter->send_control_buffer,
send_command_buf, send_command_size); send_command_buf, _len);
libusb_interrupt_transfer(adapter->handle, libusb_interrupt_transfer(adapter->handle,
adapter->endpoint_out, send_command_buf, adapter->endpoint_out, send_command_buf,
send_command_size, &tmp, 1000); _len, &tmp, 1000);
} }
} }
slock_unlock(adapter->send_control_lock); 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, 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; 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)) 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, &len, sizeof(len));
fifo_write(adapter->send_control_buffer, data_buf, len); fifo_write(adapter->send_control_buffer, s, len);
} }
else else
{ {

View File

@ -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, 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; uint8_t control_type;
struct wiiusb_adapter *adapter = (struct wiiusb_adapter*)data; struct wiiusb_adapter *adapter = (struct wiiusb_adapter*)data;
if (!adapter || !data_buf || !adapter->send_control_buffer) if (!adapter || !s || !adapter->send_control_buffer)
return; return;
/* first byte contains the type of control to use /* first byte contains the type of control to use
* which can be NONE, INT_MSG, CTRL_MSG, CTRL_MSG2 */ * 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 */ /* decrement size by one as we are getting rid of first byte */
adapter->send_control_size = len - 1; adapter->send_control_size = len - 1;
/* increase the buffer address so we access the actual data */ /* increase the buffer address so we access the actual data */
data_buf++; s++;
memcpy(adapter->send_control_buffer, data_buf, adapter->send_control_size); memcpy(adapter->send_control_buffer, s, adapter->send_control_size);
/* Activate it so it can be processed in the adapter thread */ /* Activate it so it can be processed in the adapter thread */
adapter->send_control_type = control_type; 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, const char *device_name, const char *driver_name,
uint16_t dev_vid, uint16_t dev_pid) uint16_t dev_vid, uint16_t dev_pid)
{ {
input_autoconfigure_connect( input_autoconfigure_connect(device_name, NULL, "hid",
device_name, idx, dev_vid, dev_pid);
NULL,
"hid",
idx,
dev_vid,
dev_pid);
} }
static void wiiusb_get_description(usb_device_entry *device, static void wiiusb_get_description(usb_device_entry *device,
struct wiiusb_adapter *adapter, usb_devdesc *devdesc) struct wiiusb_adapter *adapter, usb_devdesc *devdesc)
{ {
unsigned char c;
unsigned i, k; unsigned i, k;
unsigned char c;
for (c = 0; c < devdesc->bNumConfigurations; c++) for (c = 0; c < devdesc->bNumConfigurations; c++)
{ {

View File

@ -58,21 +58,17 @@ void free_xkb(void)
int init_xkb(int fd, size_t len) 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)); MOD_MAP_SIZE, sizeof(xkb_mod_index_t));
if (!mod_map_idx) if (!mod_map_idx)
goto error; goto error;
mod_map_bit = (uint16_t*) if (!(mod_map_bit = (uint16_t*)
calloc(MOD_MAP_SIZE, sizeof(uint16_t)); calloc(MOD_MAP_SIZE, sizeof(uint16_t))))
if (!mod_map_bit)
goto error; goto error;
xkb_ctx = xkb_context_new(XKB_CONTEXT_NO_FLAGS); if ((xkb_ctx = xkb_context_new(XKB_CONTEXT_NO_FLAGS)))
if (xkb_ctx)
{ {
if (fd >= 0) if (fd >= 0)
{ {

View File

@ -4004,7 +4004,7 @@ void osk_update_last_codepoint(
#ifdef HAVE_LANGEXTRA #ifdef HAVE_LANGEXTRA
/* combine 3 korean elements. make utf8 character */ /* 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 uv = c1 * (28 * 21) + c2 * 28 + c3 + 0xac00;
int tv = (uv >> 12) | ((uv & 0x0f00) << 2) | ((uv & 0xc0) << 2) | ((uv & 0x3f) << 16); 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 */ /* utf8 korean composition */
static unsigned get_kr_composition( char* pcur, char* padd) static unsigned get_kr_composition(char* pcur, char* padd)
{ {
size_t _len; size_t _len;
static char cc1[] = {"ㄱㄱㄲ ㄷㄷㄸ ㅂㅂㅃ ㅅㅅㅆ ㅈㅈㅉ"}; static char cc1[] = {"ㄱㄱㄲ ㄷㄷㄸ ㅂㅂㅃ ㅅㅅㅆ ㅈㅈㅉ"};
@ -4296,7 +4296,7 @@ void input_event_osk_append(
int ptr, int ptr,
bool show_symbol_pages, bool show_symbol_pages,
const char *word, const char *word,
size_t word_len) size_t len)
{ {
#ifdef HAVE_LANGEXTRA #ifdef HAVE_LANGEXTRA
if (string_is_equal(word, "\xe2\x87\xa6")) /* backspace character */ if (string_is_equal(word, "\xe2\x87\xa6")) /* backspace character */
@ -4327,7 +4327,7 @@ void input_event_osk_append(
else else
*osk_idx = ((enum osk_type)(OSK_TYPE_UNKNOWN + 1)); *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; unsigned character = *((unsigned*)word) | 0x01000000;
input_keyboard_line_event(&input_driver_st, keyboard_line, character); input_keyboard_line_event(&input_driver_st, keyboard_line, character);
@ -4350,7 +4350,7 @@ void input_event_osk_append(
#endif #endif
else else
{ {
input_keyboard_line_append(keyboard_line, word, word_len); input_keyboard_line_append(keyboard_line, word, len);
osk_update_last_codepoint( osk_update_last_codepoint(
osk_last_codepoint, osk_last_codepoint,
osk_last_codepoint_len, 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; retro_ctx_serialize_info_t serial_info;
uint8_t frame_tok = REPLAY_TOKEN_CHECKPOINT_FRAME; uint8_t frame_tok = REPLAY_TOKEN_CHECKPOINT_FRAME;
size_t info_size = core_serialize_size(); size_t _len = core_serialize_size();
uint64_t size = swap_if_big64(info_size); uint64_t size = swap_if_big64(_len);
uint8_t *st = (uint8_t*)malloc(info_size); uint8_t *st = (uint8_t*)malloc(_len);
serial_info.data = st; serial_info.data = st;
serial_info.size = info_size; serial_info.size = _len;
core_serialize(&serial_info); core_serialize(&serial_info);
/* "next frame is a checkpoint" */ /* "next frame is a checkpoint" */
intfstream_write(handle->file, (uint8_t *)(&frame_tok), sizeof(uint8_t)); intfstream_write(handle->file, (uint8_t *)(&frame_tok), sizeof(uint8_t));
intfstream_write(handle->file, &size, sizeof(uint64_t)); intfstream_write(handle->file, &size, sizeof(uint64_t));
intfstream_write(handle->file, st, info_size); intfstream_write(handle->file, st, _len);
free(st); free(st);
} }
else else

View File

@ -56,7 +56,7 @@ void input_event_osk_append(
int ptr, int ptr,
bool show_symbol_pages, bool show_symbol_pages,
const char *word, const char *word,
size_t word_len); size_t len);
void osk_update_last_codepoint( void osk_update_last_codepoint(
unsigned *last_codepoint, unsigned *last_codepoint,

View File

@ -94,10 +94,8 @@ struct registered_func
/* Forward declarations */ /* Forward declarations */
static struct buffer query_parse_method_call(char *s, size_t len, static struct buffer query_parse_method_call(char *s, size_t len,
struct buffer buff, struct buffer buff, struct invocation *invocation, const char **error);
struct invocation *invocation, const char **error); static struct buffer query_parse_table(char *s, size_t len, struct buffer buff,
static struct buffer query_parse_table(char *s,
size_t len, struct buffer buff,
struct invocation *invocation, const char **error); struct invocation *invocation, const char **error);
/* Errors */ /* 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, static int query_peek(struct buffer buff, const char * data,
size_t len) size_t len)
{ {
size_t remain = buff.len - buff.offset; size_t remain = buff.len - buff.offset;
if (remain < len) if (remain < len)
return 0; return 0;
return (strncmp(buff.data + buff.offset, data, len) == 0); return (strncmp(buff.data + buff.offset, data, len) == 0);
@ -466,10 +464,9 @@ static struct buffer query_parse_string(
return buff; return buff;
} }
static struct buffer query_parse_value( static struct buffer query_parse_value(char *s, size_t len,
char *s, size_t len, struct buffer buff, struct rmsgpack_dom_value *value,
struct buffer buff, const char **error)
struct rmsgpack_dom_value *value, const char **error)
{ {
buff = query_chomp(buff); buff = query_chomp(buff);
@ -502,8 +499,7 @@ static struct buffer query_parse_value(
} }
static void query_peek_char(char *s, size_t len, static void query_peek_char(char *s, size_t len,
struct buffer buff, char *c, struct buffer buff, char *c, const char **error)
const char **error)
{ {
if ((unsigned)buff.offset >= buff.len) 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]; *c = buff.data[buff.offset];
} }
static struct buffer query_get_ident( static struct buffer query_get_ident(char *s, size_t _len,
char *s, size_t _len, struct buffer buff, const char **ident,
struct buffer buff,
const char **ident,
size_t *len, const char **error) size_t *len, const char **error)
{ {
char c = '\0'; char c = '\0';
@ -622,102 +616,6 @@ static struct buffer query_parse_argument(
return buff; 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( static struct rmsgpack_dom_value query_func_all_map(
struct rmsgpack_dom_value input, struct rmsgpack_dom_value input,
unsigned argc, const struct argument *argv) unsigned argc, const struct argument *argv)
@ -776,10 +674,10 @@ static struct buffer query_parse_table(
struct invocation *invocation, const char **error) struct invocation *invocation, const char **error)
{ {
unsigned i; unsigned i;
size_t ident_len; size_t _len;
unsigned argi = 0;
struct argument args[QUERY_MAX_ARGS]; struct argument args[QUERY_MAX_ARGS];
const char *ident_name = NULL; const char *ident_name = NULL;
unsigned argi = 0;
buff = query_chomp(buff); buff = query_chomp(buff);
buff = query_expect_char(s, len, buff, '{', error); 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])) if (ISALPHA((int)buff.data[buff.offset]))
{ {
buff = query_get_ident(s, len, buff = query_get_ident(s, len,
buff, &ident_name, &ident_len, error); buff, &ident_name, &_len, error);
if (!*error) if (!*error)
{ {
args[argi].a.value.type = RDT_STRING; 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( args[argi].a.value.val.string.buff = (char*)calloc(
ident_len + 1, _len + 1, sizeof(char));
sizeof(char)
);
if (!args[argi].a.value.val.string.buff) if (!args[argi].a.value.val.string.buff)
goto clean; goto clean;
strncpy( strncpy(
args[argi].a.value.val.string.buff, args[argi].a.value.val.string.buff,
ident_name, ident_name, _len);
ident_len
);
} }
} }
else else
@ -892,6 +786,101 @@ clean:
return buff; 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) void libretrodb_query_free(void *q)
{ {
unsigned i; unsigned i;

View File

@ -203,37 +203,37 @@ uint32_t gx_mem2_total(void)
return info.used_size + info.free_size; return info.used_size + info.free_size;
} }
void *__real_malloc(size_t size); void *__real_malloc(size_t len);
void *__real_calloc(size_t n, size_t size); void *__real_calloc(size_t n, size_t len);
void *__real_memalign(size_t a, size_t size); void *__real_memalign(size_t a, size_t len);
void __real_free(void *p); 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_strdup(const char *s);
void *__real_strndup(const char *s, size_t n); void *__real_strndup(const char *s, size_t n);
size_t __real_malloc_usable_size(void *p); 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) if (p != 0)
return p; 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) if (p != 0)
return p; 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) if (p != 0)
return p; return p;
return _mem2_memalign(a, size); return _mem2_memalign(a, len);
} }
__attribute__ ((used)) void __wrap_free(void *p) __attribute__ ((used)) void __wrap_free(void *p)
@ -247,37 +247,37 @@ __attribute__ ((used)) void __wrap_free(void *p)
__real_free(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; void *n;
/* ptr from mem2 */ /* ptr from mem2 */
if (((uint32_t) p & 0x10000000) != 0) if (((uint32_t) p & 0x10000000) != 0)
{ {
n = _mem2_realloc(p, size); n = _mem2_realloc(p, len);
if (n != 0) if (n != 0)
return n; return n;
n = __real_malloc(size); n = __real_malloc(len);
if (n == 0) if (n == 0)
return 0; return 0;
if (p != 0) if (p != 0)
{ {
size_t heap_size = __lwp_heap_block_size(&gx_mem2_heap, p); 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); _mem2_free(p);
} }
return n; return n;
} }
/* ptr from malloc */ /* ptr from malloc */
n = __real_realloc(p, size); n = __real_realloc(p, len);
if (n != 0) if (n != 0)
return n; return n;
n = _mem2_malloc(size); n = _mem2_malloc(len);
if (n == 0) if (n == 0)
return 0; return 0;
if (p != 0) if (p != 0)
{ {
size_t heap_size = __real_malloc_usable_size(p); 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); __real_free(p);
} }
return n; return n;

View File

@ -1904,14 +1904,14 @@ int generic_action_ok_displaylist_push(
* selection needs to be made from a list, otherwise * selection needs to be made from a list, otherwise
* returns true and fills in @s with path to core. * 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, static bool menu_content_find_first_core(
bool load_content_with_current_core, menu_content_ctx_defer_info_t *def_info,
char *new_core_path, size_t len) bool load_content_with_current_core, char *s, size_t len)
{ {
const core_info_t *info = NULL; const core_info_t *info = NULL;
size_t supported = 0; size_t supported = 0;
core_info_list_t *core_info = (core_info_list_t*)def_info->data; core_info_list_t *core_info = (core_info_list_t*)def_info->data;
const char *default_info_dir = def_info->dir; const char *default_info_dir = def_info->dir;
if (!string_is_empty(default_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; return false;
if (info) if (info)
strlcpy(new_core_path, info->path, len); strlcpy(s, info->path, len);
return true; return true;
} }

View File

@ -591,7 +591,7 @@ typedef struct materialui_handle
} font_data; } font_data;
size_t (*word_wrap)( size_t (*word_wrap)(
char *dst, size_t dst_size, char *s, size_t len,
const char *src, size_t src_len, const char *src, size_t src_len,
int line_width, int wideglyph_width, unsigned max_lines); 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) static void materialui_context_destroy_playlist_icons(materialui_handle_t *mui)
{ {
size_t i; size_t i;
for (i = 0; i < mui->textures.playlist.size; i++) for (i = 0; i < mui->textures.playlist.size; i++)
video_driver_texture_unload(&mui->textures.playlist.icons[i].image); 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) materialui_handle_t *mui)
{ {
size_t i; size_t i;
if (string_is_empty(mui->sysicons_path)) if (string_is_empty(mui->sysicons_path))
return; return;
@ -2222,7 +2220,6 @@ static void materialui_context_reset_playlist_icons(
static void materialui_free_playlist_icon_list(materialui_handle_t *mui) static void materialui_free_playlist_icon_list(materialui_handle_t *mui)
{ {
size_t i; size_t i;
for (i = 0; i < mui->textures.playlist.size; i++) for (i = 0; i < mui->textures.playlist.size; i++)
{ {
/* Ensure that any textures are unloaded /* 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( static bool INLINE materialui_entry_onscreen(
materialui_handle_t *mui, size_t idx) materialui_handle_t *mui, size_t idx)
{ {
return (idx >= mui->first_onscreen_entry) && return (idx >= mui->first_onscreen_entry)
(idx <= mui->last_onscreen_entry); && (idx <= mui->last_onscreen_entry);
} }
/* If currently selected entry is off screen, /* If currently selected entry is off screen,
@ -3222,9 +3219,9 @@ static INLINE void materialui_kill_scroll_animation(
* is detected */ * is detected */
static bool materialui_render_process_entry_default( static bool materialui_render_process_entry_default(
materialui_handle_t* mui, materialui_handle_t* mui,
struct menu_state *menu_st, struct menu_state *menu_st, materialui_node_t *node,
materialui_node_t *node, size_t entry_idx, size_t selection,
size_t entry_idx, size_t selection, size_t playlist_idx, size_t playlist_idx,
bool first_entry_found, bool last_entry_found, bool first_entry_found, bool last_entry_found,
unsigned thumbnail_upscale_threshold, unsigned thumbnail_upscale_threshold,
bool network_on_demand_thumbnails) bool network_on_demand_thumbnails)
@ -3242,9 +3239,9 @@ static bool materialui_render_process_entry_default(
* Always returns true */ * Always returns true */
static bool materialui_render_process_entry_playlist_thumb_list( static bool materialui_render_process_entry_playlist_thumb_list(
materialui_handle_t* mui, materialui_handle_t* mui,
struct menu_state *menu_st, struct menu_state *menu_st, materialui_node_t *node,
materialui_node_t *node, size_t entry_idx, size_t selection,
size_t entry_idx, size_t selection, size_t playlist_idx, size_t playlist_idx,
bool first_entry_found, bool last_entry_found, bool first_entry_found, bool last_entry_found,
unsigned thumbnail_upscale_threshold, unsigned thumbnail_upscale_threshold,
bool network_on_demand_thumbnails) bool network_on_demand_thumbnails)
@ -3285,9 +3282,9 @@ static bool materialui_render_process_entry_playlist_thumb_list(
* Always returns true */ * Always returns true */
static bool materialui_render_process_entry_playlist_dual_icon( static bool materialui_render_process_entry_playlist_dual_icon(
materialui_handle_t* mui, materialui_handle_t* mui,
struct menu_state *menu_st, struct menu_state *menu_st, materialui_node_t *node,
materialui_node_t *node, size_t entry_idx, size_t selection,
size_t entry_idx, size_t selection, size_t playlist_idx, size_t playlist_idx,
bool first_entry_found, bool last_entry_found, bool first_entry_found, bool last_entry_found,
unsigned thumbnail_upscale_threshold, unsigned thumbnail_upscale_threshold,
bool network_on_demand_thumbnails) bool network_on_demand_thumbnails)
@ -3319,9 +3316,9 @@ static bool materialui_render_process_entry_playlist_dual_icon(
* Always returns true */ * Always returns true */
static bool materialui_render_process_entry_playlist_desktop( static bool materialui_render_process_entry_playlist_desktop(
materialui_handle_t* mui, materialui_handle_t* mui,
struct menu_state *menu_st, struct menu_state *menu_st, materialui_node_t *node,
materialui_node_t *node, size_t entry_idx, size_t selection,
size_t entry_idx, size_t selection, size_t playlist_idx, size_t playlist_idx,
bool first_entry_found, bool last_entry_found, bool first_entry_found, bool last_entry_found,
unsigned thumbnail_upscale_threshold, unsigned thumbnail_upscale_threshold,
bool network_on_demand_thumbnails) bool network_on_demand_thumbnails)
@ -3520,9 +3517,9 @@ static bool materialui_render_process_entry_playlist_desktop(
static bool (*materialui_render_process_entry)( static bool (*materialui_render_process_entry)(
materialui_handle_t* mui, materialui_handle_t* mui,
struct menu_state *menu_st, struct menu_state *menu_st, materialui_node_t *node,
materialui_node_t *node, size_t entry_idx, size_t selection,
size_t entry_idx, size_t selection, size_t playlist_idx, size_t playlist_idx,
bool first_entry_found, bool last_entry_found, bool first_entry_found, bool last_entry_found,
unsigned thumbnail_upscale_threshold, unsigned thumbnail_upscale_threshold,
bool network_on_demand_thumbnails) = materialui_render_process_entry_default; 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) file_list_t *list, size_t selection)
{ {
math_matrix_4x4 mymat; math_matrix_4x4 mymat;
materialui_node_t *node = (materialui_node_t*)list->list[selection].userdata; 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_x = (float)(x_offset + (int)mui->landscape_optimization.border_width);
float background_y = (float)header_height; float background_y = (float)header_height;
/* Note: If landscape optimisations are enabled, /* Note: If landscape optimisations are enabled,
* need to allow space for a second divider at * need to allow space for a second divider at
* the left hand edge of the sidebar */ * 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 ? (mui->entry_divider_width * (mui->landscape_optimization.enabled ?
2 : 1)); 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; (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); (mui->landscape_optimization.enabled ? mui->entry_divider_width : 0);
float thumbnail_y = background_y + (float)mui->margin; float thumbnail_y = background_y + (float)mui->margin;
gfx_display_t *p_disp = disp_get_ptr(); gfx_display_t *p_disp = disp_get_ptr();
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
/* Sanity check */ /* Sanity check */
if ( (background_width <= 0) if ( (background_width <= 0)
@ -5233,17 +5230,14 @@ static void (*materialui_render_selected_entry_aux)(
/* Draws current menu list */ /* Draws current menu list */
static void materialui_render_menu_list( static void materialui_render_menu_list(
materialui_handle_t *mui, materialui_handle_t *mui, gfx_display_t *p_disp,
gfx_display_t *p_disp, void *userdata, size_t selection,
void *userdata, unsigned video_width, unsigned video_height,
size_t selection,
unsigned video_width,
unsigned video_height,
int x_offset) int x_offset)
{ {
size_t i; size_t i;
size_t first_entry;
size_t last_entry; size_t last_entry;
size_t first_entry;
struct menu_state *menu_st = menu_state_get_ptr(); struct menu_state *menu_st = menu_state_get_ptr();
menu_list_t *menu_list = menu_st->entries.list; menu_list_t *menu_list = menu_st->entries.list;
menu_input_t *menu_input = &menu_st->input_state; 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( static void materialui_render_selection_highlight(
materialui_handle_t *mui, materialui_handle_t *mui,
gfx_display_t *p_disp, gfx_display_t *p_disp, void *userdata,
void *userdata,
unsigned video_width, unsigned video_height, unsigned video_width, unsigned video_height,
unsigned header_height, int x_offset, unsigned header_height, int x_offset,
size_t selection, float *highlight_color, size_t selection, float *highlight_color,
@ -5568,8 +5561,7 @@ static void materialui_render_selection_highlight(
static void materialui_render_entry_touch_feedback( static void materialui_render_entry_touch_feedback(
materialui_handle_t *mui, materialui_handle_t *mui,
gfx_display_t *p_disp, gfx_display_t *p_disp, void *userdata,
void *userdata,
menu_input_t *menu_input, menu_input_t *menu_input,
unsigned video_width, unsigned video_height, unsigned video_width, unsigned video_height,
unsigned header_height, int x_offset, unsigned header_height, int x_offset,
@ -6095,12 +6087,9 @@ static void materialui_render_header(
* bars. This involves substantial code duplication, but if * bars. This involves substantial code duplication, but if
* we try to handle this with a single function then * we try to handle this with a single function then
* things get incredibly messy and inefficient... */ * things get incredibly messy and inefficient... */
static void materialui_render_nav_bar_bottom( static void materialui_render_nav_bar_bottom(materialui_handle_t *mui,
materialui_handle_t *mui, gfx_display_t *p_disp, void *userdata,
gfx_display_t *p_disp, unsigned video_width, unsigned video_height, math_matrix_4x4 *mymat)
void *userdata,
unsigned video_width, unsigned video_height,
math_matrix_4x4 *mymat)
{ {
size_t i; size_t i;
unsigned nav_bar_width = video_width; unsigned nav_bar_width = video_width;
@ -6219,12 +6208,9 @@ static void materialui_render_nav_bar_bottom(
} }
} }
static void materialui_render_nav_bar_right( static void materialui_render_nav_bar_right(materialui_handle_t *mui,
materialui_handle_t *mui, gfx_display_t *p_disp, void *userdata,
gfx_display_t *p_disp, unsigned video_width, unsigned video_height,
void *userdata,
unsigned video_width,
unsigned video_height,
math_matrix_4x4 *mymat) math_matrix_4x4 *mymat)
{ {
size_t i; size_t i;
@ -6345,12 +6331,9 @@ static void materialui_render_nav_bar_right(
} }
} }
static void materialui_render_nav_bar( static void materialui_render_nav_bar(materialui_handle_t *mui,
materialui_handle_t *mui, gfx_display_t *p_disp, void *userdata,
gfx_display_t *p_disp, unsigned video_width, unsigned video_height,
void *userdata,
unsigned video_width,
unsigned video_height,
math_matrix_4x4 *mymat) math_matrix_4x4 *mymat)
{ {
switch (mui->nav_bar.location) switch (mui->nav_bar.location)
@ -6541,13 +6524,10 @@ static void materialui_show_fullscreen_thumbnails(
mui->flags |= MUI_FLAG_SHOW_FULLSCREEN_THUMBNAILS; mui->flags |= MUI_FLAG_SHOW_FULLSCREEN_THUMBNAILS;
} }
static void materialui_render_fullscreen_thumbnails( static void materialui_render_fullscreen_thumbnails(materialui_handle_t *mui,
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 video_width, unsigned video_height,
unsigned header_height, unsigned header_height, size_t selection)
size_t selection)
{ {
/* Check whether fullscreen thumbnails are visible */ /* Check whether fullscreen thumbnails are visible */
if (mui->fullscreen_thumbnail_alpha > 0.0f) 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 */ /* Updates scrollbar draw position */
static void materialui_update_scrollbar( static void materialui_update_scrollbar(materialui_handle_t *mui,
materialui_handle_t *mui,
unsigned width, unsigned height, unsigned width, unsigned height,
unsigned header_height, int x_offset) 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 /* Determines current list view type, based on
* whether current menu is a playlist, and whether * whether current menu is a playlist, and whether
* user has enabled playlist thumbnails */ * user has enabled playlist thumbnails */
static void materialui_set_list_view_type( static void materialui_set_list_view_type(materialui_handle_t *mui,
materialui_handle_t *mui,
struct menu_state *menu_st, struct menu_state *menu_st,
unsigned thumbnail_view_portrait, unsigned thumbnail_view_portrait,
unsigned thumbnail_view_landscape) unsigned thumbnail_view_landscape)
@ -7512,8 +7490,8 @@ static void materialui_set_landscape_optimisations_enable(
/* Initialises status bar, determining current /* Initialises status bar, determining current
* enable state based on view mode and user * enable state based on view mode and user
* configuration */ * configuration */
static void materialui_status_bar_init( static void materialui_status_bar_init(materialui_handle_t *mui,
materialui_handle_t *mui, settings_t *settings) settings_t *settings)
{ {
bool playlist_show_sublabels = settings->bools.playlist_show_sublabels; bool playlist_show_sublabels = settings->bools.playlist_show_sublabels;
uintptr_t alpha_tag = (uintptr_t)&mui->status_bar.alpha; 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) switch (mui->list_view_type)
{ {
case MUI_LIST_VIEW_PLAYLIST_THUMB_LIST_SMALL: case MUI_LIST_VIEW_PLAYLIST_THUMB_LIST_SMALL:
/* Maximum height is just standard icon size */ /* Maximum height is just standard icon size */
mui->thumbnail_height_max = mui->icon_size; mui->thumbnail_height_max = mui->icon_size;
/* Set thumbnail width based on max height */ /* Set thumbnail width based on max height */
mui->thumbnail_width_max = mui->thumbnail_width_max =
(unsigned)(((float)mui->thumbnail_height_max * (unsigned)(((float)mui->thumbnail_height_max *
MUI_THUMBNAIL_DEFAULT_ASPECT_RATIO) + 0.5f); MUI_THUMBNAIL_DEFAULT_ASPECT_RATIO) + 0.5f);
break; break;
case MUI_LIST_VIEW_PLAYLIST_THUMB_LIST_MEDIUM: case MUI_LIST_VIEW_PLAYLIST_THUMB_LIST_MEDIUM:
/* Maximum height corresponds to text height when /* Maximum height corresponds to text height when
* showing full playlist sublabel metadata * showing full playlist sublabel metadata
* (core association + runtime info) * (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 * - Returns false if secondary thumbnails cannot be
* enabled (due to per-playlist override) */ * enabled (due to per-playlist override) */
static bool materialui_force_enable_secondary_thumbnail( static bool materialui_force_enable_secondary_thumbnail(
materialui_handle_t *mui, materialui_handle_t *mui, struct menu_state *menu_st,
struct menu_state *menu_st,
settings_t *settings) settings_t *settings)
{ {
/* If secondary thumbnail is already enabled, /* If secondary thumbnail is already enabled,
@ -7769,10 +7741,8 @@ static bool materialui_force_enable_secondary_thumbnail(
/* Determines whether dual thumbnails should be enabled /* Determines whether dual thumbnails should be enabled
* based on current list view mode, thumbnail dimensions * based on current list view mode, thumbnail dimensions
* and screen size */ * and screen size */
static void materialui_set_secondary_thumbnail_enable( static void materialui_set_secondary_thumbnail_enable(materialui_handle_t *mui,
materialui_handle_t *mui, struct menu_state *menu_st, settings_t *settings)
struct menu_state *menu_st,
settings_t *settings)
{ {
switch (mui->list_view_type) switch (mui->list_view_type)
{ {
@ -7858,8 +7828,7 @@ static void materialui_set_secondary_thumbnail_enable(
* Must be called when updating menu layout and * Must be called when updating menu layout and
* populating menu lists. */ * populating menu lists. */
static void materialui_update_list_view(materialui_handle_t *mui, static void materialui_update_list_view(materialui_handle_t *mui,
struct menu_state *menu_st, struct menu_state *menu_st, settings_t *settings)
settings_t *settings)
{ {
materialui_set_list_view_type(mui, menu_st, materialui_set_list_view_type(mui, menu_st,
settings->uints.menu_materialui_thumbnail_view_portrait, 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; mui->flags |= MUI_FLAG_NEED_COMPUTE;
} }
static void materialui_init_font( static void materialui_init_font(gfx_display_t *p_disp,
gfx_display_t *p_disp, font_data_impl_t *font_data, int font_size,
font_data_impl_t *font_data, bool video_is_threaded, const char *str_latin)
int font_size,
bool video_is_threaded,
const char *str_latin
)
{ {
char tmp_dir[DIR_MAX_LENGTH]; char tmp_dir[DIR_MAX_LENGTH];
char fontpath[PATH_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, font_data->font = gfx_display_font_file(p_disp,
fontpath, font_size, video_is_threaded); fontpath, font_size, video_is_threaded);
if (font_data->font) if (font_data->font)
{ {
/* Calculate a more realistic ticker_limit */ /* Calculate a more realistic ticker_limit */
int char_width = int char_width =
@ -7972,12 +7937,9 @@ static void materialui_init_font(
} }
/* Compute the positions of the widgets */ /* Compute the positions of the widgets */
static void materialui_layout( static void materialui_layout(materialui_handle_t *mui,
materialui_handle_t *mui, struct menu_state *menu_st, gfx_display_t *p_disp,
struct menu_state *menu_st, settings_t *settings, bool video_is_threaded)
gfx_display_t *p_disp,
settings_t *settings,
bool video_is_threaded)
{ {
int title_font_size; int title_font_size;
int list_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; mui->nav_bar.location = MUI_NAV_BAR_LOCATION_BOTTOM;
} }
static void materialui_menu_animation_update_time( static void materialui_menu_animation_update_time(float *s,
float *ticker_pixel_increment,
unsigned video_width, unsigned video_height) unsigned video_width, unsigned video_height)
{ {
gfx_display_t *p_disp = disp_get_ptr(); 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 * a small correction factor to achieve a
* default scroll speed equal to that of the * default scroll speed equal to that of the
* non-smooth ticker */ * non-smooth ticker */
*(ticker_pixel_increment) *= gfx_display_get_dpi_scale( *(s) *= gfx_display_get_dpi_scale(p_disp, settings,
p_disp, settings,
video_width, video_height, false, false) * 0.8f; 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 /* Note: This is only used for loading wallpaper
* images. Thumbnails are 'streamed' and must be * images. Thumbnails are 'streamed' and must be
* handled differently */ * 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; 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; mui->scroll_animation_selection = 0;
} }
static void materialui_animate_scroll( static void materialui_animate_scroll(materialui_handle_t *mui,
materialui_handle_t *mui, float scroll_pos, float duration) float scroll_pos, float duration)
{ {
gfx_animation_ctx_entry_t animation_entry; gfx_animation_ctx_entry_t animation_entry;
struct menu_state *menu_st = menu_state_get_ptr(); 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; materialui_handle_t *mui = (materialui_handle_t*)data;
if (!mui) if (!mui)
return; return;
menu_st->entries.begin = i; 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) 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); materialui_navigation_set(data, true);
} }
static void materialui_populate_nav_bar( static void materialui_populate_nav_bar(materialui_handle_t *mui,
materialui_handle_t *mui, struct menu_state *menu_st, const char *label, settings_t *settings)
struct menu_state *menu_st,
const char *label,
settings_t *settings)
{ {
size_t menu_tab_index = 0; size_t menu_tab_index = 0;
bool menu_content_show_playlists = bool menu_content_show_playlists =
@ -8531,8 +8484,8 @@ static void materialui_populate_nav_bar(
mui->nav_bar.num_menu_tabs = menu_tab_index; mui->nav_bar.num_menu_tabs = menu_tab_index;
} }
static void materialui_init_transition_animation( static void materialui_init_transition_animation(materialui_handle_t *mui,
materialui_handle_t *mui, settings_t *settings) settings_t *settings)
{ {
gfx_animation_ctx_entry_t alpha_entry; gfx_animation_ctx_entry_t alpha_entry;
gfx_animation_ctx_entry_t x_offset_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 */ /* A new list has been pushed */
static void materialui_populate_entries( static void materialui_populate_entries(void *data, const char *path,
void *data, const char *path,
const char *label, unsigned i) const char *label, unsigned i)
{ {
materialui_handle_t *mui = (materialui_handle_t*)data; 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(); video_driver_monitor_reset();
} }
static int materialui_environ(enum menu_environ_cb type, static int materialui_environ(enum menu_environ_cb type, void *data,
void *data, void *userdata) void *userdata)
{ {
materialui_handle_t *mui = (materialui_handle_t*)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: /* Called before we push the new list after:
* - Clicking a menu-type tab on the navigation bar * - Clicking a menu-type tab on the navigation bar
* - Using left/right to navigate between top level menus */ * - Using left/right to navigate between top level menus */
static bool materialui_preswitch_tabs( static bool materialui_preswitch_tabs(materialui_handle_t *mui,
materialui_handle_t *mui, materialui_nav_bar_menu_tab_t *target_tab) materialui_nav_bar_menu_tab_t *target_tab)
{ {
size_t stack_size = 0; size_t stack_size = 0;
file_list_t *menu_stack = NULL; file_list_t *menu_stack = NULL;
@ -8987,9 +8939,8 @@ static bool materialui_preswitch_tabs(
* > If tab == NULL, this is a left/right navigation * > If tab == NULL, this is a left/right navigation
* event - in this case, 'action' is used to determine * event - in this case, 'action' is used to determine
* target tab */ * target tab */
static int materialui_switch_tabs( static int materialui_switch_tabs(materialui_handle_t *mui,
materialui_handle_t *mui, materialui_nav_bar_menu_tab_t *tab, materialui_nav_bar_menu_tab_t *tab, enum menu_action action)
enum menu_action action)
{ {
materialui_nav_bar_menu_tab_t *target_tab = tab; 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, /* If viewing a playlist with thumbnails enabled,
* cycles current thumbnail view mode */ * cycles current thumbnail view mode */
static void materialui_switch_list_view(materialui_handle_t *mui, static void materialui_switch_list_view(materialui_handle_t *mui,
struct menu_state *menu_st, struct menu_state *menu_st, settings_t *settings)
settings_t *settings)
{ {
bool secondary_thumbnail_enabled_prev = mui->flags & bool secondary_thumbnail_enabled_prev = mui->flags &
MUI_FLAG_SECONDARY_THUMBNAIL_ENABLED; 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; mui->flags |= MUI_FLAG_NEED_COMPUTE;
} }
/* Material UI requires special handling of certain /* Material UI requires special handling of certain
* menu input functions, due to the fact that navigation * menu input functions, due to the fact that navigation
* controls are relative to the currently selected item, * 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( static int materialui_pointer_up_swipe_horz_default(
materialui_handle_t *mui, menu_entry_t *entry, 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)) 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( static int materialui_pointer_up_nav_bar(
materialui_handle_t *mui, materialui_handle_t *mui,
unsigned x, unsigned y, unsigned width, unsigned height, size_t selection, unsigned x, unsigned y, unsigned width, unsigned height,
menu_file_list_cbs_t *cbs, menu_entry_t *entry, unsigned action) size_t selection, menu_file_list_cbs_t *cbs,
menu_entry_t *entry, unsigned action)
{ {
unsigned tab_index; unsigned tab_index;
size_t num_tabs = mui->nav_bar.num_menu_tabs + MUI_NAV_BAR_NUM_ACTION_TABS; 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 * This function allocates the materialui_node_t
* for the new entry. */ * for the new entry. */
static void materialui_list_insert( static void materialui_list_insert(void *userdata,
void *userdata,
file_list_t *list, file_list_t *list,
const char *path, const char *path, const char *fullpath,
const char *fullpath, const char *label, size_t list_size, unsigned type)
const char *label,
size_t list_size,
unsigned type)
{ {
int i = (int)list_size; int i = (int)list_size;
materialui_node_t *node = NULL; materialui_node_t *node = NULL;

View File

@ -4242,12 +4242,13 @@ static void ozone_update_content_metadata(ozone_handle_t *ozone)
core_label = menu_st->thumbnail_path_data->content_core_name; 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), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_CORE),
sizeof(ozone->selection_core_name)); sizeof(ozone->selection_core_name));
ozone->selection_core_name[ _len] = ' '; _len += strlcpy(ozone->selection_core_name + _len, " ",
ozone->selection_core_name[++_len] = '\0'; sizeof(ozone->selection_core_name) - _len);
strlcpy(ozone->selection_core_name + _len, core_label, sizeof(ozone->selection_core_name) - _len); strlcpy(ozone->selection_core_name + _len, core_label,
sizeof(ozone->selection_core_name) - _len);
if (!scroll_content_metadata) if (!scroll_content_metadata)
linebreak_after_colon(&ozone->selection_core_name); linebreak_after_colon(&ozone->selection_core_name);
@ -4290,20 +4291,18 @@ static void ozone_update_content_metadata(ozone_handle_t *ozone)
else else
{ {
const char *disabled_str = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DISABLED); const char *disabled_str = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DISABLED);
size_t _len = size_t _len = strlcpy(ozone->selection_playtime,
strlcpy(ozone->selection_playtime,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_RUNTIME), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_RUNTIME),
sizeof(ozone->selection_playtime)); sizeof(ozone->selection_playtime));
ozone->selection_playtime[ _len] = ' '; _len += strlcpy(ozone->selection_playtime + _len, " ",
ozone->selection_playtime[++_len] = '\0'; sizeof(ozone->selection_playtime) - _len);
strlcpy(ozone->selection_playtime + _len, disabled_str, sizeof(ozone->selection_playtime) - _len); strlcpy(ozone->selection_playtime + _len, disabled_str, sizeof(ozone->selection_playtime) - _len);
_len = _len = strlcpy(ozone->selection_lastplayed,
strlcpy(ozone->selection_lastplayed,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED),
sizeof(ozone->selection_lastplayed)); sizeof(ozone->selection_lastplayed));
ozone->selection_lastplayed[ _len] = ' '; _len += strlcpy(ozone->selection_lastplayed + _len, " ",
ozone->selection_lastplayed[++_len] = '\0'; sizeof(ozone->selection_lastplayed) - _len);
strlcpy(ozone->selection_lastplayed + _len, disabled_str, sizeof(ozone->selection_lastplayed) - _len); strlcpy(ozone->selection_lastplayed + _len, disabled_str, sizeof(ozone->selection_lastplayed) - _len);
} }

View File

@ -1649,9 +1649,9 @@ static void rgui_fill_rect(
* this function is frequently used to fill large areas. * this function is frequently used to fill large areas.
* We therefore gain significant performance benefits * We therefore gain significant performance benefits
* from using memcpy() tricks... */ * from using memcpy() tricks... */
unsigned x_end = (x_end_i <= fb_width) ? x_end_i : fb_width; 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; unsigned y_end = (y_end_i <= fb_height) ? y_end_i : fb_height;
size_t x_size = (x_end - x_start) * sizeof(uint16_t); size_t x_size = (x_end - x_start) * sizeof(uint16_t);
/* Sanity check */ /* Sanity check */
if (x_size == 0) if (x_size == 0)
@ -4962,17 +4962,14 @@ static bool gfx_thumbnail_get_label(
return true; return true;
} }
static void rgui_render( static void rgui_render(void *data, unsigned width, unsigned height,
void *data,
unsigned width,
unsigned height,
bool is_idle) bool is_idle)
{ {
gfx_animation_ctx_ticker_t ticker;
gfx_animation_ctx_ticker_smooth_t ticker_smooth;
unsigned x, y; unsigned x, y;
size_t i, end, fb_pitch, old_start, new_start;
unsigned fb_width, fb_height; 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 bool display_kb = false;
static const char* const static const char* const
ticker_spacer = RGUI_TICKER_SPACER; ticker_spacer = RGUI_TICKER_SPACER;
@ -5288,11 +5285,11 @@ static void rgui_render(
else else
{ {
/* Render usual text */ /* Render usual text */
size_t selection = menu_st->selection_ptr;
size_t title_max_len;
size_t title_len;
unsigned title_x; unsigned title_x;
size_t title_len;
size_t title_max_len;
char title_buf[NAME_MAX_LENGTH]; 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 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 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); unsigned timedate_x = term_end_x - (5 * rgui->font_width_stride);
@ -7458,16 +7455,12 @@ static int rgui_environ(
/* Forward declaration */ /* Forward declaration */
static int rgui_menu_entry_action( static int rgui_menu_entry_action(
void *userdata, void *userdata, menu_entry_t *entry,
menu_entry_t *entry, size_t i, enum menu_action action);
size_t i,
enum menu_action action);
static int rgui_pointer_up( static int rgui_pointer_up(
void *data, void *data,
unsigned x, unsigned x, unsigned y, unsigned ptr,
unsigned y,
unsigned ptr,
enum menu_input_pointer_gesture gesture, enum menu_input_pointer_gesture gesture,
menu_file_list_cbs_t *cbs, menu_file_list_cbs_t *cbs,
menu_entry_t *entry, menu_entry_t *entry,
@ -8156,10 +8149,8 @@ static enum menu_action rgui_parse_menu_entry_action(
/* Menu entry action callback */ /* Menu entry action callback */
static int rgui_menu_entry_action( static int rgui_menu_entry_action(
void *userdata, void *userdata, menu_entry_t *entry,
menu_entry_t *entry, size_t i, enum menu_action action)
size_t i,
enum menu_action action)
{ {
rgui_t *rgui = (rgui_t*)userdata; rgui_t *rgui = (rgui_t*)userdata;

View File

@ -345,7 +345,7 @@ typedef struct xmb_handle
video_font_raster_block_t raster_block2; video_font_raster_block_t raster_block2;
size_t (*word_wrap)( size_t (*word_wrap)(
char *dst, size_t dst_size, char *s, size_t len,
const char *src, size_t src_len, const char *src, size_t src_len,
int line_width, int wideglyph_width, unsigned max_lines); 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, dir_dynamic_wallpapers,
xmb->title_name, xmb->title_name,
sizeof(path)); sizeof(path));
strlcpy(path + _len, ".png", sizeof(path) - _len);
path[ _len] = '.';
path[++_len] = 'p';
path[++_len] = 'n';
path[++_len] = 'g';
path[++_len] = '\0';
} }
if (!string_is_empty(path) && path_is_valid(path)) 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); size_t bottom_fade_line_index = bottom_fade_line_offset % (lines.size + 1);
/* Is line valid? */ /* Is line valid? */
if (top_fade_line_index < lines.size) 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) 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; success = true;
@ -4596,7 +4595,8 @@ static int xmb_draw_item(
{ {
char entry_path[PATH_MAX_LENGTH]; char entry_path[PATH_MAX_LENGTH];
strlcpy(entry_path, entry.path, sizeof(entry_path)); 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)) if (!string_is_empty(entry_path))
strlcpy(entry.path, entry_path, sizeof(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 */ /* Use alternative title if available */
strlcpy(title_truncated, 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)); sizeof(title_truncated));
if (!vertical_fade_factor && selection > 1) if (!vertical_fade_factor && selection > 1)

View File

@ -99,8 +99,8 @@ static void contentless_cores_free_info_entries(
static void contentless_cores_init_info_entries( static void contentless_cores_init_info_entries(
contentless_cores_state_t *state) contentless_cores_state_t *state)
{ {
core_info_list_t *core_info_list = NULL;
size_t i; size_t i;
core_info_list_t *core_info_list = NULL;
if (!state) if (!state)
return; return;
@ -207,8 +207,8 @@ void menu_contentless_cores_get_info(const char *core_id,
void menu_contentless_cores_flush_runtime(void) void menu_contentless_cores_flush_runtime(void)
{ {
contentless_cores_state_t *state = contentless_cores_state;
size_t i, cap; size_t i, cap;
contentless_cores_state_t *state = contentless_cores_state;
if (!state || !state->info_entries) if (!state || !state->info_entries)
return; return;

View File

@ -833,7 +833,9 @@ static int menu_displaylist_parse_core_info(
/* Show the path that was checked */ /* Show the path that was checked */
#ifdef IOS #ifdef IOS
shortened_path[0] = '\0'; 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), snprintf(tmp, sizeof(tmp),
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_FIRMWARE_PATH), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_FIRMWARE_PATH),
shortened_path); shortened_path);
@ -887,7 +889,9 @@ static int menu_displaylist_parse_core_info(
core_info_list_hide[j] = true; core_info_list_hide[j] = true;
__len = strlcpy(tmp, "- ", sizeof(tmp)); __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, "", if (menu_entries_append(list, tmp, "",
MENU_ENUM_LABEL_CORE_INFO_ENTRY, MENU_ENUM_LABEL_CORE_INFO_ENTRY,
@ -925,7 +929,8 @@ static int menu_displaylist_parse_core_info(
tmp[++_len] = '\0'; tmp[++_len] = '\0';
#if IOS #if IOS
shortened_path[0] = '\0'; 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); strlcpy(tmp + _len, shortened_path, sizeof(tmp) - _len);
#else #else
strlcpy(tmp + _len, core_path, sizeof(tmp) - _len); 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 *label,
const char *actual_string, const char *actual_string,
const char *path, const char *path,
size_t path_len,
file_list_t *list) file_list_t *list)
{ {
char tmp[128]; char tmp[128];
@ -2679,9 +2683,7 @@ static int create_string_list_rdb_entry_string(
static int create_string_list_rdb_entry_int( static int create_string_list_rdb_entry_int(
enum msg_hash_enums enum_idx, enum msg_hash_enums enum_idx,
const char *desc, const char *label, const char *desc, const char *label,
int actual_int, int actual_int, const char *path, file_list_t *list)
const char *path, size_t path_len,
file_list_t *list)
{ {
size_t _len; size_t _len;
char str[16]; char str[16];
@ -2733,7 +2735,6 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
menu_displaylist_info_t *info) menu_displaylist_info_t *info)
{ {
size_t _len; size_t _len;
size_t path_len;
unsigned i, j, k; unsigned i, j, k;
char query[256]; char query[256];
char path_base[NAME_MAX_LENGTH]; 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); 0, 0, 0, NULL);
} }
path_len = strlen(info->path);
if (db_info_entry->publisher) if (db_info_entry->publisher)
{ {
if (create_string_list_rdb_entry_string( if (create_string_list_rdb_entry_string(
MENU_ENUM_LABEL_RDB_ENTRY_PUBLISHER, MENU_ENUM_LABEL_RDB_ENTRY_PUBLISHER,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_PUBLISHER), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_PUBLISHER),
msg_hash_to_str(MENU_ENUM_LABEL_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; goto error;
} }
@ -2900,7 +2899,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
MENU_ENUM_LABEL_RDB_ENTRY_CATEGORY, MENU_ENUM_LABEL_RDB_ENTRY_CATEGORY,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_CATEGORY), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_CATEGORY),
msg_hash_to_str(MENU_ENUM_LABEL_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; goto error;
} }
@ -2910,7 +2909,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
MENU_ENUM_LABEL_RDB_ENTRY_LANGUAGE, MENU_ENUM_LABEL_RDB_ENTRY_LANGUAGE,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_LANGUAGE), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_LANGUAGE),
msg_hash_to_str(MENU_ENUM_LABEL_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; goto error;
} }
@ -2920,7 +2919,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
MENU_ENUM_LABEL_RDB_ENTRY_REGION, MENU_ENUM_LABEL_RDB_ENTRY_REGION,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_REGION), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_REGION),
msg_hash_to_str(MENU_ENUM_LABEL_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; goto error;
} }
@ -2930,7 +2929,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
MENU_ENUM_LABEL_RDB_ENTRY_SCORE, MENU_ENUM_LABEL_RDB_ENTRY_SCORE,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_SCORE), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_SCORE),
msg_hash_to_str(MENU_ENUM_LABEL_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; goto error;
} }
@ -2940,7 +2939,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
MENU_ENUM_LABEL_RDB_ENTRY_MEDIA, MENU_ENUM_LABEL_RDB_ENTRY_MEDIA,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_MEDIA), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_MEDIA),
msg_hash_to_str(MENU_ENUM_LABEL_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; goto error;
} }
@ -2950,7 +2949,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
MENU_ENUM_LABEL_RDB_ENTRY_CONTROLS, MENU_ENUM_LABEL_RDB_ENTRY_CONTROLS,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_CONTROLS), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_CONTROLS),
msg_hash_to_str(MENU_ENUM_LABEL_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; goto error;
} }
@ -2960,7 +2959,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
MENU_ENUM_LABEL_RDB_ENTRY_ARTSTYLE, MENU_ENUM_LABEL_RDB_ENTRY_ARTSTYLE,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_ARTSTYLE), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_ARTSTYLE),
msg_hash_to_str(MENU_ENUM_LABEL_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; goto error;
} }
@ -2970,7 +2969,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
MENU_ENUM_LABEL_RDB_ENTRY_GAMEPLAY, MENU_ENUM_LABEL_RDB_ENTRY_GAMEPLAY,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_GAMEPLAY), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_GAMEPLAY),
msg_hash_to_str(MENU_ENUM_LABEL_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; goto error;
} }
@ -2980,7 +2979,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
MENU_ENUM_LABEL_RDB_ENTRY_NARRATIVE, MENU_ENUM_LABEL_RDB_ENTRY_NARRATIVE,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_NARRATIVE), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_NARRATIVE),
msg_hash_to_str(MENU_ENUM_LABEL_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; goto error;
} }
@ -2990,7 +2989,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
MENU_ENUM_LABEL_RDB_ENTRY_PACING, MENU_ENUM_LABEL_RDB_ENTRY_PACING,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_PACING), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_PACING),
msg_hash_to_str(MENU_ENUM_LABEL_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; goto error;
} }
@ -3000,7 +2999,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
MENU_ENUM_LABEL_RDB_ENTRY_PERSPECTIVE, MENU_ENUM_LABEL_RDB_ENTRY_PERSPECTIVE,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_PERSPECTIVE), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_PERSPECTIVE),
msg_hash_to_str(MENU_ENUM_LABEL_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; goto error;
} }
@ -3010,7 +3009,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
MENU_ENUM_LABEL_RDB_ENTRY_SETTING, MENU_ENUM_LABEL_RDB_ENTRY_SETTING,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_SETTING), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_SETTING),
msg_hash_to_str(MENU_ENUM_LABEL_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; goto error;
} }
@ -3020,7 +3019,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
MENU_ENUM_LABEL_RDB_ENTRY_VISUAL, MENU_ENUM_LABEL_RDB_ENTRY_VISUAL,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_VISUAL), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_VISUAL),
msg_hash_to_str(MENU_ENUM_LABEL_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; goto error;
} }
@ -3030,7 +3029,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
MENU_ENUM_LABEL_RDB_ENTRY_VEHICULAR, MENU_ENUM_LABEL_RDB_ENTRY_VEHICULAR,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_VEHICULAR), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_VEHICULAR),
msg_hash_to_str(MENU_ENUM_LABEL_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; goto error;
} }
@ -3048,7 +3047,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
MENU_ENUM_LABEL_RDB_ENTRY_DEVELOPER, MENU_ENUM_LABEL_RDB_ENTRY_DEVELOPER,
val_rdb_entry_dev, rdb_entry_dev, val_rdb_entry_dev, rdb_entry_dev,
db_info_entry->developer->elems[k].data, db_info_entry->developer->elems[k].data,
info->path, path_len, info->list) == -1) info->path, info->list) == -1)
goto error; goto error;
} }
} }
@ -3060,7 +3059,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
MENU_ENUM_LABEL_RDB_ENTRY_ORIGIN, MENU_ENUM_LABEL_RDB_ENTRY_ORIGIN,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_ORIGIN), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_ORIGIN),
msg_hash_to_str(MENU_ENUM_LABEL_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; goto error;
} }
@ -3070,7 +3069,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
MENU_ENUM_LABEL_RDB_ENTRY_FRANCHISE, MENU_ENUM_LABEL_RDB_ENTRY_FRANCHISE,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_FRANCHISE), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_FRANCHISE),
msg_hash_to_str(MENU_ENUM_LABEL_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; goto error;
} }
@ -3080,8 +3079,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
MENU_ENUM_LABEL_RDB_ENTRY_MAX_USERS, 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_VALUE_INPUT_MAX_USERS),
msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_MAX_USERS), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_MAX_USERS),
db_info_entry->max_users, db_info_entry->max_users, info->path, info->list) == -1)
info->path, path_len, info->list) == -1)
goto error; goto error;
} }
@ -3091,8 +3089,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
MENU_ENUM_LABEL_RDB_ENTRY_TGDB_RATING, 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_VALUE_RDB_ENTRY_TGDB_RATING),
msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_TGDB_RATING), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_TGDB_RATING),
db_info_entry->tgdb_rating, db_info_entry->tgdb_rating, info->path, info->list) == -1)
info->path, path_len, info->list) == -1)
goto error; 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, 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_VALUE_RDB_ENTRY_FAMITSU_MAGAZINE_RATING),
msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_FAMITSU_MAGAZINE_RATING), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_FAMITSU_MAGAZINE_RATING),
db_info_entry->famitsu_magazine_rating, db_info_entry->famitsu_magazine_rating, info->path, info->list) == -1)
info->path, path_len, info->list) == -1)
goto error; 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, 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_VALUE_RDB_ENTRY_EDGE_MAGAZINE_REVIEW),
msg_hash_to_str(MENU_ENUM_LABEL_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; 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, 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_VALUE_RDB_ENTRY_EDGE_MAGAZINE_RATING),
msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_EDGE_MAGAZINE_RATING), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_EDGE_MAGAZINE_RATING),
db_info_entry->edge_magazine_rating, db_info_entry->edge_magazine_rating, info->path, info->list) == -1)
info->path, path_len, info->list) == -1)
goto error; 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, 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_VALUE_RDB_ENTRY_EDGE_MAGAZINE_ISSUE),
msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_EDGE_MAGAZINE_ISSUE), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_EDGE_MAGAZINE_ISSUE),
db_info_entry->edge_magazine_issue, db_info_entry->edge_magazine_issue, info->path, info->list) == -1)
info->path, path_len, info->list) == -1)
goto error; goto error;
} }
@ -3145,8 +3139,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
MENU_ENUM_LABEL_RDB_ENTRY_RELEASE_MONTH, 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_VALUE_RDB_ENTRY_RELEASE_MONTH),
msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_RELEASE_MONTH), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_RELEASE_MONTH),
db_info_entry->releasemonth, db_info_entry->releasemonth, info->path, info->list) == -1)
info->path, path_len, info->list) == -1)
goto error; goto error;
} }
@ -3156,8 +3149,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
MENU_ENUM_LABEL_RDB_ENTRY_RELEASE_YEAR, 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_VALUE_RDB_ENTRY_RELEASE_YEAR),
msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_RELEASE_YEAR), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_RELEASE_YEAR),
db_info_entry->releaseyear, db_info_entry->releaseyear, info->path, info->list) == -1)
info->path, path_len, info->list) == -1)
goto error; goto error;
} }
@ -3167,7 +3159,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
MENU_ENUM_LABEL_RDB_ENTRY_BBFC_RATING, 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_VALUE_RDB_ENTRY_BBFC_RATING),
msg_hash_to_str(MENU_ENUM_LABEL_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; goto error;
} }
@ -3177,7 +3169,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
MENU_ENUM_LABEL_RDB_ENTRY_ESRB_RATING, 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_VALUE_RDB_ENTRY_ESRB_RATING),
msg_hash_to_str(MENU_ENUM_LABEL_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; goto error;
} }
@ -3187,7 +3179,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
MENU_ENUM_LABEL_RDB_ENTRY_ELSPA_RATING, 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_VALUE_RDB_ENTRY_ELSPA_RATING),
msg_hash_to_str(MENU_ENUM_LABEL_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; goto error;
} }
@ -3197,7 +3189,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
MENU_ENUM_LABEL_RDB_ENTRY_PEGI_RATING, 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_VALUE_RDB_ENTRY_PEGI_RATING),
msg_hash_to_str(MENU_ENUM_LABEL_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; goto error;
} }
@ -3207,7 +3199,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
MENU_ENUM_LABEL_RDB_ENTRY_ENHANCEMENT_HW, 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_VALUE_RDB_ENTRY_ENHANCEMENT_HW),
msg_hash_to_str(MENU_ENUM_LABEL_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; goto error;
} }
@ -3217,7 +3209,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
MENU_ENUM_LABEL_RDB_ENTRY_CERO_RATING, 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_VALUE_RDB_ENTRY_CERO_RATING),
msg_hash_to_str(MENU_ENUM_LABEL_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; goto error;
} }
@ -3227,7 +3219,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
MENU_ENUM_LABEL_RDB_ENTRY_SERIAL, MENU_ENUM_LABEL_RDB_ENTRY_SERIAL,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_SERIAL), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_SERIAL),
msg_hash_to_str(MENU_ENUM_LABEL_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; goto error;
} }
@ -3237,7 +3229,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
MENU_ENUM_LABEL_RDB_ENTRY_ANALOG, MENU_ENUM_LABEL_RDB_ENTRY_ANALOG,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_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_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) info->list) == -1)
goto error; goto error;
} }
@ -3248,7 +3240,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
MENU_ENUM_LABEL_RDB_ENTRY_RUMBLE, MENU_ENUM_LABEL_RDB_ENTRY_RUMBLE,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_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_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) info->list) == -1)
goto error; goto error;
} }
@ -3259,7 +3251,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
MENU_ENUM_LABEL_RDB_ENTRY_COOP, MENU_ENUM_LABEL_RDB_ENTRY_COOP,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_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_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) info->list) == -1)
goto error; goto error;
} }
@ -3270,7 +3262,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
MENU_ENUM_LABEL_RDB_ENTRY_ACHIEVEMENTS, MENU_ENUM_LABEL_RDB_ENTRY_ACHIEVEMENTS,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_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_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) info->list) == -1)
goto error; goto error;
} }
@ -3281,7 +3273,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
MENU_ENUM_LABEL_RDB_ENTRY_CONSOLE_EXCLUSIVE, 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_VALUE_RDB_ENTRY_CONSOLE_EXCLUSIVE),
msg_hash_to_str(MENU_ENUM_LABEL_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) info->list) == -1)
goto error; goto error;
} }
@ -3292,7 +3284,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
MENU_ENUM_LABEL_RDB_ENTRY_PLATFORM_EXCLUSIVE, 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_VALUE_RDB_ENTRY_PLATFORM_EXCLUSIVE),
msg_hash_to_str(MENU_ENUM_LABEL_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) info->list) == -1)
goto error; goto error;
} }
@ -3306,8 +3298,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
MENU_ENUM_LABEL_RDB_ENTRY_CRC32, MENU_ENUM_LABEL_RDB_ENTRY_CRC32,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_CRC32), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_CRC32),
msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_CRC32), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_CRC32),
crc_str, crc_str, info->path, info->list) == -1)
info->path, path_len, info->list) == -1)
goto error; goto error;
} }
@ -3317,8 +3308,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
MENU_ENUM_LABEL_RDB_ENTRY_SHA1, MENU_ENUM_LABEL_RDB_ENTRY_SHA1,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_SHA1), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_SHA1),
msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_SHA1), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_SHA1),
db_info_entry->sha1, db_info_entry->sha1, info->path, info->list) == -1)
info->path, path_len, info->list) == -1)
goto error; goto error;
} }
@ -3328,8 +3318,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
MENU_ENUM_LABEL_RDB_ENTRY_MD5, MENU_ENUM_LABEL_RDB_ENTRY_MD5,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_MD5), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_MD5),
msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_MD5), msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_MD5),
db_info_entry->md5, db_info_entry->md5, info->path, info->list) == -1)
info->path, path_len, info->list) == -1)
goto error; goto error;
} }
} }
@ -6560,7 +6549,7 @@ static int menu_displaylist_parse_disc_info(file_list_t *info_list,
unsigned type) unsigned type)
{ {
unsigned i; unsigned i;
unsigned count = 0; unsigned count = 0;
struct string_list *list = cdrom_get_available_drives(); struct string_list *list = cdrom_get_available_drives();
const char *msg_drive_number = msg_hash_to_str(MSG_DRIVE_NUMBER); 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( static unsigned menu_displaylist_populate_subsystem(
const struct retro_subsystem_info* subsystem, const struct retro_subsystem_info* subsystem,
settings_t *settings, settings_t *settings, file_list_t *list)
file_list_t *list)
{ {
char star_char[16]; char star_char[16];
unsigned count = 0; unsigned count = 0;

View File

@ -542,13 +542,13 @@ static menu_search_terms_t *menu_entries_search_get_terms_internal(void)
* 'idx' to the matching list entry index. */ * 'idx' to the matching list entry index. */
bool menu_entries_list_search(const char *needle, size_t *idx) bool menu_entries_list_search(const char *needle, size_t *idx)
{ {
size_t i;
struct menu_state *menu_st = &menu_driver_state; struct menu_state *menu_st = &menu_driver_state;
menu_list_t *menu_list = menu_st->entries.list; menu_list_t *menu_list = menu_st->entries.list;
file_list_t *list = MENU_LIST_GET_SELECTION(menu_list, (unsigned)0); file_list_t *list = MENU_LIST_GET_SELECTION(menu_list, (unsigned)0);
bool match_found = false; bool match_found = false;
bool char_search = false; bool char_search = false;
char needle_char = 0; char needle_char = 0;
size_t i;
if ( !list if ( !list
|| string_is_empty(needle) || 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 /* Display the date and time - time_mode will influence how
* the time representation will look like. * 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 /* Storage container for current menu datetime
* representation string */ * 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 */ /* 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; int percent = 0;
struct menu_state *menu_st = &menu_driver_state; struct menu_state *menu_st = &menu_driver_state;
@ -1254,12 +1256,9 @@ static void menu_list_free_list(
file_list_free(list); file_list_free(list);
} }
static void menu_list_pop_stack( static void menu_list_pop_stack(const menu_ctx_driver_t *menu_driver_ctx,
const menu_ctx_driver_t *menu_driver_ctx, void *menu_userdata, menu_list_t *list,
void *menu_userdata, size_t idx, size_t *directory_ptr)
menu_list_t *list,
size_t idx,
size_t *directory_ptr)
{ {
file_list_t *menu_list = MENU_LIST_GET(list, (unsigned)idx); 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( static void menu_list_flush_stack(
const menu_ctx_driver_t *menu_driver_ctx, const menu_ctx_driver_t *menu_driver_ctx,
void *menu_userdata, void *menu_userdata, struct menu_state *menu_st,
struct menu_state *menu_st,
menu_list_t *list, menu_list_t *list,
size_t idx, const char *needle, unsigned final_type) size_t idx, const char *needle, unsigned final_type)
{ {
@ -1339,8 +1337,7 @@ static void menu_list_flush_stack(
} }
} }
static void menu_list_free( static void menu_list_free(const menu_ctx_driver_t *menu_driver_ctx,
const menu_ctx_driver_t *menu_driver_ctx,
menu_list_t *menu_list) menu_list_t *menu_list)
{ {
if (!menu_list) if (!menu_list)
@ -1431,12 +1428,9 @@ error:
return NULL; return NULL;
} }
static int menu_input_key_bind_set_mode_common( static int menu_input_key_bind_set_mode_common(struct menu_state *menu_st,
struct menu_state *menu_st, struct menu_bind_state *binds, enum menu_input_binds_ctl_state state,
struct menu_bind_state *binds, rarch_setting_t *setting, settings_t *settings)
enum menu_input_binds_ctl_state state,
rarch_setting_t *setting,
settings_t *settings)
{ {
switch (state) switch (state)
{ {

View File

@ -314,7 +314,7 @@ static void explore_add_unique_string(
for (p = str + 1;; p++) for (p = str + 1;; p++)
{ {
size_t _len = 0; size_t _len = 0;
uint32_t hash = 0; uint32_t hash = 0;
explore_string_t* entry = NULL; explore_string_t* entry = NULL;

View File

@ -298,9 +298,9 @@ static INLINE void menu_screensaver_set_dimensions(
static bool menu_screensaver_init_effect(menu_screensaver_t *screensaver) static bool menu_screensaver_init_effect(menu_screensaver_t *screensaver)
{ {
size_t i;
unsigned width; unsigned width;
unsigned height; unsigned height;
size_t i;
/* Create particle array, if required */ /* Create particle array, if required */
if (!screensaver->particles) if (!screensaver->particles)
@ -311,7 +311,7 @@ static bool menu_screensaver_init_effect(menu_screensaver_t *screensaver)
if (!screensaver->particles) if (!screensaver->particles)
return false; return false;
} }
width = screensaver->last_width; width = screensaver->last_width;
height = screensaver->last_height; height = screensaver->last_height;
@ -518,12 +518,12 @@ void menu_screensaver_iterate(
uint32_t particle_tint, unsigned width, unsigned height, uint32_t particle_tint, unsigned width, unsigned height,
const char *dir_assets) const char *dir_assets)
{ {
float base_particle_size; size_t i;
uint32_t tint_r; uint32_t tint_r;
uint32_t tint_g; uint32_t tint_g;
uint32_t tint_b; uint32_t tint_b;
float base_particle_size;
float global_speed_factor; float global_speed_factor;
size_t i;
if (!screensaver) if (!screensaver)
return; return;
@ -532,9 +532,9 @@ void menu_screensaver_iterate(
if (!menu_screensaver_update_state( if (!menu_screensaver_update_state(
screensaver, p_disp, screensaver, p_disp,
effect, particle_tint, effect, particle_tint,
width, height, dir_assets) || width, height, dir_assets)
(screensaver->effect == MENU_SCREENSAVER_BLANK) || || (screensaver->effect == MENU_SCREENSAVER_BLANK)
!screensaver->particles) || !screensaver->particles)
return; return;
base_particle_size = screensaver->particle_scale * screensaver->font_size; base_particle_size = screensaver->particle_scale * screensaver->font_size;
@ -544,7 +544,7 @@ void menu_screensaver_iterate(
/* Set global animation speed */ /* Set global animation speed */
global_speed_factor = p_anim->delta_time / MENU_SS_EFFECT_PERIOD; 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; global_speed_factor *= effect_speed;
/* Update particle array */ /* Update particle array */
@ -784,9 +784,9 @@ void menu_screensaver_frame(menu_screensaver_t *screensaver,
&& font && font
&& screensaver->particles) && screensaver->particles)
{ {
size_t i;
float y_centre_offset = screensaver->font_data.y_centre_offset; float y_centre_offset = screensaver->font_data.y_centre_offset;
float particle_scale = screensaver->particle_scale; float particle_scale = screensaver->particle_scale;
size_t i;
/* Bind font */ /* Bind font */
font_driver_bind_block(font, &screensaver->font_data.raster_block); font_driver_bind_block(font, &screensaver->font_data.raster_block);

View File

@ -2326,7 +2326,7 @@ static void config_float(
static void config_path( static void config_path(
rarch_setting_t **list, rarch_setting_t **list,
rarch_setting_info_t *list_info, 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 name_enum_idx,
enum msg_hash_enums SHORT_enum_idx, enum msg_hash_enums SHORT_enum_idx,
const char *default_value, const char *default_value,
@ -2338,7 +2338,7 @@ static void config_path(
(*list)[list_info->index++] = setting_string_setting(ST_PATH, (*list)[list_info->index++] = setting_string_setting(ST_PATH,
msg_hash_to_str(name_enum_idx), msg_hash_to_str(name_enum_idx),
msg_hash_to_str(SHORT_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, group_info->name, subgroup_info->name, parent_group,
change_handler, read_handler, change_handler, read_handler,
false); false);
@ -2351,7 +2351,7 @@ static void config_path(
static void config_dir( static void config_dir(
rarch_setting_t **list, rarch_setting_t **list,
rarch_setting_info_t *list_info, 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 name_enum_idx,
enum msg_hash_enums SHORT_enum_idx, enum msg_hash_enums SHORT_enum_idx,
const char *default_value, const char *default_value,
@ -2364,7 +2364,7 @@ static void config_dir(
(*list)[list_info->index++] = setting_string_setting(ST_DIR, (*list)[list_info->index++] = setting_string_setting(ST_DIR,
msg_hash_to_str(name_enum_idx), msg_hash_to_str(name_enum_idx),
msg_hash_to_str(SHORT_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), msg_hash_to_str(empty_enum_idx),
group_info->name, subgroup_info->name, parent_group, group_info->name, subgroup_info->name, parent_group,
change_handler, read_handler, change_handler, read_handler,
@ -2382,7 +2382,7 @@ static void config_dir(
static void config_string( static void config_string(
rarch_setting_t **list, rarch_setting_t **list,
rarch_setting_info_t *list_info, 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 name_enum_idx,
enum msg_hash_enums SHORT_enum_idx, enum msg_hash_enums SHORT_enum_idx,
const char *default_value, const char *default_value,
@ -2394,7 +2394,7 @@ static void config_string(
(*list)[list_info->index++] = setting_string_setting(ST_STRING, (*list)[list_info->index++] = setting_string_setting(ST_STRING,
msg_hash_to_str(name_enum_idx), msg_hash_to_str(name_enum_idx),
msg_hash_to_str(SHORT_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, group_info->name, subgroup_info->name, parent_group,
change_handler, read_handler, false); change_handler, read_handler, false);
MENU_SETTINGS_LIST_CURRENT_ADD_ENUM_IDX_PTR(list, list_info, name_enum_idx); 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( static void config_string_alt(
rarch_setting_t **list, rarch_setting_t **list,
rarch_setting_info_t *list_info, rarch_setting_info_t *list_info,
char *target, size_t len, char *s, size_t len,
char *label, char *label,
char* shortname, char* shortname,
const char *default_value, const char *default_value,
@ -2414,9 +2414,8 @@ static void config_string_alt(
change_handler_t change_handler, change_handler_t read_handler) change_handler_t change_handler, change_handler_t read_handler)
{ {
(*list)[list_info->index++] = setting_string_setting(ST_STRING, (*list)[list_info->index++] = setting_string_setting(ST_STRING,
label, label, shortname,
shortname, s, (unsigned)len, default_value, "",
target, (unsigned)len, default_value, "",
group_info->name, subgroup_info->name, parent_group, group_info->name, subgroup_info->name, parent_group,
change_handler, read_handler, true); change_handler, read_handler, true);
} }
@ -2424,7 +2423,7 @@ static void config_string_alt(
static void config_string_options( static void config_string_options(
rarch_setting_t **list, rarch_setting_t **list,
rarch_setting_info_t *list_info, 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 name_enum_idx,
enum msg_hash_enums SHORT_enum_idx, enum msg_hash_enums SHORT_enum_idx,
const char *default_value, const char *values, const char *default_value, const char *values,
@ -2437,7 +2436,7 @@ static void config_string_options(
ST_STRING_OPTIONS, ST_STRING_OPTIONS,
msg_hash_to_str(name_enum_idx), msg_hash_to_str(name_enum_idx),
msg_hash_to_str(SHORT_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, group_info->name, subgroup_info->name, parent_group,
change_handler, read_handler, false); change_handler, read_handler, false);
(*list)[list_info->index - 1].ui_type = ST_UI_TYPE_STRING_COMBOBOX; (*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( static void config_bind_alt(
rarch_setting_t **list, rarch_setting_t **list,
rarch_setting_info_t *list_info, rarch_setting_info_t *list_info,
struct retro_keybind *target, struct retro_keybind *s,
uint32_t player, uint32_t player_offset, uint32_t player, uint32_t player_offset,
const char *name, const char *SHORT, const char *name, const char *SHORT,
const struct retro_keybind *default_value, const struct retro_keybind *default_value,
@ -2460,7 +2459,7 @@ static void config_bind_alt(
rarch_setting_group_info_t *subgroup_info, rarch_setting_group_info_t *subgroup_info,
const char *parent_group) 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, player, player_offset, default_value,
group_info->name, subgroup_info->name, parent_group, group_info->name, subgroup_info->name, parent_group,
true); true);
@ -2600,12 +2599,12 @@ static int setting_action_ok_bind_defaults(
if (!setting) if (!setting)
return -1; return -1;
target = &input_config_binds[setting->index_offset][0]; target = &input_config_binds[setting->index_offset][0];
def_binds = (setting->index_offset) def_binds = (setting->index_offset)
? retro_keybinds_rest ? retro_keybinds_rest
: retro_keybinds_1; : retro_keybinds_1;
binds->begin = MENU_SETTINGS_BIND_BEGIN; binds->begin = MENU_SETTINGS_BIND_BEGIN;
binds->last = MENU_SETTINGS_BIND_LAST; binds->last = MENU_SETTINGS_BIND_LAST;
for ( i = MENU_SETTINGS_BIND_BEGIN; for ( i = MENU_SETTINGS_BIND_BEGIN;
i <= MENU_SETTINGS_BIND_LAST; i++, target++) 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) #if defined(HAVE_CHEEVOS) || defined(HAVE_CLOUDSYNC)
static void setting_get_string_representation_password( static void setting_get_string_representation_password(
rarch_setting_t *setting, rarch_setting_t *setting, char *s, size_t len)
char *s, size_t len)
{ {
if (!setting) if (!setting)
return; 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( static void setting_get_string_representation_uint_ai_service_lang(
rarch_setting_t *setting, rarch_setting_t *setting, char *s, size_t len)
char *s, size_t len)
{ {
enum msg_hash_enums enum_idx = MSG_UNKNOWN; enum msg_hash_enums enum_idx = MSG_UNKNOWN;
if (!setting) if (!setting)
@ -3311,8 +3308,7 @@ static void setting_get_string_representation_uint_ai_service_lang(
#endif #endif
static void setting_get_string_representation_uint_menu_thumbnails( static void setting_get_string_representation_uint_menu_thumbnails(
rarch_setting_t *setting, rarch_setting_t *setting, char *s, size_t len)
char *s, size_t len)
{ {
if (!setting) if (!setting)
return; return;
@ -3347,8 +3343,7 @@ static void setting_get_string_representation_uint_menu_thumbnails(
} }
static void setting_get_string_representation_uint_menu_left_thumbnails( static void setting_get_string_representation_uint_menu_left_thumbnails(
rarch_setting_t *setting, rarch_setting_t *setting, char *s, size_t len)
char *s, size_t len)
{ {
if (!setting) if (!setting)
return; 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( static void setting_get_string_representation_uint_menu_icon_thumbnails(
rarch_setting_t *setting, rarch_setting_t *setting, char *s, size_t len)
char *s, size_t len)
{ {
if (!setting) if (!setting)
return; 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) static void setting_set_string_representation_timedate_date_separator(char *s)
{ {
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
unsigned menu_timedate_date_separator = settings ? unsigned menu_timedate_date_separator = settings
settings->uints.menu_timedate_date_separator : ? settings->uints.menu_timedate_date_separator
MENU_TIMEDATE_DATE_SEPARATOR_HYPHEN; : MENU_TIMEDATE_DATE_SEPARATOR_HYPHEN;
switch (menu_timedate_date_separator) 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( static void setting_get_string_representation_uint_menu_timedate_style(
rarch_setting_t *setting, rarch_setting_t *setting, char *s, size_t len)
char *s, size_t len)
{ {
if (!setting) if (!setting)
return; 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( static void setting_get_string_representation_uint_menu_timedate_date_separator(
rarch_setting_t *setting, rarch_setting_t *setting, char *s, size_t len)
char *s, size_t len)
{ {
if (!setting) if (!setting)
return; 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( static void setting_get_string_representation_uint_menu_add_content_entry_display_type(
rarch_setting_t *setting, rarch_setting_t *setting, char *s, size_t len)
char *s, size_t len)
{ {
if (!setting) if (!setting)
return; 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( static void setting_get_string_representation_uint_menu_contentless_cores_display_type(
rarch_setting_t *setting, rarch_setting_t *setting, char *s, size_t len)
char *s, size_t len)
{ {
if (!setting) if (!setting)
return; 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( static void setting_get_string_representation_uint_rgui_menu_color_theme(
rarch_setting_t *setting, rarch_setting_t *setting, char *s, size_t len)
char *s, size_t len)
{ {
if (!setting) if (!setting)
return; 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( static void setting_get_string_representation_uint_rgui_thumbnail_scaler(
rarch_setting_t *setting, rarch_setting_t *setting, char *s, size_t len)
char *s, size_t len)
{ {
if (!setting) if (!setting)
return; 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( static void setting_get_string_representation_uint_rgui_internal_upscale_level(
rarch_setting_t *setting, rarch_setting_t *setting, char *s, size_t len)
char *s, size_t len)
{ {
if (!setting) if (!setting)
return; return;
@ -3990,8 +3977,7 @@ static void setting_get_string_representation_uint_rgui_internal_upscale_level(
#if !defined(DINGUX) #if !defined(DINGUX)
static void setting_get_string_representation_uint_rgui_aspect_ratio( static void setting_get_string_representation_uint_rgui_aspect_ratio(
rarch_setting_t *setting, rarch_setting_t *setting, char *s, size_t len)
char *s, size_t len)
{ {
if (!setting) if (!setting)
return; 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( static void setting_get_string_representation_uint_rgui_aspect_ratio_lock(
rarch_setting_t *setting, rarch_setting_t *setting, char *s, size_t len)
char *s, size_t len)
{ {
if (!setting) if (!setting)
return; return;
@ -4112,8 +4097,7 @@ static void setting_get_string_representation_uint_rgui_aspect_ratio_lock(
#endif #endif
static void setting_get_string_representation_uint_rgui_particle_effect( static void setting_get_string_representation_uint_rgui_particle_effect(
rarch_setting_t *setting, rarch_setting_t *setting, char *s, size_t len)
char *s, size_t len)
{ {
if (!setting) if (!setting)
return; return;
@ -4161,8 +4145,7 @@ static void setting_get_string_representation_uint_rgui_particle_effect(
#ifdef HAVE_XMB #ifdef HAVE_XMB
static void setting_get_string_representation_uint_menu_xmb_animation_move_up_down( static void setting_get_string_representation_uint_menu_xmb_animation_move_up_down(
rarch_setting_t *setting, rarch_setting_t *setting, char *s, size_t len)
char *s, size_t len)
{ {
if (!setting) if (!setting)
return; 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( static void setting_get_string_representation_uint_menu_xmb_animation_opening_main_menu(
rarch_setting_t *setting, rarch_setting_t *setting, char *s, size_t len)
char *s, size_t len)
{ {
if (!setting) if (!setting)
return; 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( static void setting_get_string_representation_uint_menu_xmb_animation_horizontal_highlight(
rarch_setting_t *setting, rarch_setting_t *setting, char *s, size_t len)
char *s, size_t len)
{ {
if (!setting) if (!setting)
return; return;
@ -4228,8 +4209,7 @@ static void setting_get_string_representation_uint_menu_xmb_animation_horizontal
#endif #endif
static void setting_get_string_representation_uint_menu_ticker_type( static void setting_get_string_representation_uint_menu_ticker_type(
rarch_setting_t *setting, rarch_setting_t *setting, char *s, size_t len)
char *s, size_t len)
{ {
if (!setting) if (!setting)
return; return;
@ -4253,8 +4233,7 @@ static void setting_get_string_representation_uint_menu_ticker_type(
#ifdef HAVE_XMB #ifdef HAVE_XMB
static void setting_get_string_representation_uint_xmb_icon_theme( static void setting_get_string_representation_uint_xmb_icon_theme(
rarch_setting_t *setting, rarch_setting_t *setting, char *s, size_t len)
char *s, size_t len)
{ {
if (!setting) if (!setting)
return; return;
@ -4313,8 +4292,7 @@ static void setting_get_string_representation_uint_xmb_icon_theme(
} }
static void setting_get_string_representation_uint_xmb_layout( static void setting_get_string_representation_uint_xmb_layout(
rarch_setting_t *setting, rarch_setting_t *setting, char *s, size_t len)
char *s, size_t len)
{ {
if (!setting) if (!setting)
return; 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( static void setting_get_string_representation_uint_xmb_menu_color_theme(
rarch_setting_t *setting, rarch_setting_t *setting, char *s, size_t len)
char *s, size_t len)
{ {
if (!setting) if (!setting)
return; return;
@ -4468,8 +4445,7 @@ static void setting_get_string_representation_uint_xmb_menu_color_theme(
#ifdef HAVE_MATERIALUI #ifdef HAVE_MATERIALUI
static void setting_get_string_representation_uint_materialui_menu_color_theme( static void setting_get_string_representation_uint_materialui_menu_color_theme(
rarch_setting_t *setting, rarch_setting_t *setting, char *s, size_t len)
char *s, size_t len)
{ {
if (!setting) if (!setting)
return; 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( static void setting_get_string_representation_uint_materialui_menu_transition_animation(
rarch_setting_t *setting, rarch_setting_t *setting, char *s, size_t len)
char *s, size_t len)
{ {
if (!setting) if (!setting)
return; 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( static void setting_get_string_representation_uint_materialui_menu_thumbnail_view_portrait(
rarch_setting_t *setting, rarch_setting_t *setting, char *s, size_t len)
char *s, size_t len)
{ {
if (!setting) if (!setting)
return; 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( static void setting_get_string_representation_uint_materialui_menu_thumbnail_view_landscape(
rarch_setting_t *setting, rarch_setting_t *setting, char *s, size_t len)
char *s, size_t len)
{ {
if (!setting) if (!setting)
return; 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( static void setting_get_string_representation_uint_materialui_landscape_layout_optimization(
rarch_setting_t *setting, rarch_setting_t *setting, char *s, size_t len)
char *s, size_t len)
{ {
if (!setting) if (!setting)
return; return;
@ -4740,8 +4712,7 @@ static void setting_get_string_representation_uint_materialui_landscape_layout_o
#ifdef HAVE_OZONE #ifdef HAVE_OZONE
static void setting_get_string_representation_uint_ozone_menu_color_theme( static void setting_get_string_representation_uint_ozone_menu_color_theme(
rarch_setting_t *setting, rarch_setting_t *setting, char *s, size_t len)
char *s, size_t len)
{ {
if (!setting) if (!setting)
return; 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_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL)
#if defined(HAVE_XMB) && defined(HAVE_SHADERPIPELINE) #if defined(HAVE_XMB) && defined(HAVE_SHADERPIPELINE)
static void setting_get_string_representation_uint_xmb_shader_pipeline( static void setting_get_string_representation_uint_xmb_shader_pipeline(
rarch_setting_t *setting, rarch_setting_t *setting, char *s, size_t len)
char *s, size_t len)
{ {
if (!setting) if (!setting)
return; return;
@ -4875,8 +4845,7 @@ static void setting_get_string_representation_uint_xmb_shader_pipeline(
#ifdef HAVE_SCREENSHOTS #ifdef HAVE_SCREENSHOTS
#ifdef HAVE_GFX_WIDGETS #ifdef HAVE_GFX_WIDGETS
static void setting_get_string_representation_uint_notification_show_screenshot_duration( static void setting_get_string_representation_uint_notification_show_screenshot_duration(
rarch_setting_t *setting, rarch_setting_t *setting, char *s, size_t len)
char *s, size_t len)
{ {
if (!setting) if (!setting)
return; 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( static void setting_get_string_representation_uint_notification_show_screenshot_flash(
rarch_setting_t *setting, rarch_setting_t *setting, char *s, size_t len)
char *s, size_t len)
{ {
if (!setting) if (!setting)
return; return;
@ -4922,8 +4890,7 @@ static void setting_get_string_representation_uint_notification_show_screenshot_
#endif #endif
static void setting_get_string_representation_uint_video_autoswitch_refresh_rate( static void setting_get_string_representation_uint_video_autoswitch_refresh_rate(
rarch_setting_t *setting, rarch_setting_t *setting, char *s, size_t len)
char *s, size_t len)
{ {
if (!setting) if (!setting)
return; return;

View File

@ -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) 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(); settings_t *settings = config_get_ptr();
const char *url = settings->arrays.webdav_url; const char *url = settings->arrays.webdav_url;
webdav_state_t *webdav_st = webdav_state_get_ptr(); webdav_state_t *webdav_st = webdav_state_get_ptr();
size_t len = 0;
char *auth_header;
if (string_is_empty(url)) if (string_is_empty(url))
return false; return false;
@ -517,18 +517,18 @@ static bool webdav_sync_begin(cloud_sync_complete_handler_t cb, void *user_data)
/* TODO: LOCK? */ /* TODO: LOCK? */
if (!strstr(url, "://")) if (!strstr(url, "://"))
len += strlcpy(webdav_st->url, "http://", STRLEN_CONST("http://")); _len += strlcpy(webdav_st->url, "http://", STRLEN_CONST("http://"));
strlcpy(webdav_st->url + len, url, sizeof(webdav_st->url) - len); strlcpy(webdav_st->url + _len, url, sizeof(webdav_st->url) - _len);
fill_pathname_slash(webdav_st->url, sizeof(webdav_st->url)); fill_pathname_slash(webdav_st->url, sizeof(webdav_st->url));
/* url/username/password may have changed, redo auth check */ /* url/username/password may have changed, redo auth check */
webdav_st->basic = true; webdav_st->basic = true;
auth_header = webdav_get_auth_header(NULL, NULL); auth_header = webdav_get_auth_header(NULL, NULL);
if (auth_header) if (auth_header)
{ {
webdav_cb_state_t *webdav_cb_st = (webdav_cb_state_t*)calloc(1, sizeof(webdav_cb_state_t)); 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; webdav_cb_st->user_data = user_data;
task_push_webdav_stat(webdav_st->url, true, auth_header, webdav_stat_cb, webdav_cb_st); task_push_webdav_stat(webdav_st->url, true, auth_header, webdav_stat_cb, webdav_cb_st);
free(auth_header); free(auth_header);