Hello, I want to say thank you for all of the hard work that has gone into this project, it's allowed me to create some really cool things!
Summary
Physically unplugging headphones (or other devices) may result in a panic. The panic originates from an .unwrap() on a result inside the push_command body (from stream.rs), which receives E_HANDLE (0x800700, "The handle is invalid") because the stream's worker thread has already exited and closed the event handle.
Platform
cpal version: 0.18.1
Platform: Windows (WASAPI host)
Reproduction
- Start an output stream on a physical device (headphones/USB DAC).
- Physically unplug the device.
- From the thread that owns the Stream, drop it (e.g. to rebuild against the new default).
- Panic: called Result::unwrap() on an Err value: Error { code: HRESULT(0x80070006), message: "The handle is invalid." } at stream.rs:461.
Relevant code
// src/host/wasapi/stream.rs:458
fn push_command(&self, command: Command) -> Result<(), SendError<Command>> {
self.commands.send(command)?;
unsafe {
Threading::SetEvent(self.pending_scheduled_event).unwrap(); // panic
}
Ok(())
}
(StreamTrait::play and pause reach the same .unwrap())
Hello, I want to say thank you for all of the hard work that has gone into this project, it's allowed me to create some really cool things!
Summary
Physically unplugging headphones (or other devices) may result in a panic. The panic originates from an .unwrap() on a result inside the push_command body (from stream.rs), which receives
E_HANDLE (0x800700, "The handle is invalid")because the stream's worker thread has already exited and closed the event handle.Platform
cpal version: 0.18.1
Platform: Windows (WASAPI host)
Reproduction
Relevant code
(StreamTrait::play and pause reach the same .unwrap())