ExPixel / miniaudio-rs

Rust bindings for miniaudio C library.
https://crates.io/crates/miniaudio
MIT License
49 stars 20 forks source link

SpinLock not initialized correctly #30

Closed sagacity closed 4 years ago

sagacity commented 4 years ago

Hi! Great that seeking support was added. However, the changes introduced in 9cafedb31cb3a94c88ffdb4447855336300c2574 don't seem to be correctly creating the SpinRwLock guarding the SyncDecoder. The constructor SpinRwLock::new is never called, instead the SyncDecoder is created by transmuting the decoder returned from MiniAudio (e.g. in SyncDecoder::from_file).

This causes the spinlock's lock field to not be initialized to zero but rather to something undefined. This, in turn, causes try_write to fail since it does a compare and swap, expecting the value of the lock to be zero.

Background: The new playback-decoder-repeat example hangs on MacOS on the playback_decoder.read_pcm_frames(output) statement.

ExPixel commented 4 years ago

This is what I get for copying and pasting the constructors. I'll put out a fix soon, thanks for letting me know.

ExPixel commented 4 years ago

This should be fixed in 6cfd3ab57722c2394cf43a0afd5675506fdf54ca, let me know if the issue persists.