tesselode / kira

Library for expressive game audio.
https://crates.io/crates/kira
Apache License 2.0
837 stars 42 forks source link

Freeing resources while quitting issue #12

Closed simast closed 3 years ago

simast commented 3 years ago

Seeing this error in console on every quit (and it takes indeed 1 second for program to exit):

Kira failed to free up resources after 1000 milliseconds, giving up

Seems this is the bare minimum example that reproduces this issue for me:

let mut manager = AudioManager::new(AudioManagerSettings::default())?;
let music_track = manager.add_sub_track(SubTrackSettings::default())?;

Tested on macOS.

Edit: Realized that the issue seems to be related to the fact I keep the sub-track reference in the same object as audio manager:

pub struct Audio {
    manager: AudioManager,
    music_track: SubTrackHandle,
}

Not sure how I can workaround this? I do need a reference to this track handle for later use.

tesselode commented 3 years ago

I'm able to reproduce this issue. I'll have to think about a good solution to this. I'll get back to you when I have one.

tesselode commented 3 years ago

So!

I know why this is happening.

Bad news: this is hard to fix with Kira's current architecture Good news: I'm in the middle of rearchitecting Kira in a way that will fix this problem!

In the meantime, I don't have a great recommendation other than: drop the SubTrackHandle before dropping the AudioManager. I know it's a pain, so I will be working to make resource management more ergonomic.

simast commented 3 years ago

👍 not a problem if the fix is on the way as part of the refactor you are doing. Awesome library and API btw.

tesselode commented 3 years ago

thanks!

tesselode commented 3 years ago

Fixed in 31642b0.