mirror of
https://github.com/libretro/RetroArch
synced 2025-03-27 23:37:39 +00:00
(runloop_data.c) Cleanups/style nits
This commit is contained in:
parent
89366b9b35
commit
f16e19e5b4
100
runloop_data.c
100
runloop_data.c
@ -842,29 +842,29 @@ static void data_runloop_thread_deinit(data_runloop_t *runloop)
|
|||||||
|
|
||||||
void rarch_main_data_deinit(void)
|
void rarch_main_data_deinit(void)
|
||||||
{
|
{
|
||||||
data_runloop_t *data_runloop = (data_runloop_t*)rarch_main_data_get_ptr();
|
data_runloop_t *runloop = (data_runloop_t*)rarch_main_data_get_ptr();
|
||||||
|
|
||||||
if (!data_runloop)
|
if (!runloop)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#ifdef HAVE_THREADS
|
#ifdef HAVE_THREADS
|
||||||
if (data_runloop->thread_inited)
|
if (runloop->thread_inited)
|
||||||
{
|
{
|
||||||
data_runloop_thread_deinit(data_runloop);
|
data_runloop_thread_deinit(runloop);
|
||||||
data_runloop->thread_code = THREAD_CODE_DEINIT;
|
runloop->thread_code = THREAD_CODE_DEINIT;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
data_runloop->inited = false;
|
runloop->inited = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void rarch_main_data_free(void)
|
void rarch_main_data_free(void)
|
||||||
{
|
{
|
||||||
data_runloop_t *data_runloop = (data_runloop_t*)rarch_main_data_get_ptr();
|
data_runloop_t *runloop = (data_runloop_t*)rarch_main_data_get_ptr();
|
||||||
|
|
||||||
if (data_runloop)
|
if (runloop)
|
||||||
free(data_runloop);
|
free(runloop);
|
||||||
data_runloop = NULL;
|
runloop = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void data_runloop_iterate(bool is_thread, data_runloop_t *runloop)
|
static void data_runloop_iterate(bool is_thread, data_runloop_t *runloop)
|
||||||
@ -912,32 +912,32 @@ static void data_thread_loop(void *data)
|
|||||||
|
|
||||||
static void rarch_main_data_thread_init(void)
|
static void rarch_main_data_thread_init(void)
|
||||||
{
|
{
|
||||||
data_runloop_t *data_runloop = (data_runloop_t*)rarch_main_data_get_ptr();
|
data_runloop_t *runloop = (data_runloop_t*)rarch_main_data_get_ptr();
|
||||||
|
|
||||||
if (!data_runloop)
|
if (!runloop)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
data_runloop->lock = slock_new();
|
runloop->lock = slock_new();
|
||||||
data_runloop->cond_lock = slock_new();
|
runloop->cond_lock = slock_new();
|
||||||
data_runloop->overlay_lock = slock_new();
|
runloop->overlay_lock = slock_new();
|
||||||
data_runloop->cond = scond_new();
|
runloop->cond = scond_new();
|
||||||
|
|
||||||
data_runloop->thread = sthread_create(data_thread_loop, data_runloop);
|
runloop->thread = sthread_create(data_thread_loop, runloop);
|
||||||
|
|
||||||
if (!data_runloop->thread)
|
if (!runloop->thread)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
data_runloop->thread_inited = true;
|
runloop->thread_inited = true;
|
||||||
data_runloop->alive = true;
|
runloop->alive = true;
|
||||||
data_runloop->thread_code = THREAD_CODE_ALIVE;
|
runloop->thread_code = THREAD_CODE_ALIVE;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
slock_free(data_runloop->lock);
|
slock_free(runloop->lock);
|
||||||
slock_free(data_runloop->cond_lock);
|
slock_free(runloop->cond_lock);
|
||||||
slock_free(data_runloop->overlay_lock);
|
slock_free(runloop->overlay_lock);
|
||||||
scond_free(data_runloop->cond);
|
scond_free(runloop->cond);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -968,14 +968,14 @@ static void rarch_main_data_nbio_image_upload_iterate(bool is_thread,
|
|||||||
|
|
||||||
void rarch_main_data_iterate(void)
|
void rarch_main_data_iterate(void)
|
||||||
{
|
{
|
||||||
data_runloop_t *data_runloop = (data_runloop_t*)rarch_main_data_get_ptr();
|
data_runloop_t *runloop = (data_runloop_t*)rarch_main_data_get_ptr();
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
|
|
||||||
(void)settings;
|
(void)settings;
|
||||||
#ifdef HAVE_THREADS
|
#ifdef HAVE_THREADS
|
||||||
if (settings->menu.threaded_data_runloop_enable)
|
if (settings->menu.threaded_data_runloop_enable)
|
||||||
{
|
{
|
||||||
switch (data_runloop->thread_code)
|
switch (runloop->thread_code)
|
||||||
{
|
{
|
||||||
case THREAD_CODE_INIT:
|
case THREAD_CODE_INIT:
|
||||||
rarch_main_data_thread_init();
|
rarch_main_data_thread_init();
|
||||||
@ -988,9 +988,9 @@ void rarch_main_data_iterate(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_OVERLAY
|
#ifdef HAVE_OVERLAY
|
||||||
rarch_main_data_overlay_iterate(false, data_runloop);
|
rarch_main_data_overlay_iterate(false, runloop);
|
||||||
#endif
|
#endif
|
||||||
rarch_main_data_nbio_image_upload_iterate(false, data_runloop);
|
rarch_main_data_nbio_image_upload_iterate(false, runloop);
|
||||||
|
|
||||||
if (data_runloop_msg[0] != '\0')
|
if (data_runloop_msg[0] != '\0')
|
||||||
{
|
{
|
||||||
@ -999,28 +999,28 @@ void rarch_main_data_iterate(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_THREADS
|
#ifdef HAVE_THREADS
|
||||||
if (settings->menu.threaded_data_runloop_enable && data_runloop->alive)
|
if (settings->menu.threaded_data_runloop_enable && runloop->alive)
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
data_runloop_iterate(false, data_runloop);
|
data_runloop_iterate(false, runloop);
|
||||||
}
|
}
|
||||||
|
|
||||||
static data_runloop_t *rarch_main_data_new(void)
|
static data_runloop_t *rarch_main_data_new(void)
|
||||||
{
|
{
|
||||||
data_runloop_t *data_runloop = (data_runloop_t*)calloc(1, sizeof(data_runloop_t));
|
data_runloop_t *runloop = (data_runloop_t*)calloc(1, sizeof(data_runloop_t));
|
||||||
|
|
||||||
if (!data_runloop)
|
if (!runloop)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
#ifdef HAVE_THREADS
|
#ifdef HAVE_THREADS
|
||||||
data_runloop->thread_inited = false;
|
runloop->thread_inited = false;
|
||||||
data_runloop->alive = false;
|
runloop->alive = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
data_runloop->inited = true;
|
runloop->inited = true;
|
||||||
|
|
||||||
return data_runloop;
|
return runloop;
|
||||||
}
|
}
|
||||||
|
|
||||||
void rarch_main_data_clear_state(void)
|
void rarch_main_data_clear_state(void)
|
||||||
@ -1033,18 +1033,18 @@ void rarch_main_data_clear_state(void)
|
|||||||
|
|
||||||
void rarch_main_data_init_queues(void)
|
void rarch_main_data_init_queues(void)
|
||||||
{
|
{
|
||||||
data_runloop_t *data_runloop = (data_runloop_t*)rarch_main_data_get_ptr();
|
data_runloop_t *runloop = (data_runloop_t*)rarch_main_data_get_ptr();
|
||||||
#ifdef HAVE_NETWORKING
|
#ifdef HAVE_NETWORKING
|
||||||
if (!data_runloop->http.msg_queue)
|
if (!runloop->http.msg_queue)
|
||||||
rarch_assert(data_runloop->http.msg_queue = msg_queue_new(8));
|
rarch_assert(runloop->http.msg_queue = msg_queue_new(8));
|
||||||
#endif
|
#endif
|
||||||
if (!data_runloop->nbio.msg_queue)
|
if (!runloop->nbio.msg_queue)
|
||||||
rarch_assert(data_runloop->nbio.msg_queue = msg_queue_new(8));
|
rarch_assert(runloop->nbio.msg_queue = msg_queue_new(8));
|
||||||
if (!data_runloop->nbio.image.msg_queue)
|
if (!runloop->nbio.image.msg_queue)
|
||||||
rarch_assert(data_runloop->nbio.image.msg_queue = msg_queue_new(8));
|
rarch_assert(runloop->nbio.image.msg_queue = msg_queue_new(8));
|
||||||
#ifdef HAVE_LIBRETRODB
|
#ifdef HAVE_LIBRETRODB
|
||||||
if (!data_runloop->db.msg_queue)
|
if (!runloop->db.msg_queue)
|
||||||
rarch_assert(data_runloop->db.msg_queue = msg_queue_new(8));
|
rarch_assert(runloop->db.msg_queue = msg_queue_new(8));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1054,23 +1054,23 @@ void rarch_main_data_msg_queue_push(unsigned type,
|
|||||||
{
|
{
|
||||||
char new_msg[PATH_MAX_LENGTH];
|
char new_msg[PATH_MAX_LENGTH];
|
||||||
msg_queue_t *queue = NULL;
|
msg_queue_t *queue = NULL;
|
||||||
data_runloop_t *data_runloop = (data_runloop_t*)rarch_main_data_get_ptr();
|
data_runloop_t *runloop = (data_runloop_t*)rarch_main_data_get_ptr();
|
||||||
|
|
||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
case DATA_TYPE_NONE:
|
case DATA_TYPE_NONE:
|
||||||
break;
|
break;
|
||||||
case DATA_TYPE_FILE:
|
case DATA_TYPE_FILE:
|
||||||
queue = data_runloop->nbio.msg_queue;
|
queue = runloop->nbio.msg_queue;
|
||||||
snprintf(new_msg, sizeof(new_msg), "%s|%s", msg, msg2);
|
snprintf(new_msg, sizeof(new_msg), "%s|%s", msg, msg2);
|
||||||
break;
|
break;
|
||||||
case DATA_TYPE_IMAGE:
|
case DATA_TYPE_IMAGE:
|
||||||
queue = data_runloop->nbio.image.msg_queue;
|
queue = runloop->nbio.image.msg_queue;
|
||||||
snprintf(new_msg, sizeof(new_msg), "%s|%s", msg, msg2);
|
snprintf(new_msg, sizeof(new_msg), "%s|%s", msg, msg2);
|
||||||
break;
|
break;
|
||||||
#ifdef HAVE_NETWORKING
|
#ifdef HAVE_NETWORKING
|
||||||
case DATA_TYPE_HTTP:
|
case DATA_TYPE_HTTP:
|
||||||
queue = data_runloop->http.msg_queue;
|
queue = runloop->http.msg_queue;
|
||||||
snprintf(new_msg, sizeof(new_msg), "%s|%s", msg, msg2);
|
snprintf(new_msg, sizeof(new_msg), "%s|%s", msg, msg2);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user