audiocogs / ogg.js

An Ogg demuxer for aurora.js ported using emscripten

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Files less BUFFER_SIZE not playing

strobox opened this issue · comments

Files less BUFFER_SIZE not playing. That code

while (this._stream.available(BUFFER_SIZE)) {
      Ogg.HEAPU8.set(this._stream.readBuffer(BUFFER_SIZE).data, this.buf);
      Ogg._AVOggRead(this.ogg, this.buf, BUFFER_SIZE, this.callback);
    }

To get it work I've changed it to

    do {
      var toRead = BUFFER_SIZE<=this._stream.list.availableBytes?BUFFER_SIZE:this._stream.list.availableBytes;
      Ogg.HEAPU8.set(this._stream.readBuffer(toRead).data, this.buf);
      Ogg._AVOggRead(this.ogg, this.buf, toRead, this.callback);
    } while (this._stream.available(BUFFER_SIZE))

I've done it by guess, and without clear understanding what i'm doing.