Reduce size of variables

This commit is contained in:
twinaphex 2017-09-08 23:44:10 +02:00
parent eb12526b79
commit 79f1166c6e
5 changed files with 51 additions and 35 deletions

View File

@ -187,7 +187,8 @@ static void *audio_driver_context_audio_data = NULL;
**/ **/
static void compute_audio_buffer_statistics(void) static void compute_audio_buffer_statistics(void)
{ {
unsigned i, low_water_size, high_water_size, avg, stddev; uint8_t i;
unsigned low_water_size, high_water_size, avg, stddev;
float avg_filled = 0.0f; float avg_filled = 0.0f;
float deviation = 0.0f; float deviation = 0.0f;
uint64_t accum = 0; uint64_t accum = 0;
@ -810,7 +811,7 @@ void audio_driver_monitor_adjust_system_rates(void)
void audio_driver_setup_rewind(void) void audio_driver_setup_rewind(void)
{ {
unsigned i; uint8_t i;
/* Push audio ready to be played. */ /* Push audio ready to be played. */
audio_driver_rewind_ptr = audio_driver_rewind_size; audio_driver_rewind_ptr = audio_driver_rewind_size;
@ -844,7 +845,7 @@ bool audio_driver_find_driver(void)
current_audio = (const audio_driver_t*)audio_driver_find_handle(i); current_audio = (const audio_driver_t*)audio_driver_find_handle(i);
else else
{ {
unsigned d; uint8_t d;
RARCH_ERR("Couldn't find any audio driver named \"%s\"\n", RARCH_ERR("Couldn't find any audio driver named \"%s\"\n",
settings->arrays.audio_driver); settings->arrays.audio_driver);
RARCH_LOG_OUTPUT("Available audio drivers are:\n"); RARCH_LOG_OUTPUT("Available audio drivers are:\n");
@ -909,7 +910,7 @@ bool audio_driver_get_devices_list(void **data)
bool audio_driver_mixer_extension_supported(const char *ext) bool audio_driver_mixer_extension_supported(const char *ext)
{ {
union string_list_elem_attr attr; union string_list_elem_attr attr;
unsigned i; uint8_t i;
bool ret = false; bool ret = false;
struct string_list *str_list = string_list_new(); struct string_list *str_list = string_list_new();
@ -942,7 +943,7 @@ bool audio_driver_mixer_extension_supported(const char *ext)
static int audio_mixer_find_index(audio_mixer_sound_t *sound) static int audio_mixer_find_index(audio_mixer_sound_t *sound)
{ {
unsigned i; uint8_t i;
for (i = 0; i < AUDIO_MIXER_MAX_STREAMS; i++) for (i = 0; i < AUDIO_MIXER_MAX_STREAMS; i++)
{ {
@ -1091,7 +1092,7 @@ static void audio_driver_mixer_remove_stream(unsigned i)
static void audio_driver_mixer_deinit(void) static void audio_driver_mixer_deinit(void)
{ {
unsigned i; uint8_t i;
audio_set_bool(AUDIO_ACTION_MIXER, false); audio_set_bool(AUDIO_ACTION_MIXER, false);

View File

@ -145,7 +145,7 @@ static const void *find_driver_nonempty(const char *label, int i,
**/ **/
static int driver_find_index(const char * label, const char *drv) static int driver_find_index(const char * label, const char *drv)
{ {
unsigned i; uint8_t i;
char str[256]; char str[256];
str[0] = '\0'; str[0] = '\0';
@ -178,7 +178,7 @@ static bool driver_find_first(const char *label, char *s, size_t len)
**/ **/
static bool driver_find_last(const char *label, char *s, size_t len) static bool driver_find_last(const char *label, char *s, size_t len)
{ {
unsigned i; uint8_t i;
for (i = 0; for (i = 0;
find_driver_nonempty(label, i, s, len) != NULL; i++) find_driver_nonempty(label, i, s, len) != NULL; i++)
@ -290,9 +290,11 @@ void driver_set_nonblock_state(void)
* *
* Returns: true (1) if successful, otherwise false (0). * Returns: true (1) if successful, otherwise false (0).
**/ **/
static bool driver_update_system_av_info(const struct retro_system_av_info *info) static bool driver_update_system_av_info(
const struct retro_system_av_info *info)
{ {
struct retro_system_av_info *av_info = video_viewport_get_system_av_info(); struct retro_system_av_info *av_info =
video_viewport_get_system_av_info();
memcpy(av_info, info, sizeof(*av_info)); memcpy(av_info, info, sizeof(*av_info));
command_event(CMD_EVENT_REINIT, NULL); command_event(CMD_EVENT_REINIT, NULL);
@ -302,7 +304,8 @@ static bool driver_update_system_av_info(const struct retro_system_av_info *info
if (recording_driver_get_data_ptr()) if (recording_driver_get_data_ptr())
{ {
runloop_msg_queue_push( runloop_msg_queue_push(
msg_hash_to_str(MSG_RESTARTING_RECORDING_DUE_TO_DRIVER_REINIT), msg_hash_to_str(
MSG_RESTARTING_RECORDING_DUE_TO_DRIVER_REINIT),
2, 180, false); 2, 180, false);
command_event(CMD_EVENT_RECORD_DEINIT, NULL); command_event(CMD_EVENT_RECORD_DEINIT, NULL);
command_event(CMD_EVENT_RECORD_INIT, NULL); command_event(CMD_EVENT_RECORD_INIT, NULL);
@ -365,11 +368,13 @@ void drivers_init(int flags)
} }
/* Only initialize camera driver if we're ever going to use it. */ /* Only initialize camera driver if we're ever going to use it. */
if ((flags & DRIVER_CAMERA_MASK) && camera_driver_ctl(RARCH_CAMERA_CTL_IS_ACTIVE, NULL)) if ((flags & DRIVER_CAMERA_MASK) &&
camera_driver_ctl(RARCH_CAMERA_CTL_IS_ACTIVE, NULL))
camera_driver_ctl(RARCH_CAMERA_CTL_INIT, NULL); camera_driver_ctl(RARCH_CAMERA_CTL_INIT, NULL);
/* Only initialize location driver if we're ever going to use it. */ /* Only initialize location driver if we're ever going to use it. */
if ((flags & DRIVER_LOCATION_MASK) && location_driver_ctl(RARCH_LOCATION_CTL_IS_ACTIVE, NULL)) if ((flags & DRIVER_LOCATION_MASK) &&
location_driver_ctl(RARCH_LOCATION_CTL_IS_ACTIVE, NULL))
init_location(); init_location();
core_info_init_current_core(); core_info_init_current_core();
@ -402,7 +407,8 @@ void drivers_init(int flags)
**/ **/
/** /**
* Driver ownership - set this to true if the platform in question needs to 'own' * Driver ownership - set this to true if the platform in
* question needs to 'own'
* the respective handle and therefore skip regular RetroArch * the respective handle and therefore skip regular RetroArch
* driver teardown/reiniting procedure. * driver teardown/reiniting procedure.
* *
@ -425,13 +431,16 @@ void driver_uninit(int flags)
menu_driver_ctl(RARCH_MENU_CTL_DEINIT, NULL); menu_driver_ctl(RARCH_MENU_CTL_DEINIT, NULL);
#endif #endif
if ((flags & DRIVER_LOCATION_MASK) && !location_driver_ctl(RARCH_LOCATION_CTL_OWNS_DRIVER, NULL)) if ((flags & DRIVER_LOCATION_MASK) &&
!location_driver_ctl(RARCH_LOCATION_CTL_OWNS_DRIVER, NULL))
location_driver_ctl(RARCH_LOCATION_CTL_DEINIT, NULL); location_driver_ctl(RARCH_LOCATION_CTL_DEINIT, NULL);
if ((flags & DRIVER_CAMERA_MASK) && !camera_driver_ctl(RARCH_CAMERA_CTL_OWNS_DRIVER, NULL)) if ((flags & DRIVER_CAMERA_MASK) &&
!camera_driver_ctl(RARCH_CAMERA_CTL_OWNS_DRIVER, NULL))
camera_driver_ctl(RARCH_CAMERA_CTL_DEINIT, NULL); camera_driver_ctl(RARCH_CAMERA_CTL_DEINIT, NULL);
if ((flags & DRIVER_WIFI_MASK) && !wifi_driver_ctl(RARCH_WIFI_CTL_OWNS_DRIVER, NULL)) if ((flags & DRIVER_WIFI_MASK) &&
!wifi_driver_ctl(RARCH_WIFI_CTL_OWNS_DRIVER, NULL))
wifi_driver_ctl(RARCH_WIFI_CTL_DEINIT, NULL); wifi_driver_ctl(RARCH_WIFI_CTL_DEINIT, NULL);
if (flags & DRIVERS_VIDEO_INPUT) if (flags & DRIVERS_VIDEO_INPUT)
@ -487,7 +496,8 @@ bool driver_ctl(enum driver_ctl_state state, void *data)
break; break;
case RARCH_DRIVER_CTL_UPDATE_SYSTEM_AV_INFO: case RARCH_DRIVER_CTL_UPDATE_SYSTEM_AV_INFO:
{ {
const struct retro_system_av_info **info = (const struct retro_system_av_info**)data; const struct retro_system_av_info **info
= (const struct retro_system_av_info**)data;
if (info) if (info)
return driver_update_system_av_info(*info); return driver_update_system_av_info(*info);
} }

View File

@ -219,7 +219,7 @@ static void gl_overlay_tex_geom(void *data,
static void gl_render_overlay(gl_t *gl, video_frame_info_t *video_info) static void gl_render_overlay(gl_t *gl, video_frame_info_t *video_info)
{ {
video_shader_ctx_coords_t coords; video_shader_ctx_coords_t coords;
unsigned i; uint8_t i;
unsigned width = video_info->width; unsigned width = video_info->width;
unsigned height = video_info->height; unsigned height = video_info->height;
@ -563,7 +563,7 @@ static void gl_update_input_size(gl_t *gl, unsigned width,
static void gl_init_textures_data(gl_t *gl) static void gl_init_textures_data(gl_t *gl)
{ {
unsigned i; uint8_t i;
for (i = 0; i < gl->textures; i++) for (i = 0; i < gl->textures; i++)
{ {
@ -610,7 +610,7 @@ static void gl_init_textures_reference(gl_t *gl, unsigned i,
static void gl_init_textures(gl_t *gl, const video_info_t *video) static void gl_init_textures(gl_t *gl, const video_info_t *video)
{ {
unsigned i; uint8_t i;
GLenum internal_fmt, texture_type = 0, texture_fmt = 0; GLenum internal_fmt, texture_type = 0, texture_fmt = 0;
(void)texture_type; (void)texture_type;
@ -682,8 +682,7 @@ static INLINE void gl_copy_frame(gl_t *gl,
size_t buffer_stride = gl->tex_w * gl->base_size; size_t buffer_stride = gl->tex_w * gl->base_size;
const uint8_t *frame_copy = frame; const uint8_t *frame_copy = frame;
size_t frame_copy_size = width * gl->base_size; size_t frame_copy_size = width * gl->base_size;
uint8_t *buffer = (uint8_t*)glMapBuffer(
uint8_t *buffer = (uint8_t*)glMapBuffer(
GL_TEXTURE_REFERENCE_BUFFER_SCE, GL_READ_WRITE) + buffer_addr; GL_TEXTURE_REFERENCE_BUFFER_SCE, GL_READ_WRITE) + buffer_addr;
for (h = 0; h < height; h++, buffer += buffer_stride, frame_copy += pitch) for (h = 0; h < height; h++, buffer += buffer_stride, frame_copy += pitch)
memcpy(buffer, frame_copy, frame_copy_size); memcpy(buffer, frame_copy, frame_copy_size);
@ -706,7 +705,8 @@ static INLINE void gl_copy_frame(gl_t *gl,
img_info.rgb32 = (gl->base_size == 4); img_info.rgb32 = (gl->base_size == 4);
img_info.handle = &img; img_info.handle = &img;
new_egl = video_context_driver_write_to_image_buffer(&img_info); new_egl =
video_context_driver_write_to_image_buffer(&img_info);
if (img == EGL_NO_IMAGE_KHR) if (img == EGL_NO_IMAGE_KHR)
{ {
@ -1036,7 +1036,8 @@ static INLINE void gl_draw_texture(gl_t *gl, video_frame_info_t *video_info)
video_shader_driver_set_coords(coords); video_shader_driver_set_coords(coords);
video_info->cb_shader_set_mvp(gl, video_info->shader_data, &gl->mvp_no_rot); video_info->cb_shader_set_mvp(gl,
video_info->shader_data, &gl->mvp_no_rot);
glEnable(GL_BLEND); glEnable(GL_BLEND);
@ -1108,7 +1109,8 @@ static bool gl_frame(void *data, const void *frame,
mode.width = width; mode.width = width;
mode.height = height; mode.height = height;
video_info->cb_set_resize(video_info->context_data, mode.width, mode.height); video_info->cb_set_resize(video_info->context_data,
mode.width, mode.height);
#ifdef HAVE_FBO #ifdef HAVE_FBO
if (gl->fbo_inited) if (gl->fbo_inited)
@ -1136,8 +1138,10 @@ static bool gl_frame(void *data, const void *frame,
if (!gl->hw_render_fbo_init) if (!gl->hw_render_fbo_init)
#endif #endif
{ {
gl_update_input_size(gl, frame_width, frame_height, pitch, true); gl_update_input_size(gl, frame_width,
gl_copy_frame(gl, video_info, frame, frame_width, frame_height, pitch); frame_height, pitch, true);
gl_copy_frame(gl, video_info, frame,
frame_width, frame_height, pitch);
} }
/* No point regenerating mipmaps /* No point regenerating mipmaps
@ -1184,7 +1188,8 @@ static bool gl_frame(void *data, const void *frame,
#ifdef HAVE_FBO #ifdef HAVE_FBO
if (gl->fbo_feedback_enable) if (gl->fbo_feedback_enable)
{ {
const struct video_fbo_rect *rect = &gl->fbo_rect[gl->fbo_feedback_pass]; const struct video_fbo_rect
*rect = &gl->fbo_rect[gl->fbo_feedback_pass];
GLfloat xamt = (GLfloat)rect->img_width / rect->width; GLfloat xamt = (GLfloat)rect->img_width / rect->width;
GLfloat yamt = (GLfloat)rect->img_height / rect->height; GLfloat yamt = (GLfloat)rect->img_height / rect->height;
@ -1361,7 +1366,7 @@ static void gl_free(void *data)
#ifdef HAVE_GL_SYNC #ifdef HAVE_GL_SYNC
if (gl->have_sync) if (gl->have_sync)
{ {
unsigned i; uint8_t i;
for (i = 0; i < gl->fence_count; i++) for (i = 0; i < gl->fence_count; i++)
{ {
@ -1576,7 +1581,7 @@ static INLINE void gl_set_texture_fmts(gl_t *gl, bool rgb32)
#ifdef HAVE_GL_ASYNC_READBACK #ifdef HAVE_GL_ASYNC_READBACK
static void gl_init_pbo_readback(gl_t *gl) static void gl_init_pbo_readback(gl_t *gl)
{ {
unsigned i; uint8_t i;
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
bool *recording_enabled = recording_is_enabled(); bool *recording_enabled = recording_is_enabled();
#ifndef HAVE_OPENGLES3 #ifndef HAVE_OPENGLES3

View File

@ -1278,7 +1278,7 @@ void video_monitor_set_refresh_rate(float hz)
bool video_monitor_fps_statistics(double *refresh_rate, bool video_monitor_fps_statistics(double *refresh_rate,
double *deviation, unsigned *sample_points) double *deviation, unsigned *sample_points)
{ {
unsigned i; uint8_t i;
retro_time_t accum = 0, avg, accum_var = 0; retro_time_t accum = 0, avg, accum_var = 0;
unsigned samples = MIN(MEASURE_FRAME_TIME_SAMPLES_COUNT, unsigned samples = MIN(MEASURE_FRAME_TIME_SAMPLES_COUNT,
(unsigned)video_driver_frame_time_count); (unsigned)video_driver_frame_time_count);

View File

@ -281,12 +281,12 @@ static void retroarch_msg_queue_init(void)
static void retroarch_override_setting_free_state(void) static void retroarch_override_setting_free_state(void)
{ {
unsigned i; uint8_t i;
for (i = 0; i < RARCH_OVERRIDE_SETTING_LAST; i++) for (i = 0; i < RARCH_OVERRIDE_SETTING_LAST; i++)
{ {
if (i == RARCH_OVERRIDE_SETTING_LIBRETRO_DEVICE) if (i == RARCH_OVERRIDE_SETTING_LIBRETRO_DEVICE)
{ {
unsigned j; uint8_t j;
for (j = 0; j < MAX_USERS; j++) for (j = 0; j < MAX_USERS; j++)
retroarch_override_setting_unset((enum rarch_override_setting)(i), &j); retroarch_override_setting_unset((enum rarch_override_setting)(i), &j);
} }
@ -1476,7 +1476,7 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data)
#endif #endif
retroarch_init_state(); retroarch_init_state();
{ {
unsigned i; uint8_t i;
for (i = 0; i < MAX_USERS; i++) for (i = 0; i < MAX_USERS; i++)
input_config_set_device(i, RETRO_DEVICE_JOYPAD); input_config_set_device(i, RETRO_DEVICE_JOYPAD);
} }