mirror of
https://github.com/libretro/RetroArch.git
synced 2025-03-02 22:55:41 +00:00
(audio/video_thread_wrapper) Style nits
This commit is contained in:
parent
96a39ec234
commit
b98d8a47cf
@ -51,11 +51,11 @@ static void audio_thread_loop(void *data)
|
||||
return;
|
||||
|
||||
RARCH_LOG("[Audio Thread]: Initializing audio driver.\n");
|
||||
thr->driver_data = thr->driver->init(thr->device, thr->out_rate, thr->latency);
|
||||
thr->driver_data = thr->driver->init(thr->device, thr->out_rate, thr->latency);
|
||||
slock_lock(thr->lock);
|
||||
thr->inited = thr->driver_data ? 1 : -1;
|
||||
thr->inited = thr->driver_data ? 1 : -1;
|
||||
if (thr->inited > 0 && thr->driver->use_float)
|
||||
thr->use_float = thr->driver->use_float(thr->driver_data);
|
||||
thr->use_float = thr->driver->use_float(thr->driver_data);
|
||||
scond_signal(thr->cond);
|
||||
slock_unlock(thr->lock);
|
||||
|
||||
@ -133,7 +133,7 @@ static void audio_thread_free(void *data)
|
||||
{
|
||||
slock_lock(thr->lock);
|
||||
thr->stopped = false;
|
||||
thr->alive = false;
|
||||
thr->alive = false;
|
||||
scond_signal(thr->cond);
|
||||
slock_unlock(thr->lock);
|
||||
|
||||
@ -149,7 +149,7 @@ static void audio_thread_free(void *data)
|
||||
|
||||
static bool audio_thread_alive(void *data)
|
||||
{
|
||||
bool alive = false;
|
||||
bool alive = false;
|
||||
audio_thread_t *thr = (audio_thread_t*)data;
|
||||
|
||||
if (!thr)
|
||||
@ -165,7 +165,7 @@ static bool audio_thread_alive(void *data)
|
||||
static bool audio_thread_stop(void *data)
|
||||
{
|
||||
audio_thread_t *thr = (audio_thread_t*)data;
|
||||
global_t *global = global_get_ptr();
|
||||
global_t *global = global_get_ptr();
|
||||
|
||||
if (!thr)
|
||||
return false;
|
||||
@ -180,7 +180,7 @@ static bool audio_thread_stop(void *data)
|
||||
static bool audio_thread_start(void *data)
|
||||
{
|
||||
audio_thread_t *thr = (audio_thread_t*)data;
|
||||
global_t *global = global_get_ptr();
|
||||
global_t *global = global_get_ptr();
|
||||
|
||||
if (!thr)
|
||||
return false;
|
||||
@ -252,32 +252,33 @@ static const audio_driver_t audio_thread = {
|
||||
*
|
||||
* Starts a audio driver in a new thread.
|
||||
* Access to audio driver will be mediated through this driver.
|
||||
* This driver interfaces with audio callback and is only used in that case.
|
||||
* This driver interfaces with audio callback and is
|
||||
* only used in that case.
|
||||
*
|
||||
* Returns: true (1) if successful, otherwise false (0).
|
||||
**/
|
||||
bool rarch_threaded_audio_init(const audio_driver_t **out_driver, void **out_data,
|
||||
const char *device, unsigned audio_out_rate, unsigned latency,
|
||||
const audio_driver_t *drv)
|
||||
bool rarch_threaded_audio_init(const audio_driver_t **out_driver,
|
||||
void **out_data, const char *device, unsigned audio_out_rate,
|
||||
unsigned latency, const audio_driver_t *drv)
|
||||
{
|
||||
audio_thread_t *thr = (audio_thread_t*)calloc(1, sizeof(*thr));
|
||||
if (!thr)
|
||||
return false;
|
||||
|
||||
thr->driver = (const audio_driver_t*)drv;
|
||||
thr->device = device;
|
||||
thr->out_rate = audio_out_rate;
|
||||
thr->latency = latency;
|
||||
thr->driver = (const audio_driver_t*)drv;
|
||||
thr->device = device;
|
||||
thr->out_rate = audio_out_rate;
|
||||
thr->latency = latency;
|
||||
|
||||
if (!(thr->cond = scond_new()))
|
||||
if (!(thr->cond = scond_new()))
|
||||
goto error;
|
||||
if (!(thr->lock = slock_new()))
|
||||
if (!(thr->lock = slock_new()))
|
||||
goto error;
|
||||
|
||||
thr->alive = true;
|
||||
thr->stopped = true;
|
||||
|
||||
if (!(thr->thread = sthread_create(audio_thread_loop, thr)))
|
||||
if (!(thr->thread = sthread_create(audio_thread_loop, thr)))
|
||||
goto error;
|
||||
|
||||
/* Wait until thread has initialized (or failed) the driver. */
|
||||
@ -289,13 +290,13 @@ bool rarch_threaded_audio_init(const audio_driver_t **out_driver, void **out_dat
|
||||
if (thr->inited < 0) /* Thread failed. */
|
||||
goto error;
|
||||
|
||||
*out_driver = &audio_thread;
|
||||
*out_data = thr;
|
||||
*out_driver = &audio_thread;
|
||||
*out_data = thr;
|
||||
return true;
|
||||
|
||||
error:
|
||||
*out_driver = NULL;
|
||||
*out_data = NULL;
|
||||
*out_driver = NULL;
|
||||
*out_data = NULL;
|
||||
audio_thread_free(thr);
|
||||
return false;
|
||||
}
|
||||
|
@ -553,38 +553,38 @@ static bool thread_init(thread_video_t *thr, const video_info_t *info,
|
||||
{
|
||||
size_t max_size;
|
||||
|
||||
thr->lock = slock_new();
|
||||
thr->alpha_lock = slock_new();
|
||||
thr->frame.lock = slock_new();
|
||||
thr->cond_cmd = scond_new();
|
||||
thr->cond_thread = scond_new();
|
||||
thr->input = input;
|
||||
thr->input_data = input_data;
|
||||
thr->info = *info;
|
||||
thr->alive = true;
|
||||
thr->focus = true;
|
||||
thr->has_windowed = true;
|
||||
thr->lock = slock_new();
|
||||
thr->alpha_lock = slock_new();
|
||||
thr->frame.lock = slock_new();
|
||||
thr->cond_cmd = scond_new();
|
||||
thr->cond_thread = scond_new();
|
||||
thr->input = input;
|
||||
thr->input_data = input_data;
|
||||
thr->info = *info;
|
||||
thr->alive = true;
|
||||
thr->focus = true;
|
||||
thr->has_windowed = true;
|
||||
thr->suppress_screensaver = true;
|
||||
|
||||
max_size = info->input_scale * RARCH_SCALE_BASE;
|
||||
max_size *= max_size;
|
||||
max_size *= info->rgb32 ? sizeof(uint32_t) : sizeof(uint16_t);
|
||||
thr->frame.buffer = (uint8_t*)malloc(max_size);
|
||||
max_size = info->input_scale * RARCH_SCALE_BASE;
|
||||
max_size *= max_size;
|
||||
max_size *= info->rgb32 ? sizeof(uint32_t) : sizeof(uint16_t);
|
||||
thr->frame.buffer = (uint8_t*)malloc(max_size);
|
||||
|
||||
if (!thr->frame.buffer)
|
||||
return false;
|
||||
|
||||
memset(thr->frame.buffer, 0x80, max_size);
|
||||
|
||||
thr->last_time = rarch_get_time_usec();
|
||||
|
||||
thr->thread = sthread_create(thread_loop, thr);
|
||||
thr->last_time = rarch_get_time_usec();
|
||||
thr->thread = sthread_create(thread_loop, thr);
|
||||
if (!thr->thread)
|
||||
return false;
|
||||
|
||||
thread_send_cmd(thr, CMD_INIT);
|
||||
thread_wait_reply(thr, CMD_INIT);
|
||||
|
||||
thr->send_cmd_func = thread_send_cmd;
|
||||
thr->send_cmd_func = thread_send_cmd;
|
||||
thr->wait_reply_func = thread_wait_reply;
|
||||
|
||||
return thr->cmd_data.b;
|
||||
@ -696,6 +696,9 @@ static bool thread_overlay_load(void *data,
|
||||
{
|
||||
thread_video_t *thr = (thread_video_t*)data;
|
||||
|
||||
if (!thr)
|
||||
return false;
|
||||
|
||||
thr->cmd_data.image.data = images;
|
||||
thr->cmd_data.image.num = num_images;
|
||||
thread_send_cmd(thr, CMD_OVERLAY_LOAD);
|
||||
@ -754,7 +757,7 @@ static void thread_overlay_set_alpha(void *data, unsigned idx, float mod)
|
||||
return;
|
||||
slock_lock(thr->alpha_lock);
|
||||
thr->alpha_mod[idx] = mod;
|
||||
thr->alpha_update = true;
|
||||
thr->alpha_update = true;
|
||||
slock_unlock(thr->alpha_lock);
|
||||
}
|
||||
|
||||
@ -798,7 +801,7 @@ static void thread_set_filtering(void *data, unsigned idx, bool smooth)
|
||||
|
||||
if (!thr)
|
||||
return;
|
||||
thr->cmd_data.filtering.index = idx;
|
||||
thr->cmd_data.filtering.index = idx;
|
||||
thr->cmd_data.filtering.smooth = smooth;
|
||||
thread_send_cmd(thr, CMD_POKE_SET_FILTERING);
|
||||
thread_wait_reply(thr, CMD_POKE_SET_FILTERING);
|
||||
@ -856,12 +859,12 @@ static void thread_set_texture_frame(void *data, const void *frame,
|
||||
thread_video_t *thr = (thread_video_t*)data;
|
||||
|
||||
slock_lock(thr->frame.lock);
|
||||
required = width * height *
|
||||
required = width * height *
|
||||
(rgb32 ? sizeof(uint32_t) : sizeof(uint16_t));
|
||||
|
||||
if (required > thr->texture.frame_cap)
|
||||
{
|
||||
thr->texture.frame = realloc(thr->texture.frame, required);
|
||||
thr->texture.frame = realloc(thr->texture.frame, required);
|
||||
thr->texture.frame_cap = required;
|
||||
}
|
||||
|
||||
@ -869,10 +872,10 @@ static void thread_set_texture_frame(void *data, const void *frame,
|
||||
{
|
||||
memcpy(thr->texture.frame, frame, required);
|
||||
thr->texture.frame_updated = true;
|
||||
thr->texture.rgb32 = rgb32;
|
||||
thr->texture.width = width;
|
||||
thr->texture.height = height;
|
||||
thr->texture.alpha = alpha;
|
||||
thr->texture.rgb32 = rgb32;
|
||||
thr->texture.width = width;
|
||||
thr->texture.height = height;
|
||||
thr->texture.alpha = alpha;
|
||||
}
|
||||
slock_unlock(thr->frame.lock);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user