(runloop_data.c) Cleanups/style nits

This commit is contained in:
twinaphex 2015-04-11 09:33:20 +02:00
parent 89366b9b35
commit f16e19e5b4

View File

@ -842,29 +842,29 @@ static void data_runloop_thread_deinit(data_runloop_t *runloop)
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;
#ifdef HAVE_THREADS
if (data_runloop->thread_inited)
if (runloop->thread_inited)
{
data_runloop_thread_deinit(data_runloop);
data_runloop->thread_code = THREAD_CODE_DEINIT;
data_runloop_thread_deinit(runloop);
runloop->thread_code = THREAD_CODE_DEINIT;
}
#endif
data_runloop->inited = false;
runloop->inited = false;
}
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)
free(data_runloop);
data_runloop = NULL;
if (runloop)
free(runloop);
runloop = NULL;
}
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)
{
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;
data_runloop->lock = slock_new();
data_runloop->cond_lock = slock_new();
data_runloop->overlay_lock = slock_new();
data_runloop->cond = scond_new();
runloop->lock = slock_new();
runloop->cond_lock = slock_new();
runloop->overlay_lock = slock_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;
data_runloop->thread_inited = true;
data_runloop->alive = true;
data_runloop->thread_code = THREAD_CODE_ALIVE;
runloop->thread_inited = true;
runloop->alive = true;
runloop->thread_code = THREAD_CODE_ALIVE;
return;
error:
slock_free(data_runloop->lock);
slock_free(data_runloop->cond_lock);
slock_free(data_runloop->overlay_lock);
scond_free(data_runloop->cond);
slock_free(runloop->lock);
slock_free(runloop->cond_lock);
slock_free(runloop->overlay_lock);
scond_free(runloop->cond);
}
#endif
@ -968,14 +968,14 @@ static void rarch_main_data_nbio_image_upload_iterate(bool is_thread,
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();
(void)settings;
#ifdef HAVE_THREADS
if (settings->menu.threaded_data_runloop_enable)
{
switch (data_runloop->thread_code)
switch (runloop->thread_code)
{
case THREAD_CODE_INIT:
rarch_main_data_thread_init();
@ -988,9 +988,9 @@ void rarch_main_data_iterate(void)
#endif
#ifdef HAVE_OVERLAY
rarch_main_data_overlay_iterate(false, data_runloop);
rarch_main_data_overlay_iterate(false, runloop);
#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')
{
@ -999,28 +999,28 @@ void rarch_main_data_iterate(void)
}
#ifdef HAVE_THREADS
if (settings->menu.threaded_data_runloop_enable && data_runloop->alive)
if (settings->menu.threaded_data_runloop_enable && runloop->alive)
return;
#endif
data_runloop_iterate(false, data_runloop);
data_runloop_iterate(false, runloop);
}
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;
#ifdef HAVE_THREADS
data_runloop->thread_inited = false;
data_runloop->alive = false;
runloop->thread_inited = false;
runloop->alive = false;
#endif
data_runloop->inited = true;
runloop->inited = true;
return data_runloop;
return runloop;
}
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)
{
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
if (!data_runloop->http.msg_queue)
rarch_assert(data_runloop->http.msg_queue = msg_queue_new(8));
if (!runloop->http.msg_queue)
rarch_assert(runloop->http.msg_queue = msg_queue_new(8));
#endif
if (!data_runloop->nbio.msg_queue)
rarch_assert(data_runloop->nbio.msg_queue = msg_queue_new(8));
if (!data_runloop->nbio.image.msg_queue)
rarch_assert(data_runloop->nbio.image.msg_queue = msg_queue_new(8));
if (!runloop->nbio.msg_queue)
rarch_assert(runloop->nbio.msg_queue = msg_queue_new(8));
if (!runloop->nbio.image.msg_queue)
rarch_assert(runloop->nbio.image.msg_queue = msg_queue_new(8));
#ifdef HAVE_LIBRETRODB
if (!data_runloop->db.msg_queue)
rarch_assert(data_runloop->db.msg_queue = msg_queue_new(8));
if (!runloop->db.msg_queue)
rarch_assert(runloop->db.msg_queue = msg_queue_new(8));
#endif
}
@ -1054,23 +1054,23 @@ void rarch_main_data_msg_queue_push(unsigned type,
{
char new_msg[PATH_MAX_LENGTH];
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)
{
case DATA_TYPE_NONE:
break;
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);
break;
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);
break;
#ifdef HAVE_NETWORKING
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);
break;
#endif