mirror of https://github.com/inolen/redream.git
added option to enable/disable the audio backend
This commit is contained in:
parent
c38a8725c7
commit
26fc11b9d2
|
@ -13,9 +13,9 @@ Command line flags are loaded from and saved to `$HOME/.redream/flags` each run.
|
||||||
```
|
```
|
||||||
--bios Path to BIOS [default: dc_boot.bin]
|
--bios Path to BIOS [default: dc_boot.bin]
|
||||||
--flash Path to flash ROM [default: dc_flash.bin]
|
--flash Path to flash ROM [default: dc_flash.bin]
|
||||||
--latency Set preferred audio latency in MS [default: 100]
|
--audio Enable audio [default: 1]
|
||||||
--controller Path to controller profile
|
--latency Preferred audio latency in MS [default: 100]
|
||||||
--throttle Throttle emulation speed to match the original hardware [default: 1]
|
--profile Path to controller profile
|
||||||
--verbose Enable debug logging [default: 0]
|
--verbose Enable debug logging [default: 0]
|
||||||
--perf Write perf-compatible maps for generated code [default: 0]
|
--perf Write perf-compatible maps for generated code [default: 0]
|
||||||
--gdb Start GDB debug server [default: 0]
|
--gdb Start GDB debug server [default: 0]
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include "audio/audio_backend.h"
|
#include "audio/audio_backend.h"
|
||||||
#include "hw/aica/aica.h"
|
#include "hw/aica/aica.h"
|
||||||
|
|
||||||
DEFINE_OPTION_INT(latency, 100, "Set preferred audio latency in MS");
|
DEFINE_OPTION_INT(latency, 100, "Preferred audio latency in MS");
|
||||||
|
|
||||||
struct audio_backend {
|
struct audio_backend {
|
||||||
struct aica *aica;
|
struct aica *aica;
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
DEFINE_AGGREGATE_COUNTER(frames);
|
DEFINE_AGGREGATE_COUNTER(frames);
|
||||||
|
|
||||||
|
DEFINE_OPTION_INT(audio, 1, "Enable audio");
|
||||||
|
|
||||||
struct emu {
|
struct emu {
|
||||||
struct window *window;
|
struct window *window;
|
||||||
struct window_listener listener;
|
struct window_listener listener;
|
||||||
|
@ -145,12 +147,15 @@ static void emu_close(void *data) {
|
||||||
|
|
||||||
static void *emu_core_thread(void *data) {
|
static void *emu_core_thread(void *data) {
|
||||||
struct emu *emu = data;
|
struct emu *emu = data;
|
||||||
struct audio_backend *audio = audio_create(emu->dc->aica);
|
struct audio_backend *audio = NULL;
|
||||||
|
|
||||||
if (!audio) {
|
if (OPTION_audio) {
|
||||||
LOG_WARNING("Audio backend creation failed");
|
audio = audio_create(emu->dc->aica);
|
||||||
emu->running = 0;
|
|
||||||
return 0;
|
if (!audio) {
|
||||||
|
LOG_WARNING("Audio backend creation failed");
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const int64_t MACHINE_STEP = HZ_TO_NANO(1000);
|
static const int64_t MACHINE_STEP = HZ_TO_NANO(1000);
|
||||||
|
@ -158,22 +163,29 @@ static void *emu_core_thread(void *data) {
|
||||||
int64_t next_pump_time = 0;
|
int64_t next_pump_time = 0;
|
||||||
|
|
||||||
while (emu->running) {
|
while (emu->running) {
|
||||||
while (audio_buffer_low(audio) && emu->running) {
|
/* run a slice of dreamcast time if the available audio is running low. this
|
||||||
|
effectively synchronizes the emulation speed with the host audio clock.
|
||||||
|
note however, if audio is disabled, the emulator will run as fast as
|
||||||
|
possible */
|
||||||
|
if (!audio || audio_buffer_low(audio)) {
|
||||||
dc_tick(emu->dc, MACHINE_STEP);
|
dc_tick(emu->dc, MACHINE_STEP);
|
||||||
|
}
|
||||||
|
|
||||||
current_time = time_nanoseconds();
|
/* update profiler stats */
|
||||||
|
current_time = time_nanoseconds();
|
||||||
|
prof_update(current_time);
|
||||||
|
|
||||||
prof_update(current_time);
|
/* check audio events (device connect / disconnect, etc.) infrequently */
|
||||||
|
if (audio && current_time > next_pump_time) {
|
||||||
/* audio events are just for device connections, check infrequently */
|
audio_pump_events(audio);
|
||||||
if (current_time > next_pump_time) {
|
next_pump_time = current_time + NS_PER_SEC;
|
||||||
audio_pump_events(audio);
|
|
||||||
next_pump_time = current_time + NS_PER_SEC;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
audio_destroy(audio);
|
exit:
|
||||||
|
if (audio) {
|
||||||
|
audio_destroy(audio);
|
||||||
|
}
|
||||||
|
|
||||||
emu->running = 0;
|
emu->running = 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue