-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No sound when unplugging and plugging audio device back in #271
Comments
Same issue. As far as I can tell the issue is that OutputStream ties itself to a specific physical device at the time of creation. This means that if the specific device it is tied to gets disconnected, it will stop working, and also that if you change the default output device at a later time, it will ignore the change and keep playing audio on the old device. |
I was looking at Rodio for reference in how it handle device disconnection (to use on my code), but it does not handle it. The relevant code: Lines 198 to 230 in 0356d81
The tricky part is that the previous Stream needs to be dropped and a new one created, but Stream is not Send so there is no way to do that in the error_callback (the callback must be Send). In my code I will probably need to handle the cpal state in another thread, and handle the error there by messaging, but this would not work for WebAssembly... Edit: looking at kira, it does pretty much exactly what I describe, and doesn't handle device disconnection in WebAssembly (it may not even be necessary, on second thought). |
Say I unplug my headphones and plug them in again. What happens to me right now is that even after the replug, I have no audio output (from
play_raw()
).I tried calling
default_output_device()
again but the problem persists - the function returnsSome(Device)
, but callingplay_raw()
on it plays no sound.Restarting my app works, though.
The text was updated successfully, but these errors were encountered: