throttle the ui to 60 fps

ran latest clang-format
This commit is contained in:
Anthony Pesch 2017-11-20 08:10:13 -05:00
parent 2e1dec131a
commit eca0c94b2c
7 changed files with 28 additions and 16 deletions

View File

@ -617,7 +617,14 @@ void emu_render_frame(struct emu *emu) {
r_clear(emu->r);
if (!dc_running(emu->dc)) {
/* since the host times itself based off of our audio output, it's important
to pump out silent audio frames even when not running the dreamcast, else
the host will render the ui completely unthrottled */
uint32_t silence[AICA_SAMPLE_FREQ / 60] = {0};
audio_push(emu->host, (int16_t *)silence, ARRAY_SIZE(silence));
emu_debug_menu(emu);
return;
}

View File

@ -16,7 +16,7 @@ struct trace_cmd {
/* set on read */
struct trace_cmd *prev;
struct trace_cmd *next;
struct trace_cmd * override;
struct trace_cmd *override;
/* the data pointers in these structs are written out relative to the cmd,
and patched to absolute pointers on read */

View File

@ -5,11 +5,12 @@
#include "core/core.h"
#include "core/filesystem.h"
#include "emulator.h"
#include "guest/aica/aica.h"
#include "host/host.h"
#include "options.h"
#include "render/render_backend.h"
#define AUDIO_FREQ 44100
#define AUDIO_FREQ AICA_SAMPLE_FREQ
#define VIDEO_WIDTH 640
#define VIDEO_HEIGHT 480

View File

@ -7,6 +7,7 @@
#include "core/ringbuf.h"
#include "core/time.h"
#include "emulator.h"
#include "guest/aica/aica.h"
#include "host/host.h"
#include "imgui.h"
#include "options.h"
@ -17,7 +18,7 @@
/*
* sdl host implementation
*/
#define AUDIO_FREQ 44100
#define AUDIO_FREQ AICA_SAMPLE_FREQ
#define VIDEO_DEFAULT_WIDTH 853
#define VIDEO_DEFAULT_HEIGHT 480
#define INPUT_MAX_CONTROLLERS 4
@ -40,6 +41,7 @@ struct host {
struct {
SDL_AudioDeviceID dev;
SDL_AudioSpec spec;
int playing;
struct ringbuf *frames;
volatile int64_t last_cb;
} audio;
@ -178,9 +180,6 @@ static int audio_create_device(struct host *host) {
AUDIO_FRAMES_TO_MS(host->audio.spec.samples),
host->audio.spec.samples);
/* resume device */
SDL_PauseAudioDevice(host->audio.dev, 0);
return 1;
}
@ -196,6 +195,12 @@ void audio_push(struct host *host, const int16_t *data, int num_frames) {
}
audio_write_frames(host, data, num_frames);
/* start playback once some audio is queued */
if (!host->audio.playing) {
SDL_PauseAudioDevice(host->audio.dev, 0);
host->audio.playing = 1;
}
}
static void audio_shutdown(struct host *host) {

View File

@ -1,7 +1,6 @@
#ifndef IMGUI_H
#define IMGUI_H
/* imgui extensions */
#if HAVE_IMGUI

View File

@ -238,7 +238,7 @@ static void tracer_prev_context(struct tracer *tracer) {
while (curr != prev) {
if (curr->type == TRACE_CMD_TEXTURE) {
struct trace_cmd * override = curr->override;
struct trace_cmd *override = curr->override;
if (override) {
tracer_add_texture(tracer, override);

View File

@ -394,11 +394,11 @@ static void ui_begin_page(struct ui *ui, struct page *page) {
char title[128];
int pagenum = (int)(page - pages);
snprintf(title, sizeof(title), "ui%d", pagenum);
igBegin(title, NULL, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize |
ImGuiWindowFlags_NoMove |
ImGuiWindowFlags_NoScrollbar |
ImGuiWindowFlags_NoNavFocus |
ImGuiWindowFlags_NoBringToFrontOnFocus);
igBegin(title, NULL,
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize |
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoScrollbar |
ImGuiWindowFlags_NoNavFocus |
ImGuiWindowFlags_NoBringToFrontOnFocus);
/* push back original padding immediately */
igPushStyleVarVec(ImGuiStyleVar_WindowPadding, original_padding);
@ -1232,9 +1232,9 @@ static void ui_games_build(struct ui *ui) {
igSetNextWindowSize(size, 0);
igSetNextWindowContentSize(content_size);
igBeginChild("games list", size, false, ImGuiWindowFlags_NoScrollbar |
ImGuiWindowFlags_NoNavScroll |
ImGuiWindowFlags_NavFlattened);
igBeginChild("games list", size, false,
ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoNavScroll |
ImGuiWindowFlags_NavFlattened);
struct ImVec2 disc_pos = {list_padding, (size.y - disc_small) / 2.0f};
igSetCursorPos(disc_pos);