Skip to content

Commit a0bf846

Browse files
committed
Update decode-wma.js
1 parent b9dd3bf commit a0bf846

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

packages/decode-wma/decode-wma.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ class WMADecoder {
427427

428428
// Phase 2: incremental — extract fixed-size packets from new data
429429
let ps = this._meta.packetSize
430+
if (!ps) { this._left = buf; return EMPTY } // variable-size: accumulate, decode on flush
430431
let pkts = []
431432
let pos = 0
432433
while (pos + ps <= buf.length) {
@@ -484,7 +485,12 @@ class WMADecoder {
484485
return { channelData, sampleRate: this.sr }
485486
}
486487

487-
flush() { this._left = null; return EMPTY }
488+
flush() {
489+
let r = EMPTY
490+
if (this._left && this._meta && !this._meta.packetSize) r = this._decodePkts([this._left], this._meta)
491+
this._left = null
492+
return r
493+
}
488494

489495
free() {
490496
if (this.done) return

0 commit comments

Comments
 (0)