Fix issue in Layer3.js where last frame is dropped #19
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
These updates fix an issue where Layer3#decode would drop the last frame when no next frame is available in the stream. This situation has the most impact if the audio stream is live - that is, taken from a live source. In this case, the aurora would receive the first chunk of audio - for example, four frames - and proceed to decode them. Four mp3 frames represents roughly 100msec of audio (depending on the sample rate) and takes roughly 20 msec to decode (depending on system capacity). In this instance, additional audio frames won't be received for roughly 100msec, so when Layer3#decode tries to reference the next frame while decoding the last frame in the chunk, it doesn't exist. Previously, this would cause an exception and jump out of mp3.js back to the try/catch in decoder#decode and consequently drop that last frame.