Move g_extern.measure_data to g_runloop.measure_data

This commit is contained in:
twinaphex 2015-03-07 13:38:21 +01:00
parent 3276781b4f
commit e39d5188a3
5 changed files with 26 additions and 25 deletions

View File

@ -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

View File

@ -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
{

View File

@ -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;

View File

@ -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;

View File

@ -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;
}