mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-02 15:56:48 +00:00
Turn fifo_read_avail and fifo_write_avail into macros
This commit is contained in:
parent
11872ea157
commit
0a1942f528
@ -66,7 +66,7 @@ static void alsa_worker_thread(void *data)
|
||||
size_t fifo_size;
|
||||
snd_pcm_sframes_t frames;
|
||||
slock_lock(alsa->fifo_lock);
|
||||
avail = fifo_read_avail(alsa->buffer);
|
||||
avail = FIFO_READ_AVAIL(alsa->buffer);
|
||||
fifo_size = MIN(alsa->period_size, avail);
|
||||
fifo_read(alsa->buffer, buf, fifo_size);
|
||||
scond_signal(alsa->cond);
|
||||
@ -256,7 +256,7 @@ static ssize_t alsa_thread_write(void *data, const void *buf, size_t size)
|
||||
size_t write_amt;
|
||||
|
||||
slock_lock(alsa->fifo_lock);
|
||||
avail = fifo_write_avail(alsa->buffer);
|
||||
avail = FIFO_WRITE_AVAIL(alsa->buffer);
|
||||
write_amt = MIN(avail, size);
|
||||
|
||||
fifo_write(alsa->buffer, buf, write_amt);
|
||||
@ -271,7 +271,7 @@ static ssize_t alsa_thread_write(void *data, const void *buf, size_t size)
|
||||
{
|
||||
size_t avail;
|
||||
slock_lock(alsa->fifo_lock);
|
||||
avail = fifo_write_avail(alsa->buffer);
|
||||
avail = FIFO_WRITE_AVAIL(alsa->buffer);
|
||||
|
||||
if (avail == 0)
|
||||
{
|
||||
@ -334,7 +334,7 @@ static size_t alsa_thread_write_avail(void *data)
|
||||
if (alsa->thread_dead)
|
||||
return 0;
|
||||
slock_lock(alsa->fifo_lock);
|
||||
val = fifo_write_avail(alsa->buffer);
|
||||
val = FIFO_WRITE_AVAIL(alsa->buffer);
|
||||
slock_unlock(alsa->fifo_lock);
|
||||
return val;
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ static OSStatus audio_write_cb(void *userdata,
|
||||
|
||||
slock_lock(dev->lock);
|
||||
|
||||
if (fifo_read_avail(dev->buffer) < write_avail)
|
||||
if (FIFO_READ_AVAIL(dev->buffer) < write_avail)
|
||||
{
|
||||
*action_flags = kAudioUnitRenderAction_OutputIsSilence;
|
||||
|
||||
@ -356,7 +356,7 @@ static ssize_t coreaudio_write(void *data, const void *buf_, size_t size)
|
||||
|
||||
slock_lock(dev->lock);
|
||||
|
||||
write_avail = fifo_write_avail(dev->buffer);
|
||||
write_avail = FIFO_WRITE_AVAIL(dev->buffer);
|
||||
if (write_avail > size)
|
||||
write_avail = size;
|
||||
|
||||
@ -430,7 +430,7 @@ static size_t coreaudio_write_avail(void *data)
|
||||
coreaudio_t *dev = (coreaudio_t*)data;
|
||||
|
||||
slock_lock(dev->lock);
|
||||
avail = fifo_write_avail(dev->buffer);
|
||||
avail = FIFO_WRITE_AVAIL(dev->buffer);
|
||||
slock_unlock(dev->lock);
|
||||
|
||||
return avail;
|
||||
|
@ -155,7 +155,7 @@ static DWORD CALLBACK dsound_thread(PVOID data)
|
||||
avail = write_avail(read_ptr, write_ptr, ds->buffer_size);
|
||||
|
||||
EnterCriticalSection(&ds->crit);
|
||||
fifo_avail = fifo_read_avail(ds->buffer);
|
||||
fifo_avail = FIFO_READ_AVAIL(ds->buffer);
|
||||
LeaveCriticalSection(&ds->crit);
|
||||
|
||||
if (avail < CHUNK_SIZE || ((fifo_avail < CHUNK_SIZE) && (avail < ds->buffer_size / 2)))
|
||||
@ -511,7 +511,7 @@ static ssize_t dsound_write(void *data, const void *buf_, size_t size)
|
||||
size_t avail;
|
||||
|
||||
EnterCriticalSection(&ds->crit);
|
||||
avail = fifo_write_avail(ds->buffer);
|
||||
avail = FIFO_WRITE_AVAIL(ds->buffer);
|
||||
if (avail > size)
|
||||
avail = size;
|
||||
|
||||
@ -530,7 +530,7 @@ static ssize_t dsound_write(void *data, const void *buf_, size_t size)
|
||||
size_t avail;
|
||||
|
||||
EnterCriticalSection(&ds->crit);
|
||||
avail = fifo_write_avail(ds->buffer);
|
||||
avail = FIFO_WRITE_AVAIL(ds->buffer);
|
||||
if (avail > size)
|
||||
avail = size;
|
||||
|
||||
@ -558,7 +558,7 @@ static size_t dsound_write_avail(void *data)
|
||||
dsound_t *ds = (dsound_t*)data;
|
||||
|
||||
EnterCriticalSection(&ds->crit);
|
||||
avail = fifo_write_avail(ds->buffer);
|
||||
avail = FIFO_WRITE_AVAIL(ds->buffer);
|
||||
LeaveCriticalSection(&ds->crit);
|
||||
return avail;
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ static void event_loop(uint64_t data)
|
||||
sys_event_queue_receive(id, &event, SYS_NO_TIMEOUT);
|
||||
|
||||
sys_lwmutex_lock(&aud->lock, SYS_NO_TIMEOUT);
|
||||
if (fifo_read_avail(aud->buffer) >= sizeof(out_tmp))
|
||||
if (FIFO_READ_AVAIL(aud->buffer) >= sizeof(out_tmp))
|
||||
fifo_read(aud->buffer, out_tmp, sizeof(out_tmp));
|
||||
else
|
||||
memset(out_tmp, 0, sizeof(out_tmp));
|
||||
@ -152,11 +152,11 @@ static ssize_t ps3_audio_write(void *data, const void *buf, size_t size)
|
||||
|
||||
if (aud->nonblock)
|
||||
{
|
||||
if (fifo_write_avail(aud->buffer) < size)
|
||||
if (FIFO_WRITE_AVAIL(aud->buffer) < size)
|
||||
return 0;
|
||||
}
|
||||
|
||||
while (fifo_write_avail(aud->buffer) < size)
|
||||
while (FIFO_WRITE_AVAIL(aud->buffer) < size)
|
||||
sys_lwcond_wait(&aud->cond, 0);
|
||||
|
||||
sys_lwmutex_lock(&aud->lock, SYS_NO_TIMEOUT);
|
||||
|
@ -40,8 +40,7 @@ typedef struct rsd
|
||||
static ssize_t rsound_audio_cb(void *data, size_t bytes, void *userdata)
|
||||
{
|
||||
rsd_t *rsd = (rsd_t*)userdata;
|
||||
|
||||
size_t avail = fifo_read_avail(rsd->buffer);
|
||||
size_t avail = FIFO_READ_AVAIL(rsd->buffer);
|
||||
size_t write_size = bytes > avail ? avail : bytes;
|
||||
fifo_read(rsd->buffer, data, write_size);
|
||||
scond_signal(rsd->cond);
|
||||
@ -115,7 +114,7 @@ static ssize_t rs_write(void *data, const void *buf, size_t size)
|
||||
|
||||
rsd_callback_lock(rsd->rd);
|
||||
|
||||
avail = fifo_write_avail(rsd->buffer);
|
||||
avail = FIFO_WRITE_AVAIL(rsd->buffer);
|
||||
write_amt = avail > size ? size : avail;
|
||||
|
||||
fifo_write(rsd->buffer, buf, write_amt);
|
||||
@ -130,7 +129,7 @@ static ssize_t rs_write(void *data, const void *buf, size_t size)
|
||||
size_t avail;
|
||||
rsd_callback_lock(rsd->rd);
|
||||
|
||||
avail = fifo_write_avail(rsd->buffer);
|
||||
avail = FIFO_WRITE_AVAIL(rsd->buffer);
|
||||
|
||||
if (avail == 0)
|
||||
{
|
||||
@ -209,7 +208,7 @@ static size_t rs_write_avail(void *data)
|
||||
if (rsd->has_error)
|
||||
return 0;
|
||||
rsd_callback_lock(rsd->rd);
|
||||
val = fifo_write_avail(rsd->buffer);
|
||||
val = FIFO_WRITE_AVAIL(rsd->buffer);
|
||||
rsd_callback_unlock(rsd->rd);
|
||||
return val;
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ typedef struct sdl_audio
|
||||
static void sdl_audio_cb(void *data, Uint8 *stream, int len)
|
||||
{
|
||||
sdl_audio_t *sdl = (sdl_audio_t*)data;
|
||||
size_t avail = fifo_read_avail(sdl->buffer);
|
||||
size_t avail = FIFO_READ_AVAIL(sdl->buffer);
|
||||
size_t write_size = len > (int)avail ? avail : len;
|
||||
|
||||
fifo_read(sdl->buffer, stream, write_size);
|
||||
@ -151,7 +151,7 @@ static ssize_t sdl_audio_write(void *data, const void *buf, size_t size)
|
||||
size_t avail, write_amt;
|
||||
|
||||
SDL_LockAudio();
|
||||
avail = fifo_write_avail(sdl->buffer);
|
||||
avail = FIFO_WRITE_AVAIL(sdl->buffer);
|
||||
write_amt = avail > size ? size : avail;
|
||||
fifo_write(sdl->buffer, buf, write_amt);
|
||||
SDL_UnlockAudio();
|
||||
@ -166,7 +166,7 @@ static ssize_t sdl_audio_write(void *data, const void *buf, size_t size)
|
||||
size_t avail;
|
||||
|
||||
SDL_LockAudio();
|
||||
avail = fifo_write_avail(sdl->buffer);
|
||||
avail = FIFO_WRITE_AVAIL(sdl->buffer);
|
||||
|
||||
if (avail == 0)
|
||||
{
|
||||
|
@ -96,7 +96,7 @@ static void thread_job(void* data)
|
||||
if (current_wavebuf)
|
||||
{
|
||||
mutexLock(&aud->fifo_lock);
|
||||
available = aud->paused ? 0 : fifo_read_avail(aud->fifo);
|
||||
available = aud->paused ? 0 : FIFO_READ_AVAIL(aud->fifo);
|
||||
written_tmp = MIN(available, aud->buffer_size - current_size);
|
||||
dstbuf = current_pool_ptr + current_size;
|
||||
if (written_tmp > 0)
|
||||
@ -295,7 +295,7 @@ static ssize_t libnx_audren_thread_audio_write(void *data,
|
||||
if (aud->nonblock)
|
||||
{
|
||||
mutexLock(&aud->fifo_lock);
|
||||
available = fifo_write_avail(aud->fifo);
|
||||
available = FIFO_WRITE_AVAIL(aud->fifo);
|
||||
written = MIN(available, size);
|
||||
if (written > 0)
|
||||
fifo_write(aud->fifo, buf, written);
|
||||
@ -307,7 +307,7 @@ static ssize_t libnx_audren_thread_audio_write(void *data,
|
||||
while (written < size && aud->running)
|
||||
{
|
||||
mutexLock(&aud->fifo_lock);
|
||||
available = fifo_write_avail(aud->fifo);
|
||||
available = FIFO_WRITE_AVAIL(aud->fifo);
|
||||
if (available)
|
||||
{
|
||||
written_tmp = MIN(size - written, available);
|
||||
@ -407,7 +407,7 @@ static size_t libnx_audren_thread_audio_write_avail(void *data)
|
||||
return 0;
|
||||
|
||||
mutexLock(&aud->fifo_lock);
|
||||
available = fifo_write_avail(aud->fifo);
|
||||
available = FIFO_WRITE_AVAIL(aud->fifo);
|
||||
mutexUnlock(&aud->fifo_lock);
|
||||
|
||||
return available;
|
||||
|
@ -107,7 +107,7 @@ static void mainLoop(void* data)
|
||||
|
||||
compat_mutex_lock(&swa->fifoLock);
|
||||
|
||||
avail = fifo_read_avail(swa->fifo);
|
||||
avail = FIFO_READ_AVAIL(swa->fifo);
|
||||
to_write = MIN(avail, buf_avail);
|
||||
if (to_write > 0)
|
||||
{
|
||||
@ -349,7 +349,7 @@ static ssize_t switch_thread_audio_write(void *data, const void *buf, size_t siz
|
||||
if (swa->nonblock)
|
||||
{
|
||||
compat_mutex_lock(&swa->fifoLock);
|
||||
avail = fifo_write_avail(swa->fifo);
|
||||
avail = FIFO_WRITE_AVAIL(swa->fifo);
|
||||
written = MIN(avail, size);
|
||||
if (written > 0)
|
||||
fifo_write(swa->fifo, buf, written);
|
||||
@ -361,7 +361,7 @@ static ssize_t switch_thread_audio_write(void *data, const void *buf, size_t siz
|
||||
while (written < size && swa->running)
|
||||
{
|
||||
compat_mutex_lock(&swa->fifoLock);
|
||||
avail = fifo_write_avail(swa->fifo);
|
||||
avail = FIFO_WRITE_AVAIL(swa->fifo);
|
||||
if (avail == 0)
|
||||
{
|
||||
compat_mutex_unlock(&swa->fifoLock);
|
||||
@ -413,7 +413,7 @@ static size_t switch_thread_audio_write_avail(void *data)
|
||||
switch_thread_audio_t* swa = (switch_thread_audio_t*)data;
|
||||
|
||||
compat_mutex_lock(&swa->fifoLock);
|
||||
val = fifo_write_avail(swa->fifo);
|
||||
val = FIFO_WRITE_AVAIL(swa->fifo);
|
||||
compat_mutex_unlock(&swa->fifoLock);
|
||||
|
||||
return val;
|
||||
|
@ -632,7 +632,7 @@ static ssize_t wasapi_write_sh_buffer(wasapi_t *w, const void * data, size_t siz
|
||||
{
|
||||
ssize_t written = -1;
|
||||
UINT32 padding = 0;
|
||||
size_t write_avail = fifo_write_avail(w->buffer);
|
||||
size_t write_avail = FIFO_WRITE_AVAIL(w->buffer);
|
||||
|
||||
if (!write_avail)
|
||||
{
|
||||
@ -643,7 +643,7 @@ static ssize_t wasapi_write_sh_buffer(wasapi_t *w, const void * data, size_t siz
|
||||
if (FAILED(_IAudioClient_GetCurrentPadding(w->client, &padding)))
|
||||
return -1;
|
||||
|
||||
read_avail = fifo_read_avail(w->buffer);
|
||||
read_avail = FIFO_READ_AVAIL(w->buffer);
|
||||
write_avail = w->engine_buffer_size - padding * w->frame_size;
|
||||
written = read_avail < write_avail ? read_avail : write_avail;
|
||||
if (written)
|
||||
@ -651,7 +651,7 @@ static ssize_t wasapi_write_sh_buffer(wasapi_t *w, const void * data, size_t siz
|
||||
return -1;
|
||||
}
|
||||
|
||||
write_avail = fifo_write_avail(w->buffer);
|
||||
write_avail = FIFO_WRITE_AVAIL(w->buffer);
|
||||
written = size < write_avail ? size : write_avail;
|
||||
if (written)
|
||||
fifo_write(w->buffer, data, written);
|
||||
@ -691,14 +691,14 @@ static ssize_t wasapi_write_sh_nonblock(wasapi_t *w, const void * data, size_t s
|
||||
|
||||
if (w->buffer)
|
||||
{
|
||||
write_avail = fifo_write_avail(w->buffer);
|
||||
write_avail = FIFO_WRITE_AVAIL(w->buffer);
|
||||
if (!write_avail)
|
||||
{
|
||||
size_t read_avail = 0;
|
||||
if (FAILED(_IAudioClient_GetCurrentPadding(w->client, &padding)))
|
||||
return -1;
|
||||
|
||||
read_avail = fifo_read_avail(w->buffer);
|
||||
read_avail = FIFO_READ_AVAIL(w->buffer);
|
||||
write_avail = w->engine_buffer_size - padding * w->frame_size;
|
||||
written = read_avail < write_avail ? read_avail : write_avail;
|
||||
if (written)
|
||||
@ -706,7 +706,7 @@ static ssize_t wasapi_write_sh_nonblock(wasapi_t *w, const void * data, size_t s
|
||||
return -1;
|
||||
}
|
||||
|
||||
write_avail = fifo_write_avail(w->buffer);
|
||||
write_avail = FIFO_WRITE_AVAIL(w->buffer);
|
||||
written = size < write_avail ? size : write_avail;
|
||||
if (written)
|
||||
fifo_write(w->buffer, data, written);
|
||||
@ -731,7 +731,7 @@ static ssize_t wasapi_write_sh_nonblock(wasapi_t *w, const void * data, size_t s
|
||||
static ssize_t wasapi_write_ex(wasapi_t *w, const void * data, size_t size, DWORD ms)
|
||||
{
|
||||
ssize_t written = 0;
|
||||
size_t write_avail = fifo_write_avail(w->buffer);
|
||||
size_t write_avail = FIFO_WRITE_AVAIL(w->buffer);
|
||||
|
||||
if (!write_avail)
|
||||
{
|
||||
@ -890,7 +890,7 @@ static size_t wasapi_write_avail(void *wh)
|
||||
UINT32 padding = 0;
|
||||
|
||||
if (w->buffer)
|
||||
return fifo_write_avail(w->buffer);
|
||||
return FIFO_WRITE_AVAIL(w->buffer);
|
||||
|
||||
if (FAILED(_IAudioClient_GetCurrentPadding(w->client, &padding)))
|
||||
return 0;
|
||||
|
@ -765,13 +765,13 @@ static void rsnd_drain(rsound_t *rd)
|
||||
delta /= 1000000;
|
||||
/* Calculates the amount of data we have in our virtual buffer. Only used to calculate delay. */
|
||||
slock_lock(rd->thread.mutex);
|
||||
rd->bytes_in_buffer = (int)((int64_t)rd->total_written + (int64_t)fifo_read_avail(rd->fifo_buffer) - delta);
|
||||
rd->bytes_in_buffer = (int)((int64_t)rd->total_written + (int64_t)FIFO_READ_AVAIL(rd->fifo_buffer) - delta);
|
||||
slock_unlock(rd->thread.mutex);
|
||||
}
|
||||
else
|
||||
{
|
||||
slock_lock(rd->thread.mutex);
|
||||
rd->bytes_in_buffer = fifo_read_avail(rd->fifo_buffer);
|
||||
rd->bytes_in_buffer = FIFO_READ_AVAIL(rd->fifo_buffer);
|
||||
slock_unlock(rd->thread.mutex);
|
||||
}
|
||||
}
|
||||
@ -789,7 +789,7 @@ static size_t rsnd_fill_buffer(rsound_t *rd, const char *buf, size_t size)
|
||||
return 0;
|
||||
|
||||
slock_lock(rd->thread.mutex);
|
||||
if ( fifo_write_avail(rd->fifo_buffer) >= size )
|
||||
if (FIFO_WRITE_AVAIL(rd->fifo_buffer) >= size)
|
||||
{
|
||||
slock_unlock(rd->thread.mutex);
|
||||
break;
|
||||
@ -886,7 +886,7 @@ static size_t rsnd_get_ptr(rsound_t *rd)
|
||||
{
|
||||
int ptr;
|
||||
slock_lock(rd->thread.mutex);
|
||||
ptr = fifo_read_avail(rd->fifo_buffer);
|
||||
ptr = FIFO_READ_AVAIL(rd->fifo_buffer);
|
||||
slock_unlock(rd->thread.mutex);
|
||||
|
||||
return ptr;
|
||||
@ -1060,7 +1060,7 @@ static int rsnd_update_server_info(rsound_t *rd)
|
||||
int delay = rsd_delay(rd);
|
||||
int delta = (int)(client_ptr - serv_ptr);
|
||||
slock_lock(rd->thread.mutex);
|
||||
delta += fifo_read_avail(rd->fifo_buffer);
|
||||
delta += FIFO_READ_AVAIL(rd->fifo_buffer);
|
||||
slock_unlock(rd->thread.mutex);
|
||||
|
||||
RSD_DEBUG("[RSound] Delay: %d, Delta: %d.\n", delay, delta);
|
||||
@ -1116,7 +1116,7 @@ static void rsnd_thread ( void * thread_data )
|
||||
|
||||
/* If the buffer is empty or we've stopped the stream, jump out of this for loop */
|
||||
slock_lock(rd->thread.mutex);
|
||||
if ( fifo_read_avail(rd->fifo_buffer) < rd->backend_info.chunk_size || !rd->thread_active )
|
||||
if (FIFO_READ_AVAIL(rd->fifo_buffer) < rd->backend_info.chunk_size || !rd->thread_active)
|
||||
{
|
||||
slock_unlock(rd->thread.mutex);
|
||||
break;
|
||||
@ -1382,11 +1382,10 @@ int rsd_exec(rsound_t *rsound)
|
||||
fcntl(rsound->conn.socket, F_SETFL, O_NONBLOCK);
|
||||
#endif
|
||||
|
||||
// Flush the buffer
|
||||
|
||||
if ( fifo_read_avail(rsound->fifo_buffer) > 0 )
|
||||
/* Flush the buffer */
|
||||
if (FIFO_READ_AVAIL(rsound->fifo_buffer) > 0 )
|
||||
{
|
||||
char buffer[fifo_read_avail(rsound->fifo_buffer)];
|
||||
char buffer[FIFO_READ_AVAIL(rsound->fifo_buffer)];
|
||||
fifo_read(rsound->fifo_buffer, buffer, sizeof(buffer));
|
||||
if ( rsnd_send_chunk(fd, buffer, sizeof(buffer), 1) != (ssize_t)sizeof(buffer) )
|
||||
{
|
||||
|
@ -703,7 +703,7 @@ void CORE_PREFIX(retro_run)(void)
|
||||
to_read_bytes = to_read_frames * sizeof(int16_t) * 2;
|
||||
|
||||
slock_lock(fifo_lock);
|
||||
while (!decode_thread_dead && fifo_read_avail(audio_decode_fifo) < to_read_bytes)
|
||||
while (!decode_thread_dead && FIFO_READ_AVAIL(audio_decode_fifo) < to_read_bytes)
|
||||
{
|
||||
main_sleeping = true;
|
||||
scond_signal(fifo_decode_cond);
|
||||
@ -712,7 +712,7 @@ void CORE_PREFIX(retro_run)(void)
|
||||
}
|
||||
|
||||
reading_pts = decode_last_audio_time -
|
||||
(double)fifo_read_avail(audio_decode_fifo) / (media.sample_rate * sizeof(int16_t) * 2);
|
||||
(double)FIFO_READ_AVAIL(audio_decode_fifo) / (media.sample_rate * sizeof(int16_t) * 2);
|
||||
expected_pts = (double)audio_frames / media.sample_rate;
|
||||
old_pts_bias = pts_bias;
|
||||
pts_bias = reading_pts - expected_pts;
|
||||
@ -1574,7 +1574,8 @@ static int16_t *decode_audio(AVCodecContext *ctx, AVPacket *pkt,
|
||||
pts = frame->best_effort_timestamp;
|
||||
slock_lock(fifo_lock);
|
||||
|
||||
while (!decode_thread_dead && fifo_write_avail(audio_decode_fifo) < required_buffer)
|
||||
while (!decode_thread_dead &&
|
||||
FIFO_WRITE_AVAIL(audio_decode_fifo) < required_buffer)
|
||||
{
|
||||
if (!main_sleeping)
|
||||
scond_wait(fifo_decode_cond, fifo_lock);
|
||||
|
@ -236,7 +236,7 @@ void gfx_widgets_msg_queue_push(
|
||||
disp_widget_msg_t *msg_widget = NULL;
|
||||
dispgfx_widget_t *p_dispwidget = (dispgfx_widget_t*)data;
|
||||
|
||||
if (fifo_write_avail(p_dispwidget->msg_queue) > 0)
|
||||
if (FIFO_WRITE_AVAIL(p_dispwidget->msg_queue) > 0)
|
||||
{
|
||||
/* Get current msg if it exists */
|
||||
if (task && task->frontend_userdata)
|
||||
@ -861,7 +861,7 @@ void gfx_widgets_iterate(
|
||||
/* Messages queue */
|
||||
|
||||
/* Consume one message if available */
|
||||
if ((fifo_read_avail(p_dispwidget->msg_queue) > 0)
|
||||
if ((FIFO_READ_AVAIL(p_dispwidget->msg_queue) > 0)
|
||||
&& !p_dispwidget->widgets_moving
|
||||
&& (p_dispwidget->current_msgs_size < ARRAY_SIZE(p_dispwidget->current_msgs)))
|
||||
{
|
||||
@ -871,7 +871,7 @@ void gfx_widgets_iterate(
|
||||
|
||||
if (p_dispwidget->current_msgs_size < ARRAY_SIZE(p_dispwidget->current_msgs))
|
||||
{
|
||||
if (fifo_read_avail(p_dispwidget->msg_queue) > 0)
|
||||
if (FIFO_READ_AVAIL(p_dispwidget->msg_queue) > 0)
|
||||
fifo_read(p_dispwidget->msg_queue, &msg_widget, sizeof(msg_widget));
|
||||
|
||||
if (msg_widget)
|
||||
@ -2078,7 +2078,7 @@ static void gfx_widgets_free(dispgfx_widget_t *p_dispwidget)
|
||||
/* Purge everything from the fifo */
|
||||
if (p_dispwidget->msg_queue)
|
||||
{
|
||||
while (fifo_read_avail(p_dispwidget->msg_queue) > 0)
|
||||
while (FIFO_READ_AVAIL(p_dispwidget->msg_queue) > 0)
|
||||
{
|
||||
disp_widget_msg_t *msg_widget;
|
||||
|
||||
|
@ -94,13 +94,13 @@ static void adapter_thread(void *data)
|
||||
int size = 0;
|
||||
|
||||
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))
|
||||
{
|
||||
fifo_read(adapter->send_control_buffer,
|
||||
&send_command_size, sizeof(send_command_size));
|
||||
|
||||
if (fifo_read_avail(adapter->send_control_buffer)
|
||||
if (FIFO_READ_AVAIL(adapter->send_control_buffer)
|
||||
>= sizeof(send_command_size))
|
||||
{
|
||||
fifo_read(adapter->send_control_buffer,
|
||||
@ -132,7 +132,7 @@ static void libusb_hid_device_send_control(void *data,
|
||||
|
||||
slock_lock(adapter->send_control_lock);
|
||||
|
||||
if (fifo_write_avail(adapter->send_control_buffer) >= size + sizeof(size))
|
||||
if (FIFO_WRITE_AVAIL(adapter->send_control_buffer) >= size + sizeof(size))
|
||||
{
|
||||
fifo_write(adapter->send_control_buffer, &size, sizeof(size));
|
||||
fifo_write(adapter->send_control_buffer, data_buf, size);
|
||||
|
@ -63,15 +63,9 @@ static INLINE void fifo_free(fifo_buffer_t *buffer)
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
static INLINE size_t fifo_read_avail(fifo_buffer_t *buffer)
|
||||
{
|
||||
return (buffer->end + ((buffer->end < buffer->first) ? buffer->size : 0)) - buffer->first;
|
||||
}
|
||||
#define FIFO_READ_AVAIL(buffer) (((buffer)->end + (((buffer)->end < (buffer)->first) ? (buffer)->size : 0)) - (buffer)->first)
|
||||
|
||||
static INLINE size_t fifo_write_avail(fifo_buffer_t *buffer)
|
||||
{
|
||||
return (buffer->size - 1) - ((buffer->end + ((buffer->end < buffer->first) ? buffer->size : 0)) - buffer->first);
|
||||
}
|
||||
#define FIFO_WRITE_AVAIL(buffer) (((buffer)->size - 1) - (((buffer)->end + (((buffer)->end < (buffer)->first) ? (buffer)->size : 0)) - (buffer)->first))
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
||||
|
@ -1121,7 +1121,7 @@ static bool ffmpeg_push_video(void *data,
|
||||
unsigned avail;
|
||||
|
||||
slock_lock(handle->lock);
|
||||
avail = fifo_write_avail(handle->attr_fifo);
|
||||
avail = FIFO_WRITE_AVAIL(handle->attr_fifo);
|
||||
slock_unlock(handle->lock);
|
||||
|
||||
if (!handle->alive)
|
||||
@ -1183,7 +1183,7 @@ static bool ffmpeg_push_audio(void *data,
|
||||
unsigned avail;
|
||||
|
||||
slock_lock(handle->lock);
|
||||
avail = fifo_write_avail(handle->audio_fifo);
|
||||
avail = FIFO_WRITE_AVAIL(handle->audio_fifo);
|
||||
slock_unlock(handle->lock);
|
||||
|
||||
if (!handle->alive)
|
||||
@ -1578,7 +1578,7 @@ static bool ffmpeg_push_audio_thread(ffmpeg_t *handle,
|
||||
static void ffmpeg_flush_audio(ffmpeg_t *handle, void *audio_buf,
|
||||
size_t audio_buf_size)
|
||||
{
|
||||
size_t avail = fifo_read_avail(handle->audio_fifo);
|
||||
size_t avail = FIFO_READ_AVAIL(handle->audio_fifo);
|
||||
|
||||
if (avail)
|
||||
{
|
||||
@ -1624,7 +1624,7 @@ static void ffmpeg_flush_buffers(ffmpeg_t *handle)
|
||||
|
||||
if (handle->config.audio_enable)
|
||||
{
|
||||
if (fifo_read_avail(handle->audio_fifo) >= audio_buf_size)
|
||||
if (FIFO_READ_AVAIL(handle->audio_fifo) >= audio_buf_size)
|
||||
{
|
||||
struct record_audio_data aud = {0};
|
||||
|
||||
@ -1637,7 +1637,7 @@ static void ffmpeg_flush_buffers(ffmpeg_t *handle)
|
||||
}
|
||||
}
|
||||
|
||||
if (fifo_read_avail(handle->attr_fifo) >= sizeof(attr_buf))
|
||||
if (FIFO_READ_AVAIL(handle->attr_fifo) >= sizeof(attr_buf))
|
||||
{
|
||||
fifo_read(handle->attr_fifo, &attr_buf, sizeof(attr_buf));
|
||||
fifo_read(handle->video_fifo, video_buf,
|
||||
@ -1705,11 +1705,11 @@ static void ffmpeg_thread(void *data)
|
||||
bool avail_audio = false;
|
||||
|
||||
slock_lock(ff->lock);
|
||||
if (fifo_read_avail(ff->attr_fifo) >= sizeof(attr_buf))
|
||||
if (FIFO_READ_AVAIL(ff->attr_fifo) >= sizeof(attr_buf))
|
||||
avail_video = true;
|
||||
|
||||
if (ff->config.audio_enable)
|
||||
if (fifo_read_avail(ff->audio_fifo) >= audio_buf_size)
|
||||
if (FIFO_READ_AVAIL(ff->audio_fifo) >= audio_buf_size)
|
||||
avail_audio = true;
|
||||
slock_unlock(ff->lock);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user