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
|
||||
// the page in some way (which at this point they have), see: https://goo.gl/7K7WLu
|
||||
let ctx = audioContext()
|
||||
if (!this.webrtc) {
|
||||
this.fallbackConnector.setSampleRate(ctx.sampleRate)
|
||||
}
|
||||
if (!this._delayedMicNode) {
|
||||
this._micNode = ctx.createMediaStreamSource(this._micStream)
|
||||
this._delayNode = ctx.createDelay()
|
||||
|
|
|
@ -12,8 +12,6 @@ import Worker from './worker'
|
|||
*/
|
||||
class WorkerBasedMumbleConnector {
|
||||
constructor () {
|
||||
this._worker = new Worker()
|
||||
this._worker.addEventListener('message', this._onMessage.bind(this))
|
||||
this._reqId = 1
|
||||
this._requests = {}
|
||||
this._clients = {}
|
||||
|
@ -29,6 +27,10 @@ class WorkerBasedMumbleConnector {
|
|||
}
|
||||
|
||||
_postMessage (msg, transfer) {
|
||||
if (!this._worker) {
|
||||
this._worker = new Worker()
|
||||
this._worker.addEventListener('message', this._onMessage.bind(this))
|
||||
}
|
||||
try {
|
||||
this._worker.postMessage(msg, transfer)
|
||||
} catch (err) {
|
||||
|
|
Loading…
Reference in a new issue