From d57db886ac472cdfb258c3161481068fffa3ddb5 Mon Sep 17 00:00:00 2001 From: lawl Date: Tue, 31 Mar 2020 17:16:30 +0200 Subject: [PATCH] fix workers to work with worker-loader --- app/worker-client.js | 1 + app/worker.js | 7 ++- .../mumble-client-codecs-browser+1.2.0.patch | 61 +++++++++++++++++++ 3 files changed, 67 insertions(+), 2 deletions(-) diff --git a/app/worker-client.js b/app/worker-client.js index 62447fb..02d6f7a 100644 --- a/app/worker-client.js +++ b/app/worker-client.js @@ -15,6 +15,7 @@ import Worker from './worker' class WorkerBasedMumbleConnector { constructor () { this._worker = new Worker() //work(require.resolve('./worker')) + console.log(this._worker) this._worker.addEventListener('message', this._onMessage.bind(this)) this._reqId = 1 this._requests = {} diff --git a/app/worker.js b/app/worker.js index e6ac249..cb6b2ba 100644 --- a/app/worker.js +++ b/app/worker.js @@ -16,13 +16,15 @@ import 'subworkers' // Using require to ensure ordering relative to monkey-patch above //let CodecsBrowser = require('mumble-client-codecs-browser') -export default function (self) { + let sampleRate let nextClientId = 1 let nextVoiceId = 1 let voiceStreams = [] let clients = [] + console.log('worker created!') + function postMessage (msg, transfer) { try { self.postMessage(msg, transfer) @@ -286,4 +288,5 @@ export default function (self) { console.error('exception during message event', ev.data, ex) } }) -} + + export default null \ No newline at end of file diff --git a/patches/mumble-client-codecs-browser+1.2.0.patch b/patches/mumble-client-codecs-browser+1.2.0.patch index dbb24ea..ea1646b 100644 --- a/patches/mumble-client-codecs-browser+1.2.0.patch +++ b/patches/mumble-client-codecs-browser+1.2.0.patch @@ -1,3 +1,33 @@ +diff --git a/node_modules/mumble-client-codecs-browser/lib/decode-worker.js b/node_modules/mumble-client-codecs-browser/lib/decode-worker.js +index 3925f29..be9af92 100644 +--- a/node_modules/mumble-client-codecs-browser/lib/decode-worker.js ++++ b/node_modules/mumble-client-codecs-browser/lib/decode-worker.js +@@ -1,10 +1,6 @@ + 'use strict'; + +-Object.defineProperty(exports, "__esModule", { +- value: true +-}); + +-exports.default = function (self) { + var opusDecoder, celt7Decoder; + self.addEventListener('message', function (e) { + var data = e.data; +@@ -55,10 +51,12 @@ exports.default = function (self) { + }, [_decoded.buffer]); + } + }); +-}; ++ + + var _libopus = require('libopus.js'); + + var _libcelt = require('libcelt7.js'); + + var MUMBLE_SAMPLE_RATE = 48000; ++ ++export default null +\ No newline at end of file diff --git a/node_modules/mumble-client-codecs-browser/lib/decoder-stream.js b/node_modules/mumble-client-codecs-browser/lib/decoder-stream.js index 6cfda8b..eed6fa3 100644 --- a/node_modules/mumble-client-codecs-browser/lib/decoder-stream.js @@ -42,6 +72,37 @@ index 6cfda8b..eed6fa3 100644 +//exports.default = DecoderStream; +export default DecoderStream \ No newline at end of file +diff --git a/node_modules/mumble-client-codecs-browser/lib/encode-worker.js b/node_modules/mumble-client-codecs-browser/lib/encode-worker.js +index f7187ab..c2ebaa3 100644 +--- a/node_modules/mumble-client-codecs-browser/lib/encode-worker.js ++++ b/node_modules/mumble-client-codecs-browser/lib/encode-worker.js +@@ -1,10 +1,6 @@ + 'use strict'; + +-Object.defineProperty(exports, "__esModule", { +- value: true +-}); + +-exports.default = function (self) { + var opusEncoder, celt7Encoder; + var bitrate; + self.addEventListener('message', function (e) { +@@ -70,7 +66,7 @@ exports.default = function (self) { + }, [_buffer]); + } + }); +-}; ++ + + var _libopus = require('libopus.js'); + +@@ -83,3 +79,5 @@ var _toArraybuffer2 = _interopRequireDefault(_toArraybuffer); + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + + var MUMBLE_SAMPLE_RATE = 48000; ++ ++export default null +\ No newline at end of file diff --git a/node_modules/mumble-client-codecs-browser/lib/encoder-stream.js b/node_modules/mumble-client-codecs-browser/lib/encoder-stream.js index 021f131..853a99e 100644 --- a/node_modules/mumble-client-codecs-browser/lib/encoder-stream.js