From d1cf14a097dbd6ed6bbc469dd53eed3451c84fa1 Mon Sep 17 00:00:00 2001 From: Nadav Bhonker Date: Tue, 28 Feb 2017 17:12:36 +0200 Subject: [PATCH] audio fix for when SDL is off --- setup.py | 4 ++-- src/environment/RetroAgent.cpp | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 082593d..366fb01 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,7 @@ def run_cmake(): if ds.find_executable('cmake') is None: print("CMake is required to build RLE") - print("Please install cmake version >= 3.02 and re-run setup") + print("Please install cmake version >= 2.8 and re-run setup") sys.exit(-1) new_dir = op.join(op.split(__file__)[0], 'build') @@ -42,7 +42,7 @@ def run(self): ds.spawn(['./copy_cores.sh']) _build.build.run(self) -version = '1.1.2' +version = '1.1.3' setup(name = 'rle_python_interface', version=version, description = 'Retro Learning Environment Python Interface based on Ben Goodrich\'s work', diff --git a/src/environment/RetroAgent.cpp b/src/environment/RetroAgent.cpp index cc4b1e4..9e52fd1 100644 --- a/src/environment/RetroAgent.cpp +++ b/src/environment/RetroAgent.cpp @@ -25,7 +25,9 @@ using namespace rle; std::atomic_uint RetroAgent::numAgents{0}; thread_local struct RetroAgent::g_retro_ RetroAgent::g_retro; thread_local struct RetroAgent::g_video_ RetroAgent::g_video; +#ifdef __USE_SDL thread_local static snd_pcm_t *g_pcm = NULL; +#endif struct keymap { unsigned k; @@ -223,6 +225,7 @@ static void video_refresh(const void *data, unsigned width, unsigned height, uns } static void audio_init(int frequency) { +#ifdef __USE_SDL int err; if ((err = snd_pcm_open(&g_pcm, "default", SND_PCM_STREAM_PLAYBACK, 0)) < 0) @@ -232,13 +235,17 @@ static void audio_init(int frequency) { if (err < 0) die("Failed to configure playback device: %s", snd_strerror(err)); +#endif } static void audio_deinit() { +#ifdef __USE_SDL snd_pcm_close(g_pcm); +#endif } static size_t audio_write(const void *buf, unsigned frames) { +#ifdef __USE_SDL int written = snd_pcm_writei(g_pcm, buf, frames); if (written < 0) { @@ -249,6 +256,8 @@ static size_t audio_write(const void *buf, unsigned frames) { } return written; +#endif + return 0; } static void core_log(enum retro_log_level level, const char *fmt, ...) {