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

Fix issue in Layer3.js where last frame is dropped #19

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

DeusExLibris
Copy link

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.

@devongovett
Copy link
Member

I'll review this more in depth in a bit. For now, can you convert the tabs to 4 space indentation? Thanks!

@DeusExLibris
Copy link
Author

Done - let me know if I missed anything

@DeusExLibris
Copy link
Author

BTW, my original description of the issue - if you didn't see it - is here: #18

@DeusExLibris
Copy link
Author

I just discovered a related issue. If the audio is being streamed and the first block of data contains only the ID3 header, MP3Demuxer.probe fails even when it receives a valid ID3 header as it tries to read the first frame and it hasn't been received yet. I am working on a fix for this as well.

Thalhammer added a commit to Thalhammer/mp3.js-ts that referenced this pull request Jun 21, 2020
Merge of open pull request in parent project audiocogs/mp3.js#19
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

Successfully merging this pull request may close these issues.

2 participants