blob: 1473ef9de2a8eb652fd4ccc8a73467a920018fa2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
// license:BSD-3-Clause
// copyright-holders:Miodrag Milanovic, Katelyn Gadd
/***************************************************************************
js_sound.c
Shim for native JavaScript sound interface implementations (Emscripten only).
****************************************************************************/
#include "sound_module.h"
#include "modules/osdmodule.h"
#if defined(SDLMAME_EMSCRIPTEN)
#include "emscripten.h"
class sound_js : public osd_module, public sound_module
{
public:
sound_js() : osd_module(OSD_SOUND_PROVIDER, "js"), sound_module()
{
}
virtual ~sound_js() { }
virtual int init(osd_interface &osd, const osd_options &options) { return 0; }
virtual void exit() { }
// sound_module
virtual void stream_sink_update(uint32_t, const int16_t *buffer, int samples_this_frame)
{
EM_ASM_ARGS(
{
// Forward audio stream update on to JS backend implementation.
jsmame_steam_update($1, $2);
},
(unsigned int)buffer,
samples_this_frame);
}
};
#else // SDLMAME_EMSCRIPTEN
MODULE_NOT_SUPPORTED(sound_js, OSD_SOUND_PROVIDER, "js")
#endif // SDLMAME_EMSCRIPTEN
MODULE_DEFINITION(SOUND_JS, sound_js)
|