trunk/scripts/src/main.lua
r253634 | r253635 | |
87 | 87 | configuration { "asmjs" } |
88 | 88 | targetextension ".bc" |
89 | 89 | if os.getenv("EMSCRIPTEN") then |
| 90 | local emccopts = "" |
| 91 | emccopts = emccopts .. " -O3" |
| 92 | emccopts = emccopts .. " -s USE_SDL=2" |
| 93 | emccopts = emccopts .. " --memory-init-file 0" |
| 94 | emccopts = emccopts .. " -s ALLOW_MEMORY_GROWTH=0" |
| 95 | emccopts = emccopts .. " -s TOTAL_MEMORY=268435456" |
| 96 | emccopts = emccopts .. " -s DISABLE_EXCEPTION_CATCHING=2" |
| 97 | emccopts = emccopts .. " -s EXCEPTION_CATCHING_WHITELIST='[\"__ZN15running_machine17start_all_devicesEv\"]'" |
| 98 | emccopts = emccopts .. " -s EXPORTED_FUNCTIONS=\"['_main', '_malloc', '__Z14js_get_machinev', '__Z9js_get_uiv', '__Z12js_get_soundv', '__ZN10ui_manager12set_show_fpsEb', '__ZNK10ui_manager8show_fpsEv', '__ZN13sound_manager4muteEbh', '_SDL_PauseAudio']\"" |
| 99 | emccopts = emccopts .. " --pre-js " .. _MAKE.esc(MAME_DIR) .. "src/osd/modules/sound/js_sound.js" |
| 100 | emccopts = emccopts .. " --post-js " .. _MAKE.esc(MAME_DIR) .. "src/osd/sdl/emscripten_post.js" |
| 101 | emccopts = emccopts .. " --embed-file " .. _MAKE.esc(MAME_DIR) .. "bgfx@bgfx" |
| 102 | emccopts = emccopts .. " --embed-file " .. _MAKE.esc(MAME_DIR) .. "shaders/gles@shaders/gles" |
90 | 103 | postbuildcommands { |
91 | | os.getenv("EMSCRIPTEN") .. "/emcc -O3 -s DISABLE_EXCEPTION_CATCHING=2 -s USE_SDL=2 --memory-init-file 0 -s ALLOW_MEMORY_GROWTH=0 -s TOTAL_MEMORY=268435456 -s EXCEPTION_CATCHING_WHITELIST='[\"__ZN15running_machine17start_all_devicesEv\"]' -s EXPORTED_FUNCTIONS=\"['_main', '_malloc', '__Z14js_get_machinev', '__Z9js_get_uiv', '__Z12js_get_soundv', '__ZN10ui_manager12set_show_fpsEb', '__ZNK10ui_manager8show_fpsEv', '__ZN13sound_manager4muteEbh', '_SDL_PauseAudio']\" $(TARGET) -o " .. _MAKE.esc(MAME_DIR) .. _OPTIONS["target"] .. _OPTIONS["subtarget"] .. ".js --pre-js " .. _MAKE.esc(MAME_DIR) .. "src/osd/modules/sound/js_sound.js --post-js " .. _MAKE.esc(MAME_DIR) .. "src/osd/sdl/emscripten_post.js --embed-file " .. _MAKE.esc(MAME_DIR) .. "bgfx@bgfx --embed-file " .. _MAKE.esc(MAME_DIR) .. "shaders/gles@shaders/gles", |
| 104 | os.getenv("EMSCRIPTEN") .. "/emcc " .. emccopts .. " $(TARGET) -o " .. _MAKE.esc(MAME_DIR) .. _OPTIONS["target"] .. _OPTIONS["subtarget"] .. ".js", |
92 | 105 | } |
93 | 106 | end |
94 | 107 | |
trunk/src/osd/modules/sound/js_sound.js
r253634 | r253635 | |
185 | 185 | }; |
186 | 186 | |
187 | 187 | function sample_count() { |
188 | | //TODO get someone to call this from the emulator, |
189 | | //so the emulator can do proper audio buffering by |
190 | | //knowing how many samples are left: |
191 | | if (!context) { |
192 | | //Use impossible value as an error code: |
193 | | return -1; |
194 | | } |
195 | | var count = rear - start; |
196 | | if (start > rear) { |
197 | | count += bufferSize; |
198 | | } |
199 | | return count; |
| 188 | //TODO get someone to call this from the emulator, |
| 189 | //so the emulator can do proper audio buffering by |
| 190 | //knowing how many samples are left: |
| 191 | if (!context) { |
| 192 | //Use impossible value as an error code: |
| 193 | return -1; |
| 194 | } |
| 195 | var count = rear - start; |
| 196 | if (start > rear) { |
| 197 | count += bufferSize; |
| 198 | } |
| 199 | return count; |
200 | 200 | } |
201 | 201 | |
202 | 202 | return { |