Skip to content

Data discarded when reading header if data not available #20

Description

@richardlevy

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions