diff options
-rw-r--r-- | AUTHORS | 3 | ||||
-rw-r--r-- | src/library.js | 19 | ||||
-rw-r--r-- | src/library_sdl.js | 18 | ||||
-rw-r--r-- | src/shell.js | 4 |
4 files changed, 30 insertions, 14 deletions
@@ -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.js b/src/library.js index ab27ed35..5779327f 100644 --- a/src/library.js +++ b/src/library.js @@ -2621,7 +2621,7 @@ LibraryManager.library = { var curr = 0; var buffer = []; // Read characters according to the format. floats are trickier, they may be in an unfloat state in the middle, then be a valid float later - if (type == 'f' || type == 'e' || type == 'g' || + if (type == 'f' || type == 'e' || type == 'g' || type == 'F' || type == 'E' || type == 'G') { var last = 0; next = get(); @@ -3965,8 +3965,8 @@ LibraryManager.library = { {{{ makeGetValue('str+1', 0, 'i8') }}} == {{{ charCode('X') }}}) { str += 2; } - } - } + } + } if (!finalBase) finalBase = 10; // Get digits. @@ -4020,7 +4020,7 @@ LibraryManager.library = { var isNegative = false; // Skip space. while (_isspace({{{ makeGetValue('str', 0, 'i8') }}})) str++; - + // Check for a plus/minus sign. if ({{{ makeGetValue('str', 0, 'i8') }}} == {{{ charCode('-') }}}) { str++; @@ -4049,8 +4049,8 @@ LibraryManager.library = { {{{ makeGetValue('str+1', 0, 'i8') }}} == {{{ charCode('X') }}}) { str += 2; } - } - } + } + } if (!finalBase) finalBase = 10; start = str; @@ -7330,6 +7330,7 @@ LibraryManager.library = { */ socket__deps: ['$Sockets'], socket: function(family, type, protocol) { + var INCOMING_QUEUE_LENGTH = 64; var fd = FS.createFileHandle({ addr: null, port: null, @@ -7337,7 +7338,7 @@ LibraryManager.library = { header: new Uint16Array(2), bound: false, socket: true - }; + }); assert(fd < 64); // select() assumes socket fd values are in 0..63 var stream = type == {{{ cDefine('SOCK_STREAM') }}}; if (protocol) { @@ -7423,8 +7424,6 @@ LibraryManager.library = { Sockets.peer = peer; } - var INCOMING_QUEUE_LENGTH = 64; - function CircularBuffer(max_length) { var buffer = new Array(++ max_length); var head = 0; @@ -7700,7 +7699,7 @@ LibraryManager.library = { if (protocol) { assert(stream == (protocol == {{{ cDefine('IPPROTO_TCP') }}})); // if SOCK_STREAM, must be tcp } - var fd = FS.createFileHandle({ + var fd = FS.createFileHandle({ connected: false, stream: stream, socket: true 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 |