Skip to content

Commit

Permalink
Marke Encoder as Send + Sync to enable multithreaded use (#4)
Browse files Browse the repository at this point in the history
To quote LAME 3.99.5 HACKING:
THREADSAFE:

Lame should now be thread safe and re-entrant. 
The only problem seems to be some OS's allocate small
stacks (< 128K) to threads launched by applictions, and this
is not enough for LAME.  Fix is to increase the stack space,
or move some of our automatic variables onto the heap with
by using bug-prove malloc()'s and free().
  • Loading branch information
jhbruhn authored Mar 17, 2024
1 parent 5ebd720 commit 0bb1a2c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,11 @@ impl Drop for Encoder {
}
}

/// According to LAME 3.99.5 HACKING, it is thread-safe.
unsafe impl Send for Encoder {}
/// According to LAME 3.99.5 HACKING, it is thread-safe.
unsafe impl Sync for Encoder {}

///Creates default encoder with 192kbps bitrate and best possible quality.
pub fn encoder() -> Result<Encoder, BuildError> {
match Builder::new() {
Expand Down

0 comments on commit 0bb1a2c

Please sign in to comment.