diff --git a/audio/drivers/xaudio.c b/audio/drivers/xaudio.c index 59fbf5d15e..277e8ed671 100644 --- a/audio/drivers/xaudio.c +++ b/audio/drivers/xaudio.c @@ -57,12 +57,17 @@ typedef struct xaudio2 xaudio2_t; #define XAUDIO2_WRITE_AVAILABLE(handle) ((handle)->bufsize * (MAX_BUFFERS - (handle)->buffers - 1)) +enum xa_flags +{ + XA2_FLAG_NONBLOCK = (1 << 0), + XA2_FLAG_IS_PAUSED = (1 << 1) +}; + typedef struct { xaudio2_t *xa; size_t bufsize; - bool nonblock; - bool is_paused; + uint8_t flags; } xa_t; /* Forward declarations */ @@ -323,8 +328,7 @@ static void *xa_init(const char *device, unsigned rate, unsigned latency, bufsize = latency * rate / 1000; xa->bufsize = bufsize * 2 * sizeof(float); - xa->xa = xaudio2_new(rate, 2, xa->bufsize, device); - if (!xa->xa) + if (!(xa->xa = xaudio2_new(rate, 2, xa->bufsize, device))) { RARCH_ERR("[XAudio2] Failed to init driver.\n"); free(xa); @@ -344,7 +348,7 @@ static ssize_t xa_write(void *data, const void *buf, size_t size) xaudio2_t *handle = xa->xa; const uint8_t *buffer = (const uint8_t*)buf; - if (xa->nonblock) + if (xa->flags & XA2_FLAG_NONBLOCK) { size_t avail = XAUDIO2_WRITE_AVAILABLE(xa->xa); @@ -403,8 +407,8 @@ static ssize_t xa_write(void *data, const void *buf, size_t size) static bool xa_stop(void *data) { - xa_t *xa = (xa_t*)data; - xa->is_paused = true; + xa_t *xa = (xa_t*)data; + xa->flags |= XA2_FLAG_IS_PAUSED; return true; } @@ -413,20 +417,25 @@ static bool xa_alive(void *data) xa_t *xa = (xa_t*)data; if (!xa) return false; - return !xa->is_paused; + return !(xa->flags & XA2_FLAG_IS_PAUSED); } static void xa_set_nonblock_state(void *data, bool state) { xa_t *xa = (xa_t*)data; if (xa) - xa->nonblock = state; + { + if (state) + xa->flags |= XA2_FLAG_NONBLOCK; + else + xa->flags &= ~XA2_FLAG_NONBLOCK; + } } static bool xa_start(void *data, bool is_shutdown) { - xa_t *xa = (xa_t*)data; - xa->is_paused = false; + xa_t *xa = (xa_t*)data; + xa->flags &= ~(XA2_FLAG_IS_PAUSED); return true; } diff --git a/gfx/video_driver.c b/gfx/video_driver.c index e4fa9ad5ec..025cecedc8 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -216,7 +216,7 @@ struct aspect_ratio_elem aspectratio_lut[ASPECT_RATIO_END] = { static void *video_null_init(const video_info_t *video, input_driver_t **input, void **input_data) { - *input = NULL; + *input = NULL; *input_data = NULL; frontend_driver_install_signal_handler(); @@ -224,21 +224,15 @@ static void *video_null_init(const video_info_t *video, return (void*)-1; } -static bool video_null_frame(void *data, const void *frame, - unsigned frame_width, unsigned frame_height, uint64_t frame_count, - unsigned pitch, const char *msg, video_frame_info_t *video_info) -{ - return true; -} - -static void video_null_free(void *data) { } -static void video_null_set_nonblock_state(void *a, bool b, bool c, unsigned d) { } -static bool video_null_alive(void *data) { return frontend_driver_get_signal_handler_state() != 1; } -static bool video_null_focus(void *data) { return true; } -static bool video_null_has_windowed(void *data) { return true; } -static bool video_null_suppress_screensaver(void *data, bool enable) { return false; } -static bool video_null_set_shader(void *data, - enum rarch_shader_type type, const char *path) { return false; } +static bool video_null_frame(void *, const void *, unsigned, unsigned, uint64_t, +unsigned, const char *, video_frame_info_t *) { return true; } +static void video_null_free(void *) { } +static void video_null_set_nonblock_state(void *, bool, bool, unsigned) { } +static bool video_null_alive(void *) { return frontend_driver_get_signal_handler_state() != 1; } +static bool video_null_focus(void *) { return true; } +static bool video_null_has_windowed(void *) { return true; } +static bool video_null_suppress_screensaver(void *, bool) { return false; } +static bool video_null_set_shader(void *, enum rarch_shader_type, const char *) { return false; } video_driver_t video_null = { video_null_init, diff --git a/retroarch_types.h b/retroarch_types.h index c78dc92b70..05c647810e 100644 --- a/retroarch_types.h +++ b/retroarch_types.h @@ -367,6 +367,14 @@ typedef struct content_file_list size_t size; } content_file_list_t; +enum content_state_flags +{ + CONTENT_ST_FLAG_IS_INITED = (1 << 0), + CONTENT_ST_FLAG_CORE_DOES_NOT_NEED_CONTENT = (1 << 1), + CONTENT_ST_FLAG_PENDING_SUBSYSTEM_INIT = (1 << 2), + CONTENT_ST_FLAG_PENDING_ROM_CRC = (1 << 3) +}; + typedef struct content_state { char *pending_subsystem_roms[RARCH_MAX_SUBSYSTEM_ROMS]; @@ -378,16 +386,12 @@ typedef struct content_state int pending_subsystem_id; unsigned pending_subsystem_rom_id; uint32_t rom_crc; + uint8_t flags; char companion_ui_crc32[32]; char pending_subsystem_ident[255]; char pending_rom_crc_path[PATH_MAX_LENGTH]; char companion_ui_db_name[PATH_MAX_LENGTH]; - - bool is_inited; - bool core_does_not_need_content; - bool pending_subsystem_init; - bool pending_rom_crc; } content_state_t; RETRO_END_DECLS diff --git a/tasks/task_content.c b/tasks/task_content.c index 882a37bfae..c0d2b14bd2 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -759,7 +759,7 @@ static bool content_file_load_into_memory( and then encode the CRC32 hash */ strlcpy(p_content->pending_rom_crc_path, content_path, sizeof(p_content->pending_rom_crc_path)); - p_content->pending_rom_crc = true; + p_content->flags |= CONTENT_ST_FLAG_PENDING_ROM_CRC; } } else @@ -1105,7 +1105,7 @@ static bool content_file_load( { strlcpy(p_content->pending_rom_crc_path, content_path, sizeof(p_content->pending_rom_crc_path)); - p_content->pending_rom_crc = true; + p_content->flags |= CONTENT_ST_FLAG_PENDING_ROM_CRC; } else p_content->rom_crc = 0; @@ -1461,7 +1461,7 @@ static bool content_load(content_ctx_info_t *info, if (!success) return false; - if (p_content->pending_subsystem_init) + if (p_content->flags & CONTENT_ST_FLAG_PENDING_SUBSYSTEM_INIT) { command_event(CMD_EVENT_CORE_INIT, NULL); content_clear_subsystem(); @@ -2747,7 +2747,7 @@ bool task_push_load_subsystem_with_core( { content_state_t *p_content = content_state_get_ptr(); - p_content->pending_subsystem_init = true; + p_content->flags |= CONTENT_ST_FLAG_PENDING_SUBSYSTEM_INIT; /* Load content */ #ifdef HAVE_MENU if (!task_load_content_internal(content_info, true, false, false)) @@ -2770,18 +2770,19 @@ void content_get_status( { content_state_t *p_content = content_state_get_ptr(); - *contentless = p_content->core_does_not_need_content; - *is_inited = p_content->is_inited; + *contentless = (p_content->flags & + CONTENT_ST_FLAG_CORE_DOES_NOT_NEED_CONTENT); + *is_inited = (p_content->flags & CONTENT_ST_FLAG_IS_INITED); } /* Clears the pending subsystem rom buffer*/ void content_clear_subsystem(void) { unsigned i; - content_state_t *p_content = content_state_get_ptr(); + content_state_t *p_content = content_state_get_ptr(); - p_content->pending_subsystem_rom_id = 0; - p_content->pending_subsystem_init = false; + p_content->pending_subsystem_rom_id = 0; + p_content->flags &= ~CONTENT_ST_FLAG_PENDING_SUBSYSTEM_INIT; for (i = 0; i < RARCH_MAX_SUBSYSTEM_ROMS; i++) { @@ -2897,13 +2898,13 @@ void content_add_subsystem(const char* path) void content_set_does_not_need_content(void) { content_state_t *p_content = content_state_get_ptr(); - p_content->core_does_not_need_content = true; + p_content->flags |= CONTENT_ST_FLAG_CORE_DOES_NOT_NEED_CONTENT; } void content_unset_does_not_need_content(void) { content_state_t *p_content = content_state_get_ptr(); - p_content->core_does_not_need_content = false; + p_content->flags &= ~CONTENT_ST_FLAG_CORE_DOES_NOT_NEED_CONTENT; } #ifndef CRC32_BUFFER_SIZE @@ -2960,9 +2961,9 @@ static uint32_t file_crc32(uint32_t crc, const char *path) uint32_t content_get_crc(void) { content_state_t *p_content = content_state_get_ptr(); - if (p_content->pending_rom_crc) + if (p_content->flags & CONTENT_ST_FLAG_PENDING_ROM_CRC) { - p_content->pending_rom_crc = false; + p_content->flags &= ~CONTENT_ST_FLAG_PENDING_ROM_CRC; /* TODO/FIXME - file_crc32 has a 64MB max limit - * get rid of this function and find a better * way to calculate CRC based on the file */ @@ -2983,7 +2984,7 @@ char* content_get_subsystem_rom(unsigned index) bool content_is_inited(void) { content_state_t *p_content = content_state_get_ptr(); - return p_content->is_inited; + return ((p_content->flags & CONTENT_ST_FLAG_IS_INITED) > 0); } void content_deinit(void) @@ -2995,16 +2996,18 @@ void content_deinit(void) p_content->content_list = NULL; p_content->rom_crc = 0; - p_content->is_inited = false; - p_content->core_does_not_need_content = false; - p_content->pending_rom_crc = false; + p_content->flags &= ~(CONTENT_ST_FLAG_PENDING_ROM_CRC + | CONTENT_ST_FLAG_CORE_DOES_NOT_NEED_CONTENT + | CONTENT_ST_FLAG_IS_INITED + ) + ; } /* Set environment variables before a subsystem load */ void content_set_subsystem_info(void) { content_state_t *p_content = content_state_get_ptr(); - if (!p_content->pending_subsystem_init) + if (!(p_content->flags & CONTENT_ST_FLAG_PENDING_SUBSYSTEM_INIT)) return; path_set(RARCH_PATH_SUBSYSTEM, p_content->pending_subsystem_ident); @@ -3067,28 +3070,28 @@ bool content_init(void) if (sys_info) { - struct retro_system_info *system = &runloop_state_get_ptr()->system.info; + struct retro_system_info *system = &runloop_state_get_ptr()->system.info; if (set_supports_no_game_enable) content_ctx.flags |= CONTENT_INFO_FLAG_SET_SUPPORTS_NO_GAME_ENABLE; if (!string_is_empty(path_dir_system)) - content_ctx.directory_system = strdup(path_dir_system); + content_ctx.directory_system = strdup(path_dir_system); if (!string_is_empty(path_dir_cache)) - content_ctx.directory_cache = strdup(path_dir_cache); + content_ctx.directory_cache = strdup(path_dir_cache); if (!string_is_empty(system->valid_extensions)) - content_ctx.valid_extensions = strdup(system->valid_extensions); + content_ctx.valid_extensions = strdup(system->valid_extensions); if (system->block_extract) - content_ctx.flags |= CONTENT_INFO_FLAG_BLOCK_EXTRACT; + content_ctx.flags |= CONTENT_INFO_FLAG_BLOCK_EXTRACT; if (system->need_fullpath) - content_ctx.flags |= CONTENT_INFO_FLAG_NEED_FULLPATH; + content_ctx.flags |= CONTENT_INFO_FLAG_NEED_FULLPATH; - content_ctx.subsystem.data = sys_info->subsystem.data; - content_ctx.subsystem.size = sys_info->subsystem.size; + content_ctx.subsystem.data = sys_info->subsystem.data; + content_ctx.subsystem.size = sys_info->subsystem.size; } - p_content->is_inited = true; + p_content->flags |= CONTENT_ST_FLAG_IS_INITED; if (string_list_initialize(&content)) {