trunk/src/osd/sdl/sdlmain.c
| r31371 | r31372 | |
| 50 | 50 | #include "osdsdl.h" |
| 51 | 51 | #include "sdlos.h" |
| 52 | 52 | #include "modules/sound/sdl_sound.h" |
| 53 | #if defined(SDLMAME_EMSCRIPTEN) |
| 54 | #include "modules/sound/js_sound.h" |
| 55 | #endif |
| 53 | 56 | #if !defined(NO_DEBUGGER) |
| 54 | 57 | #include "modules/debugger/debugqt.h" |
| 55 | 58 | #endif |
| r31371 | r31372 | |
| 540 | 543 | void sdl_osd_interface::sound_register() |
| 541 | 544 | { |
| 542 | 545 | sound_options_add("sdl", OSD_SOUND_SDL); |
| 546 | #if defined(SDLMAME_EMSCRIPTEN) |
| 547 | sound_options_add("js", OSD_SOUND_JS); |
| 548 | sound_options_add("auto", OSD_SOUND_JS); // making JS audio default one |
| 549 | #else |
| 543 | 550 | sound_options_add("auto", OSD_SOUND_SDL); // making SDL audio default one |
| 551 | #endif |
| 544 | 552 | } |
| 545 | 553 | |
| 546 | 554 | //============================================================ |
trunk/src/osd/modules/sound/js_sound.c
| r0 | r31372 | |
| 1 | // license:BSD-3-Clause |
| 2 | // copyright-holders:Miodrag Milanovic, Katelyn Gadd |
| 3 | /*************************************************************************** |
| 4 | |
| 5 | js_sound.c |
| 6 | |
| 7 | Shim for native JavaScript sound interface implementations (Emscripten only). |
| 8 | |
| 9 | *******************************************************************c********/ |
| 10 | |
| 11 | |
| 12 | #include "js_sound.h" |
| 13 | #include "emscripten.h" |
| 14 | |
| 15 | //------------------------------------------------- |
| 16 | // sound_js - constructor |
| 17 | //------------------------------------------------- |
| 18 | sound_js::sound_js(const osd_interface &osd) |
| 19 | : osd_sound_interface(osd) |
| 20 | { |
| 21 | } |
| 22 | |
| 23 | void sound_js::update_audio_stream(const INT16 *buffer, int samples_this_frame) |
| 24 | { |
| 25 | EM_ASM_ARGS({ |
| 26 | // Forward audio stream update on to JS backend implementation. |
| 27 | jsmess_update_audio_stream($0, $1); |
| 28 | }, (unsigned int)buffer, samples_this_frame); |
| 29 | } |
| 30 | |
| 31 | void sound_js::set_mastervolume(int attenuation) |
| 32 | { |
| 33 | EM_ASM_ARGS({ |
| 34 | // Forward volume update on to JS backend implementation. |
| 35 | jsmess_set_mastervolume($0); |
| 36 | }, attenuation); |
| 37 | } |
| 38 | |
| 39 | const osd_sound_type OSD_SOUND_JS = &osd_sound_creator<sound_js>; |
trunk/src/osd/modules/sound/js_sound.h
| r0 | r31372 | |
| 1 | // license:BSD-3-Clause |
| 2 | // copyright-holders:Miodrag Milanovic, Katelyn Gadd |
| 3 | /*************************************************************************** |
| 4 | |
| 5 | js_sound.h |
| 6 | |
| 7 | Shim for native JavaScript sound interface implementations (Emscripten only). |
| 8 | |
| 9 | *******************************************************************c********/ |
| 10 | |
| 11 | #pragma once |
| 12 | |
| 13 | #ifndef __SOUND_JS_H__ |
| 14 | #define __SOUND_JS_H__ |
| 15 | |
| 16 | #include "osdepend.h" |
| 17 | |
| 18 | class sound_js : public osd_sound_interface |
| 19 | { |
| 20 | public: |
| 21 | // construction/destruction |
| 22 | sound_js(const osd_interface &osd); |
| 23 | virtual ~sound_js() { } |
| 24 | |
| 25 | virtual void update_audio_stream(const INT16 *buffer, int samples_this_frame); |
| 26 | virtual void set_mastervolume(int attenuation); |
| 27 | }; |
| 28 | |
| 29 | extern const osd_sound_type OSD_SOUND_JS; |
| 30 | |
| 31 | #endif /* __SOUND_JS_H__ */ |