Description
I'm trying to make a very simple SPC player demo. Whenever I try to seek the SPC file, I get:
UnderflowError {name: 'AV.UnderflowError'}
AV.Stream.Stream.advance @ spc-aurora.js:291
AV.Stream.Stream.seek @ spc-aurora.js:321
AV.Decoder.Decoder.seek @ spc-aurora.js:1265
AV.Player.Player.seek @ spc-aurora.js:1765
(anonymous) @ (index):88
You can see the bug here: https://kethinov.github.io/spc-playback-demo/
The full source code for my SPC demo which reproduces the bug is here: https://github.com/kethinov/spc-playback-demo
I've been banging my head debugging this for quite a while and all I've learned is the problem traces to these two functions from Aurora:
Stream.prototype.available = function(bytes) {
return bytes <= this.list.availableBytes - this.localOffset;
};
And:
Stream.prototype.advance = function(bytes) {
if (!this.available(bytes)) {
throw new AV.UnderflowError();
}
this.localOffset += bytes;
this.offset += bytes;
while (this.list.first && this.localOffset >= this.list.first.length) {
this.localOffset -= this.list.first.length;
this.list.advance();
}
return this;
};
Specifically what's happening is when I seek forward, advance
calls available
. When available
returns false, advance
throws the UnderflowError
. The reason available
is returning false is this.localOffset
is always 0. When I play other file formats in Aurora, this.localOffset
is not 0 when seeking. This is making me wonder if there is a bug in spc.js that is causing this, but I have been unable to trace the problem any deeper to understand what is at the root of it.
Can anyone here help me get seeking working in my demo?