Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data discarded when reading header if data not available #20

Open
richardlevy opened this issue Apr 22, 2015 · 1 comment
Open

Data discarded when reading header if data not available #20

richardlevy opened this issue Apr 22, 2015 · 1 comment

Comments

@richardlevy
Copy link

Hi,

I've created a Node FLAC player using Aurora and FLAC.JS that streams FLAC files from an HTTP server.

Streaming from the server on the same Mac works fine. When I do it over the network I start to hit issues. The FLAC files in question are identical.

FLAC.js throws a "STREAMINFO can only occur once" error.

Adding a bit of debug in both the working and failing scenarios I think I've spotted the difference.

As FLAC.js reads the blockHeaders info in readChunk, if it reads the type and size, but there's not enough data (i.e. the value of size) in the stream, it returns from the function. It will then subsequently re-enter this function to carry on reading the data and will read another byte from the stream (because it's still processing blockHeader), therefore advancing the stream a byte into the blockHeader data that it hadn't finished processing last time around.

I've tested a fix locally and will submit a pull request.

Thanks
Rich

richardlevy added a commit to richardlevy/flac.js that referenced this issue Apr 22, 2015
richardlevy added a commit to richardlevy/flac.js that referenced this issue Apr 23, 2015
@untergrundbahn
Copy link

I faced this problem also. In most cases this problem does not appear because AV.FileSource.chunkSize and AV.HTTPSource.chunkSize in the aurora.js equal to 1 MiB by default, this is enough in most cases for parse all headers of a FLAC file without interrupting parsing process and putting extra data into the stream.
For reproduce that issue create aurora.js player instance:

var player = AV.Player.fromURL(url);

or

var player = AV.Player.fromFile(file);

and set chunkSize value to 64 KiB for example

player.asset.source.chunkSize = 65535;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants