Lazily initialize fallback client
So we do not need to load the huge encoders bundle if we do not even need it.
This commit is contained in:
parent
506a799592
commit
59bb00cbe4
|
@ -457,7 +457,9 @@ class GlobalBindings {
|
||||||
// Note: This call needs to be delayed until the user has interacted with
|
// Note: This call needs to be delayed until the user has interacted with
|
||||||
// the page in some way (which at this point they have), see: https://goo.gl/7K7WLu
|
// the page in some way (which at this point they have), see: https://goo.gl/7K7WLu
|
||||||
let ctx = audioContext()
|
let ctx = audioContext()
|
||||||
this.fallbackConnector.setSampleRate(ctx.sampleRate)
|
if (!this.webrtc) {
|
||||||
|
this.fallbackConnector.setSampleRate(ctx.sampleRate)
|
||||||
|
}
|
||||||
if (!this._delayedMicNode) {
|
if (!this._delayedMicNode) {
|
||||||
this._micNode = ctx.createMediaStreamSource(this._micStream)
|
this._micNode = ctx.createMediaStreamSource(this._micStream)
|
||||||
this._delayNode = ctx.createDelay()
|
this._delayNode = ctx.createDelay()
|
||||||
|
|
|
@ -12,8 +12,6 @@ import Worker from './worker'
|
||||||
*/
|
*/
|
||||||
class WorkerBasedMumbleConnector {
|
class WorkerBasedMumbleConnector {
|
||||||
constructor () {
|
constructor () {
|
||||||
this._worker = new Worker()
|
|
||||||
this._worker.addEventListener('message', this._onMessage.bind(this))
|
|
||||||
this._reqId = 1
|
this._reqId = 1
|
||||||
this._requests = {}
|
this._requests = {}
|
||||||
this._clients = {}
|
this._clients = {}
|
||||||
|
@ -29,6 +27,10 @@ class WorkerBasedMumbleConnector {
|
||||||
}
|
}
|
||||||
|
|
||||||
_postMessage (msg, transfer) {
|
_postMessage (msg, transfer) {
|
||||||
|
if (!this._worker) {
|
||||||
|
this._worker = new Worker()
|
||||||
|
this._worker.addEventListener('message', this._onMessage.bind(this))
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
this._worker.postMessage(msg, transfer)
|
this._worker.postMessage(msg, transfer)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
Loading…
Reference in a new issue