Skip to content
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

Input stream silently changes to system default input device when disconnected (macOS) #704

Open
generalelectrix opened this issue Oct 7, 2022 · 2 comments

Comments

@generalelectrix
Copy link
Contributor

Hi there, first of all thank you SO MUCH for maintaining this library!

I'm running into what might be a bug on macOS. I have an external USB audio device connected, and I start a stream reading from this input. This works perfectly. Now, I want to implement some logic to inform me if the device has disconnected/provide support for automatic re-connection. Unfortunately, when I pull the USB cable and the device disappears, my error_callback is never invoked - the stream continues running, but appears to fall back to receiving input from whatever the system default input device happens to be at that moment.

Any suggestions? Is this just an idiosyncracy of CoreAudio?

@est31
Copy link
Member

est31 commented Oct 7, 2022

Thanks for using cpal and for reaching out. Sadly, I don't have macOS expertise and the project is also lacking a macOS expert in the maintainers, so it's likely that you won't get an answer here.

@generalelectrix
Copy link
Contributor Author

Thanks for the guidance - I might be able to take a stab at implementing something based on how other projects are handling it. The main example I've found so far is this section of code in rtaudio
https://github.com/thestk/rtaudio/blob/master/RtAudio.cpp#L1907-L1916

Looks like the approach taken there is to register a callback that is triggered when the device is no longer "alive", which calls a stream close method. If you could provide a bit of guidance as to how cpal is handling this problem in the general case (for other backends), I could at least dedicate a bit of time to experimentation and see if I can implement something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants