tesselode / kira

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

Bug: trying to play StreamingSoundData with ogg may cause AudioManager::play and subsequent operations to fail #96

Open Kolsky opened 1 month ago

Kolsky commented 1 month ago

The offender

This probably should've been reported to Symphonia instead, as it seems to be the source of the problem, but nevertheless it was first discovered indirectly (it's not clear who is responsible in this scenario), and a second issue was found later on.

This must be related to https://github.com/pdeljanov/Symphonia/issues/207. When I try to play file using StaticSoundData, it's fine, I assume because it's fully decoded and normalized. When I try to play the same file using StreamingSoundData, it fails, and the source of error tracks down to this line in demuxer.rs. Adding .start_position(Samples(1024)) does "fix" the issue, but trying to seek to 0 manually later fails again and stops the audio (probably the right thing to do, given https://github.com/tesselode/kira/commit/eb3cd092133717425c6b26c452aa6e3dca8f97c4).

rodio in these scenarios either returns Err on Decoder creation with the cryptic end of stream message, or if it succeeds, trying to seek could result in an internal panic (happened at least once).

It's not at all clear how to get this start_ts to skip decoding the unnecessary part entirely, or how to remove it from the audio with ffmpeg too.