Skip to content

Commit

Permalink
Fix UTF8 output in worker builds
Browse files Browse the repository at this point in the history
  • Loading branch information
Kagami committed Aug 12, 2015
1 parent ca53720 commit feb979e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
15 changes: 8 additions & 7 deletions build/post-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@
var __ffmpegjs_running = false;

self.onmessage = function(e) {
// This might work not so fast in case of fast printing.
function makeOutHandler(cb) {
var buf = ""
var buf = [];
return function(ch, exit) {
if (exit && buf) return cb(buf);
if (exit && buf.length) return cb(__ffmpegjs_utf8ToStr(buf, 0));
if (ch === 10 || ch === 13) {
cb(buf);
buf = "";
} else {
buf += String.fromCharCode(ch);
cb(__ffmpegjs_utf8ToStr(buf, 0));
buf = [];
} else if (ch !== 0) {
// See <https://github.com/kripken/emscripten/blob/1.34.4/
// src/library_tty.js#L146>.
buf.push(ch);
}
};
}
Expand Down
3 changes: 3 additions & 0 deletions build/pre.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
var __ffmpegjs_utf8ToStr;

function __ffmpegjs(__ffmpegjs_opts) {
__ffmpegjs_utf8ToStr = UTF8ArrayToString;
__ffmpegjs_opts = __ffmpegjs_opts || {};
var __ffmpegjs_return;
var Module = {};
Expand Down

0 comments on commit feb979e

Please sign in to comment.