From e39d5188a39803794edc74da4eb262e804ce526f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 7 Mar 2015 13:38:21 +0100 Subject: [PATCH] Move g_extern.measure_data to g_runloop.measure_data --- audio/audio_driver.c | 16 ++++++++-------- general.h | 17 +++++++++-------- gfx/video_driver.c | 2 +- gfx/video_monitor.c | 14 +++++++------- settings_data.c | 2 +- 5 files changed, 26 insertions(+), 25 deletions(-) diff --git a/audio/audio_driver.c b/audio/audio_driver.c index 81fc90a977..d7d1f82acb 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -94,20 +94,20 @@ static void compute_audio_buffer_statistics(void) float avg_filled, deviation; uint64_t accum = 0, accum_var = 0; unsigned low_water_count = 0, high_water_count = 0; - unsigned samples = min(g_extern.measure_data.buffer_free_samples_count, + unsigned samples = min(g_runloop.measure_data.buffer_free_samples_count, AUDIO_BUFFER_FREE_SAMPLES_COUNT); if (samples < 3) return; for (i = 1; i < samples; i++) - accum += g_extern.measure_data.buffer_free_samples[i]; + accum += g_runloop.measure_data.buffer_free_samples[i]; avg = accum / (samples - 1); for (i = 1; i < samples; i++) { - int diff = avg - g_extern.measure_data.buffer_free_samples[i]; + int diff = avg - g_runloop.measure_data.buffer_free_samples[i]; accum_var += diff * diff; } @@ -120,9 +120,9 @@ static void compute_audio_buffer_statistics(void) for (i = 1; i < samples; i++) { - if (g_extern.measure_data.buffer_free_samples[i] >= low_water_size) + if (g_runloop.measure_data.buffer_free_samples[i] >= low_water_size) low_water_count++; - else if (g_extern.measure_data.buffer_free_samples[i] <= high_water_size) + else if (g_runloop.measure_data.buffer_free_samples[i] <= high_water_size) high_water_count++; } @@ -382,7 +382,7 @@ void init_audio(void) rarch_main_command(RARCH_CMD_DSP_FILTER_DEINIT); - g_extern.measure_data.buffer_free_samples_count = 0; + g_runloop.measure_data.buffer_free_samples_count = 0; if (driver.audio_active && !g_settings.audio.mute_enable && g_extern.system.audio_callback.callback) @@ -428,14 +428,14 @@ void audio_driver_readjust_input_rate(void) (unsigned)(100 - (avail * 100) / g_extern.audio_data.driver_buffer_size)); #endif - write_idx = g_extern.measure_data.buffer_free_samples_count++ & + write_idx = g_runloop.measure_data.buffer_free_samples_count++ & (AUDIO_BUFFER_FREE_SAMPLES_COUNT - 1); half_size = g_extern.audio_data.driver_buffer_size / 2; delta_mid = avail - half_size; direction = (double)delta_mid / half_size; adjust = 1.0 + g_settings.audio.rate_control_delta * direction; - g_extern.measure_data.buffer_free_samples[write_idx] = avail; + g_runloop.measure_data.buffer_free_samples[write_idx] = avail; g_extern.audio_data.src_ratio = g_extern.audio_data.orig_src_ratio * adjust; #if 0 diff --git a/general.h b/general.h index 8983bc76ca..41a843442e 100644 --- a/general.h +++ b/general.h @@ -463,6 +463,15 @@ struct runloop } video; } frames; + struct + { + unsigned buffer_free_samples[AUDIO_BUFFER_FREE_SAMPLES_COUNT]; + uint64_t buffer_free_samples_count; + + retro_time_t frame_time_samples[MEASURE_FRAME_TIME_SAMPLES_COUNT]; + uint64_t frame_time_samples_count; + } measure_data; + nbio_handle_t nbio; msg_queue_t *msg_queue; }; @@ -624,14 +633,6 @@ struct global float volume_gain; } audio_data; - struct - { - unsigned buffer_free_samples[AUDIO_BUFFER_FREE_SAMPLES_COUNT]; - uint64_t buffer_free_samples_count; - - retro_time_t frame_time_samples[MEASURE_FRAME_TIME_SAMPLES_COUNT]; - uint64_t frame_time_samples_count; - } measure_data; struct { diff --git a/gfx/video_driver.c b/gfx/video_driver.c index e7f14acc46..f74471ff42 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -525,7 +525,7 @@ void init_video(void) rarch_main_command(RARCH_CMD_OVERLAY_DEINIT); rarch_main_command(RARCH_CMD_OVERLAY_INIT); - g_extern.measure_data.frame_time_samples_count = 0; + g_runloop.measure_data.frame_time_samples_count = 0; g_extern.frame_cache.width = 4; g_extern.frame_cache.height = 4; diff --git a/gfx/video_monitor.c b/gfx/video_monitor.c index 6337661b95..ce32d37779 100644 --- a/gfx/video_monitor.c +++ b/gfx/video_monitor.c @@ -81,7 +81,7 @@ void video_monitor_compute_fps_statistics(void) return; } - if (g_extern.measure_data.frame_time_samples_count < + if (g_runloop.measure_data.frame_time_samples_count < 2 * MEASURE_FRAME_TIME_SAMPLES_COUNT) { RARCH_LOG( @@ -118,7 +118,7 @@ bool video_monitor_fps_statistics(double *refresh_rate, unsigned i; retro_time_t accum = 0, avg, accum_var = 0; unsigned samples = min(MEASURE_FRAME_TIME_SAMPLES_COUNT, - g_extern.measure_data.frame_time_samples_count); + g_runloop.measure_data.frame_time_samples_count); if (!g_settings.fps_monitor_enable || g_settings.video.threaded || (samples < 2)) @@ -126,12 +126,12 @@ bool video_monitor_fps_statistics(double *refresh_rate, /* Measure statistics on frame time (microsecs), *not* FPS. */ for (i = 0; i < samples; i++) - accum += g_extern.measure_data.frame_time_samples[i]; + accum += g_runloop.measure_data.frame_time_samples[i]; #if 0 for (i = 0; i < samples; i++) RARCH_LOG("Interval #%u: %d usec / frame.\n", - i, (int)g_extern.measure_data.frame_time_samples[i]); + i, (int)g_runloop.measure_data.frame_time_samples[i]); #endif avg = accum / samples; @@ -139,7 +139,7 @@ bool video_monitor_fps_statistics(double *refresh_rate, /* Drop first measurement. It is likely to be bad. */ for (i = 0; i < samples; i++) { - retro_time_t diff = g_extern.measure_data.frame_time_samples[i] - avg; + retro_time_t diff = g_runloop.measure_data.frame_time_samples[i] - avg; accum_var += diff * diff; } @@ -184,9 +184,9 @@ bool video_monitor_get_fps(char *buf, size_t size, { bool ret = false; unsigned write_index = - g_extern.measure_data.frame_time_samples_count++ & + g_runloop.measure_data.frame_time_samples_count++ & (MEASURE_FRAME_TIME_SAMPLES_COUNT - 1); - g_extern.measure_data.frame_time_samples[write_index] = + g_runloop.measure_data.frame_time_samples[write_index] = new_time - fps_time; fps_time = new_time; diff --git a/settings_data.c b/settings_data.c index ce64aeda0d..fd38da08b9 100644 --- a/settings_data.c +++ b/settings_data.c @@ -384,7 +384,7 @@ static int setting_data_action_start_video_refresh_rate_auto( if (!setting) return -1; - g_extern.measure_data.frame_time_samples_count = 0; + g_runloop.measure_data.frame_time_samples_count = 0; return 0; }