diff options
author | 2014-07-22 04:51:52 +0000 | |
---|---|---|
committer | 2014-07-22 04:51:52 +0000 | |
commit | c4e9058ee26841baae4c0fd51e081949747d5f48 (patch) | |
tree | 51d9e35892c5931b099f9f30369cbe1cabe49cc8 /src/osd/modules/sound/js_sound.c | |
parent | ee2ad64677416ae895b69d65fc36e2abb142677e (diff) |
[JSMESS] Add shim for Web Audio sound module [Katelyn Gadd, Justin Kerk]
Diffstat (limited to 'src/osd/modules/sound/js_sound.c')
-rw-r--r-- | src/osd/modules/sound/js_sound.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/osd/modules/sound/js_sound.c b/src/osd/modules/sound/js_sound.c new file mode 100644 index 00000000000..a2bc6086343 --- /dev/null +++ b/src/osd/modules/sound/js_sound.c @@ -0,0 +1,39 @@ +// license:BSD-3-Clause +// copyright-holders:Miodrag Milanovic, Katelyn Gadd +/*************************************************************************** + + js_sound.c + + Shim for native JavaScript sound interface implementations (Emscripten only). + +*******************************************************************c********/ + + +#include "js_sound.h" +#include "emscripten.h" + +//------------------------------------------------- +// sound_js - constructor +//------------------------------------------------- +sound_js::sound_js(const osd_interface &osd) + : osd_sound_interface(osd) +{ +} + +void sound_js::update_audio_stream(const INT16 *buffer, int samples_this_frame) +{ + EM_ASM_ARGS({ + // Forward audio stream update on to JS backend implementation. + jsmess_update_audio_stream($0, $1); + }, (unsigned int)buffer, samples_this_frame); +} + +void sound_js::set_mastervolume(int attenuation) +{ + EM_ASM_ARGS({ + // Forward volume update on to JS backend implementation. + jsmess_set_mastervolume($0); + }, attenuation); +} + +const osd_sound_type OSD_SOUND_JS = &osd_sound_creator<sound_js>; |