|
|
@ -51,7 +51,7 @@ var VorbisDecoder = AV.Decoder.extend(function() { |
|
|
|
|
|
|
|
|
|
|
|
this.callback = Vorbis.Runtime.addFunction(function(len) { |
|
|
|
this.callback = Vorbis.Runtime.addFunction(function(len) { |
|
|
|
var samples = Vorbis.HEAPF32.subarray(offset, offset + len); |
|
|
|
var samples = Vorbis.HEAPF32.subarray(offset, offset + len); |
|
|
|
self.decodedBuffer = new Float32Array(samples); |
|
|
|
self.emit('data', new Float32Array(samples)); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -72,8 +72,6 @@ var VorbisDecoder = AV.Decoder.extend(function() { |
|
|
|
var status = 0; |
|
|
|
var status = 0; |
|
|
|
if ((status = Vorbis._VorbisDecode(this.vorbis, this.buf, packet.length, this.callback)) !== 0) |
|
|
|
if ((status = Vorbis._VorbisDecode(this.vorbis, this.buf, packet.length, this.callback)) !== 0) |
|
|
|
throw new Error("Vorbis decoding error: " + status); |
|
|
|
throw new Error("Vorbis decoding error: " + status); |
|
|
|
|
|
|
|
|
|
|
|
return this.decodedBuffer; |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
this.prototype.destroy = function() { |
|
|
|
this.prototype.destroy = function() { |
|
|
@ -103,20 +101,20 @@ OggDemuxer.plugins.push({ |
|
|
|
|
|
|
|
|
|
|
|
init: function() { |
|
|
|
init: function() { |
|
|
|
this.vorbis = Vorbis._VorbisInit(); |
|
|
|
this.vorbis = Vorbis._VorbisInit(); |
|
|
|
this.buflen = 4096; |
|
|
|
this.buflen = 4192; |
|
|
|
this.buf = Vorbis._malloc(this.buflen); |
|
|
|
this.vorBuf = Vorbis._malloc(this.buflen); |
|
|
|
this.headers = 3; |
|
|
|
this.headers = 3; |
|
|
|
this.headerBuffers = []; |
|
|
|
this.headerBuffers = []; |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
readHeaders: function(packet) { |
|
|
|
readHeaders: function(packet) { |
|
|
|
if (this.buflen < packet.length) { |
|
|
|
if (this.buflen < packet.length) { |
|
|
|
this.buf = Vorbis._realloc(this.buf, packet.length); |
|
|
|
this.vorBuf = Vorbis._realloc(this.vorBuf, packet.length); |
|
|
|
this.buflen = packet.length; |
|
|
|
this.buflen = packet.length; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Vorbis.HEAPU8.set(packet, this.buf); |
|
|
|
Vorbis.HEAPU8.set(packet, this.vorBuf); |
|
|
|
if (Vorbis._VorbisHeaderDecode(this.vorbis, this.buf, packet.length) !== 0) |
|
|
|
if (Vorbis._VorbisHeaderDecode(this.vorbis, this.vorBuf, packet.length) !== 0) |
|
|
|
throw new Error("Invalid vorbis header"); |
|
|
|
throw new Error("Invalid vorbis header"); |
|
|
|
|
|
|
|
|
|
|
|
this.headerBuffers.push(packet); |
|
|
|
this.headerBuffers.push(packet); |
|
|
@ -141,7 +139,7 @@ OggDemuxer.plugins.push({ |
|
|
|
this.emit('metadata', this.metadata); |
|
|
|
this.emit('metadata', this.metadata); |
|
|
|
|
|
|
|
|
|
|
|
Vorbis._VorbisDestroy(this.vorbis); |
|
|
|
Vorbis._VorbisDestroy(this.vorbis); |
|
|
|
Vorbis._free(this.buf); |
|
|
|
Vorbis._free(this.vorBuf); |
|
|
|
this.vorbis = null; |
|
|
|
this.vorbis = null; |
|
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < 3; i++) |
|
|
|
for (var i = 0; i < 3; i++) |
|
|
|