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 thread safety issue in MP3Compressor. #129

Merged
merged 4 commits into from
Jul 28, 2022

Conversation

psobot
Copy link
Member

@psobot psobot commented Jul 28, 2022

Fixes #127.

LAME's hip_decode family of functions makes use of a single static buffer when decoding MP3 frames. This precludes calling hip_decode from multiple threads, as each thread will overwrite the buffer's contents.

This PR fixes the issue by:

  • avoiding calling the function that uses the static buffer
  • copying the required logic into a lame_overrides.c file, which implements hip_decode_threadsafe
  • calling hip_decode_threadsafe from MP3Compressor instead.
  • adding a test to ensure that all deterministic plugins generate identical output when called from multiple threads concurrently

(cc @iCorv)

@psobot psobot added the bug Something isn't working label Jul 28, 2022
@psobot psobot changed the title Fix thread safety issue in LAME's hip_decode function. Fix thread safety issue in MP3Compressor. Jul 28, 2022
@psobot psobot merged commit 9a7f1f2 into master Jul 28, 2022
@psobot psobot deleted the psobot/fix-mp3compressor-thread-safety branch July 28, 2022 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MP3Compressor introduces audible glitches
2 participants