Skip to content

Commit

Permalink
audio fix for when SDL is off
Browse files Browse the repository at this point in the history
  • Loading branch information
nadavbh12 committed Feb 28, 2017
1 parent ee247fe commit d1cf14a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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',
Expand Down
9 changes: 9 additions & 0 deletions src/environment/RetroAgent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand All @@ -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) {
Expand All @@ -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, ...) {
Expand Down

0 comments on commit d1cf14a

Please sign in to comment.