diff --git a/src/emulator.c b/src/emulator.c index 66a65d3f..31f275d6 100644 --- a/src/emulator.c +++ b/src/emulator.c @@ -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; } diff --git a/src/file/trace.h b/src/file/trace.h index 4b5a5a32..038f606d 100644 --- a/src/file/trace.h +++ b/src/file/trace.h @@ -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 */ diff --git a/src/host/retro_host.c b/src/host/retro_host.c index f5d1aaed..4b9c905c 100644 --- a/src/host/retro_host.c +++ b/src/host/retro_host.c @@ -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 diff --git a/src/host/sdl_host.c b/src/host/sdl_host.c index 547540e7..32f87e54 100644 --- a/src/host/sdl_host.c +++ b/src/host/sdl_host.c @@ -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) { diff --git a/src/imgui.h b/src/imgui.h index 09fce5cc..5a126ab9 100644 --- a/src/imgui.h +++ b/src/imgui.h @@ -1,7 +1,6 @@ #ifndef IMGUI_H #define IMGUI_H - /* imgui extensions */ #if HAVE_IMGUI diff --git a/src/tracer.c b/src/tracer.c index c3fefe5f..8665a1ed 100644 --- a/src/tracer.c +++ b/src/tracer.c @@ -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); diff --git a/src/ui.c b/src/ui.c index 88a5ccca..4470278a 100644 --- a/src/ui.c +++ b/src/ui.c @@ -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);