reset the decoder if it errors
This commit is contained in:
parent
a779d5d02a
commit
58c7f8a132
@ -424,17 +424,24 @@ ImaAdpcmCodec.prototype.decodeNibble = function(nibble) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function OpusCodec(callback) {
|
function OpusCodec(callback) {
|
||||||
this.decoder = new AudioDecoder({
|
this.callback = callback;
|
||||||
|
this.resetDecoder();
|
||||||
|
}
|
||||||
|
|
||||||
|
OpusCodec.prototype.resetDecoder = function() {
|
||||||
|
var me = this;
|
||||||
|
me.decoder = new AudioDecoder({
|
||||||
output: function(audioData) {
|
output: function(audioData) {
|
||||||
var buffer = new Float32Array(audioData.numberOfFrames * audioData.numberOfChannels);
|
var buffer = new Float32Array(audioData.numberOfFrames * audioData.numberOfChannels);
|
||||||
audioData.copyTo(buffer, {planeIndex: 0});
|
audioData.copyTo(buffer, {planeIndex: 0});
|
||||||
callback(buffer);
|
me.callback(buffer);
|
||||||
},
|
},
|
||||||
error: function(e) {
|
error: function(e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
|
me.resetDecoder();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.decoder.configure({
|
me.decoder.configure({
|
||||||
codec: "opus",
|
codec: "opus",
|
||||||
sampleRate: 12000,
|
sampleRate: 12000,
|
||||||
numberOfChannels: 1
|
numberOfChannels: 1
|
||||||
|
Loading…
Reference in New Issue
Block a user