tesselode / kira

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

how to stop a streaming sound? #79

Open robtfm opened 3 months ago

robtfm commented 3 months ago

sorry if i'm missing something obvious.

i have a struct that implements Decoder which i wrap into a StreamingSoundData and send to AudioManager::play.

when the stream ends i return an error from decode, but kira continues to busy-wait poll the stream, burning cpu pretty hard.

i can't see a way to tell the audio manager to stop the handle, or to reply from the decoder that the stream has ended.

what should i do?

thanks

robtfm commented 3 months ago

i now see i can stop the handle, sorry.

would it make sense for this to be automatic if the decoder returns an error? or have another mechanism for the decoder to report that the stream is finished?

tesselode commented 3 months ago

Indeed, that is an oversight. I'm not sure if there's any realistic scenarios where a decoder returns an error, but it can still continue decoding. So it might be best to just stop the sound on the first error.