Skip to content

Commit

Permalink
Style nits
Browse files Browse the repository at this point in the history
  • Loading branch information
LibretroAdmin committed Jan 19, 2025
1 parent 13bc41f commit 3549d83
Show file tree
Hide file tree
Showing 22 changed files with 261 additions and 401 deletions.
6 changes: 3 additions & 3 deletions audio/audio_thread_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ static void audio_thread_loop(void *data)
thr->driver->stop(thr->driver_data);
while (thr->stopped)
{
/* If we stop right after start,
/* If we stop right after start,
* we might not be able to properly ack.
* Signal in the loop instead. */
thr->stopped_ack = true;
Expand Down Expand Up @@ -249,15 +249,15 @@ static bool audio_thread_use_float(void *data)
return thr->use_float;
}

static ssize_t audio_thread_write(void *data, const void *buf, size_t size)
static ssize_t audio_thread_write(void *data, const void *s, size_t len)
{
ssize_t ret;
audio_thread_t *thr = (audio_thread_t*)data;

if (!thr)
return 0;

ret = thr->driver->write(thr->driver_data, buf, size);
ret = thr->driver->write(thr->driver_data, s, len);

if (ret < 0)
{
Expand Down
22 changes: 9 additions & 13 deletions audio/drivers/openal.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,29 +163,29 @@ static bool al_get_buffer(al_t *al, ALuint *buffer)
return true;
}

static size_t al_fill_internal_buf(al_t *al, const void *buf, size_t size)
static size_t al_fill_internal_buf(al_t *al, const void *s, size_t len)
{
size_t read_size = MIN(OPENAL_BUFSIZE - al->tmpbuf_ptr, size);
memcpy(al->tmpbuf + al->tmpbuf_ptr, buf, read_size);
size_t read_size = MIN(OPENAL_BUFSIZE - al->tmpbuf_ptr, len);
memcpy(al->tmpbuf + al->tmpbuf_ptr, s, read_size);
al->tmpbuf_ptr += read_size;
return read_size;
}

static ssize_t al_write(void *data, const void *buf_, size_t size)
static ssize_t al_write(void *data, const void *s, size_t len)
{
al_t *al = (al_t*)data;
const uint8_t *buf = (const uint8_t*)buf_;
const uint8_t *buf = (const uint8_t*)s;
size_t written = 0;

while (size)
while (len)
{
ALint val;
ALuint buffer;
size_t rc = al_fill_internal_buf(al, buf, size);
size_t rc = al_fill_internal_buf(al, buf, len);

written += rc;
buf += rc;
size -= rc;
len -= rc;

if (al->tmpbuf_ptr != OPENAL_BUFSIZE)
break;
Expand Down Expand Up @@ -254,11 +254,7 @@ static size_t al_buffer_size(void *data)
return (al->num_buffers + 1) * OPENAL_BUFSIZE; /* Also got tmpbuf. */
}

static bool al_use_float(void *data)
{
(void)data;
return false;
}
static bool al_use_float(void *data) { return false; }

audio_driver_t audio_openal = {
al_init,
Expand Down
19 changes: 7 additions & 12 deletions audio/drivers/opensl.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,13 @@ static bool sl_start(void *data, bool is_shutdown)
return sl->is_paused ? false : true;
}

static ssize_t sl_write(void *data, const void *buf_, size_t size)
static ssize_t sl_write(void *data, const void *s, size_t len)
{
sl_t *sl = (sl_t*)data;
size_t written = 0;
const uint8_t *buf = (const uint8_t*)buf_;
const uint8_t *buf = (const uint8_t*)s;

while (size)
while (len)
{
size_t avail_write;

Expand All @@ -255,14 +255,14 @@ static ssize_t sl_write(void *data, const void *buf_, size_t size)
slock_unlock(sl->lock);
}

avail_write = MIN(sl->buf_size - sl->buffer_ptr, size);
avail_write = MIN(sl->buf_size - sl->buffer_ptr, len);

if (avail_write)
{
memcpy(sl->buffer[sl->buffer_index] + sl->buffer_ptr, buf, avail_write);
sl->buffer_ptr += avail_write;
buf += avail_write;
size -= avail_write;
len -= avail_write;
written += avail_write;
}

Expand All @@ -287,8 +287,7 @@ static ssize_t sl_write(void *data, const void *buf_, size_t size)
static size_t sl_write_avail(void *data)
{
sl_t *sl = (sl_t*)data;
size_t avail = (sl->buf_count - (int)sl->buffered_blocks - 1) * sl->buf_size + (sl->buf_size - (int)sl->buffer_ptr);
return avail;
return ((sl->buf_count - (int)sl->buffered_blocks - 1) * sl->buf_size + (sl->buf_size - (int)sl->buffer_ptr));
}

static size_t sl_buffer_size(void *data)
Expand All @@ -297,11 +296,7 @@ static size_t sl_buffer_size(void *data)
return sl->buf_size * sl->buf_count;
}

static bool sl_use_float(void *data)
{
(void)data;
return false;
}
static bool sl_use_float(void *data) { return false; }

audio_driver_t audio_opensl = {
sl_init,
Expand Down
60 changes: 28 additions & 32 deletions audio/drivers/pulse.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,31 @@ static void *pulse_init(const char *device, unsigned rate,
return NULL;
}

static bool pulse_start(void *data, bool is_shutdown);
static ssize_t pulse_write(void *data, const void *buf_, size_t size)
static bool pulse_start(void *data, bool is_shutdown)
{
bool ret;
pa_t *pa = (pa_t*)data;

if (!pa->is_ready)
return false;
if (!pa->is_paused)
return true;

pa->success = true; /* In case of spurious wakeup. Not critical. */
pa_threaded_mainloop_lock(pa->mainloop);
pa_stream_cork(pa->stream, false, stream_success_cb, pa);
pa_threaded_mainloop_wait(pa->mainloop);
ret = pa->success;
pa_threaded_mainloop_unlock(pa->mainloop);
pa->is_paused = false;
return ret;
}


static ssize_t pulse_write(void *data, const void *s, size_t len)
{
pa_t *pa = (pa_t*)data;
const uint8_t *buf = (const uint8_t*)buf_;
const uint8_t *buf = (const uint8_t*)s;
size_t written = 0;

/* Workaround buggy menu code.
Expand All @@ -293,15 +313,15 @@ static ssize_t pulse_write(void *data, const void *buf_, size_t size)
return 0;

pa_threaded_mainloop_lock(pa->mainloop);
while (size)
while (len)
{
size_t writable = MIN(size, pa_stream_writable_size(pa->stream));
size_t writable = MIN(len, pa_stream_writable_size(pa->stream));

if (writable)
{
pa_stream_write(pa->stream, buf, writable, NULL, 0, PA_SEEK_RELATIVE);
buf += writable;
size -= writable;
buf += writable;
len -= writable;
written += writable;
}
else if (!pa->nonblock)
Expand Down Expand Up @@ -344,38 +364,14 @@ static bool pulse_alive(void *data)
return !pa->is_paused;
}

static bool pulse_start(void *data, bool is_shutdown)
{
bool ret;
pa_t *pa = (pa_t*)data;

if (!pa->is_ready)
return false;
if (!pa->is_paused)
return true;

pa->success = true; /* In case of spurious wakeup. Not critical. */
pa_threaded_mainloop_lock(pa->mainloop);
pa_stream_cork(pa->stream, false, stream_success_cb, pa);
pa_threaded_mainloop_wait(pa->mainloop);
ret = pa->success;
pa_threaded_mainloop_unlock(pa->mainloop);
pa->is_paused = false;
return ret;
}

static void pulse_set_nonblock_state(void *data, bool state)
{
pa_t *pa = (pa_t*)data;
if (pa)
pa->nonblock = state;
}

static bool pulse_use_float(void *data)
{
(void)data;
return true;
}
static bool pulse_use_float(void *data) { return true; }

static size_t pulse_write_avail(void *data)
{
Expand Down
2 changes: 1 addition & 1 deletion audio/drivers/rsound.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ int rsd_stop (rsound_t *rd);
or there was an unexpected error. This function will block until all data has
been written to the buffer. This function will return the number of bytes written to the buffer,
or 0 should it fail (disconnection from server). You will have to restart the stream again should this occur. */
size_t rsd_write (rsound_t *rd, const void* buf, size_t size);
size_t rsd_write (rsound_t *rd, const void *s, size_t len);

/* Gets the position of the buffer pointer.
Not really interesting for normal applications.
Expand Down
6 changes: 3 additions & 3 deletions audio/drivers/rwebaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/* forward declarations */
unsigned RWebAudioSampleRate(void);
void *RWebAudioInit(unsigned latency);
ssize_t RWebAudioWrite(const void *buf, size_t size);
ssize_t RWebAudioWrite(const void *s, size_t len);
bool RWebAudioStop(void);
bool RWebAudioStart(void);
void RWebAudioSetNonblockState(bool state);
Expand Down Expand Up @@ -54,9 +54,9 @@ static void *rwebaudio_init(const char *device, unsigned rate, unsigned latency,
return rwebaudio;
}

static ssize_t rwebaudio_write(void *data, const void *buf, size_t size)
static ssize_t rwebaudio_write(void *data, const void *s, size_t len)
{
return RWebAudioWrite(buf, size);
return RWebAudioWrite(s, len);
}

static bool rwebaudio_stop(void *data)
Expand Down
6 changes: 3 additions & 3 deletions audio/drivers/switch_libnx_audren_thread_audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ static size_t libnx_audren_thread_audio_buffer_size(void *data)
}

static ssize_t libnx_audren_thread_audio_write(void *data,
const void *buf, size_t len)
const void *s, size_t len)
{
libnx_audren_thread_t *aud = (libnx_audren_thread_t*)data;
size_t available, written, written_tmp;
Expand All @@ -299,7 +299,7 @@ static ssize_t libnx_audren_thread_audio_write(void *data,
available = FIFO_WRITE_AVAIL(aud->fifo);
written = MIN(available, len);
if (written > 0)
fifo_write(aud->fifo, buf, written);
fifo_write(aud->fifo, s, written);
mutexUnlock(&aud->fifo_lock);
}
else
Expand All @@ -312,7 +312,7 @@ static ssize_t libnx_audren_thread_audio_write(void *data,
if (available)
{
written_tmp = MIN(len - written, available);
fifo_write(aud->fifo, (const char*)buf + written, written_tmp);
fifo_write(aud->fifo, (const char*)s + written, written_tmp);
mutexUnlock(&aud->fifo_lock);
written += written_tmp;
}
Expand Down
Loading

0 comments on commit 3549d83

Please sign in to comment.