aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AUTHORS3
-rw-r--r--src/library_sdl.js18
-rw-r--r--src/shell.js4
3 files changed, 21 insertions, 4 deletions
diff --git a/AUTHORS b/AUTHORS
index 7196711d..9e9d5748 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -82,4 +82,7 @@ a license to everyone to use it as detailed in LICENSE.)
* Onno Jongbloed <hey@onnoj.net>
* Jez Ng <me@jezng.com>
* Marc Feeley <mfeeley@mozilla.com> (copyright owned by Mozilla Foundation)
+* Ludovic Perrine <jazzzz@gmail.com>
+
+
diff --git a/src/library_sdl.js b/src/library_sdl.js
index 4f871f9d..e8419536 100644
--- a/src/library_sdl.js
+++ b/src/library_sdl.js
@@ -936,7 +936,10 @@ var LibrarySDL = {
},
SDL_GetError: function() {
- return allocate(intArrayFromString("unknown SDL-emscripten error"), 'i8');
+ if (!SDL.errorMessage) {
+ SDL.errorMessage = allocate(intArrayFromString("unknown SDL-emscripten error"), 'i8', ALLOC_NORMAL);
+ }
+ return SDL.errorMessage;
},
SDL_CreateRGBSurface: function(flags, width, height, depth, rmask, gmask, bmask, amask) {
@@ -1160,9 +1163,6 @@ var LibrarySDL = {
SDL_OpenAudio: function(desired, obtained) {
SDL.allocateChannels(32);
- // FIXME: Assumes 16-bit audio
- assert(obtained === 0, 'Cannot return obtained SDL audio params');
-
SDL.audio = {
freq: {{{ makeGetValue('desired', 'SDL.structs.AudioSpec.freq', 'i32', 0, 1) }}},
format: {{{ makeGetValue('desired', 'SDL.structs.AudioSpec.format', 'i16', 0, 1) }}},
@@ -1174,6 +1174,16 @@ var LibrarySDL = {
timer: null
};
+ if (obtained) {
+ {{{ makeSetValue('obtained', 'SDL.structs.AudioSpec.freq', 'SDL.audio.freq', 'i32') }}}; // no good way for us to know if the browser can really handle this
+ {{{ makeSetValue('obtained', 'SDL.structs.AudioSpec.format', 33040, 'i16') }}}; // float, signed, 16-bit
+ {{{ makeSetValue('obtained', 'SDL.structs.AudioSpec.channels', 'SDL.audio.channels', 'i8') }}};
+ {{{ makeSetValue('obtained', 'SDL.structs.AudioSpec.silence', makeGetValue('desired', 'SDL.structs.AudioSpec.silence', 'i8', 0, 1), 'i8') }}}; // unclear if browsers can provide this
+ {{{ makeSetValue('obtained', 'SDL.structs.AudioSpec.samples', 'SDL.audio.samples', 'i16') }}};
+ {{{ makeSetValue('obtained', 'SDL.structs.AudioSpec.callback', 'SDL.audio.callback', '*') }}};
+ {{{ makeSetValue('obtained', 'SDL.structs.AudioSpec.userdata', 'SDL.audio.userdata', '*') }}};
+ }
+
var totalSamples = SDL.audio.samples*SDL.audio.channels;
SDL.audio.bufferSize = totalSamples*2; // hardcoded 16-bit audio
SDL.audio.buffer = _malloc(SDL.audio.bufferSize);
diff --git a/src/shell.js b/src/shell.js
index 20db25a7..873bcc65 100644
--- a/src/shell.js
+++ b/src/shell.js
@@ -12,6 +12,10 @@ var ENVIRONMENT_IS_WEB = typeof window === 'object';
var ENVIRONMENT_IS_WORKER = typeof importScripts === 'function';
var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
+if (typeof module === "object") {
+ module.exports = Module;
+}
+
if (ENVIRONMENT_IS_NODE) {
// Expose functionality in the same simple way that the shells work
// Note that we pollute the global namespace here, otherwise we break in node