-
Notifications
You must be signed in to change notification settings - Fork 71
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
[Bug] default_speaker() returns the wrong bluetooth speaker #122
Comments
Is Windows showing the disconnected headphones as its default speaker as well? Perhaps Windows only changes the default once some app tries to play audio, but technically we query it before playing? That would be unfortunate. |
Windows shows the correct default speaker, and doesn’t list the disconnected one as an option. Weirdly, calling |
The default device is fetched from Windows in mediafoundation.py:274 using the function GetDefaultAudioEndpoint. Perhaps the documentation on the eRole parameter is outdated, and we should be using Does it work correctly if you change the third parameter from 0 to 1? |
I’ll test this within a few days and find out. |
Tried to reproduce the error, not having any luck even on a fresh restart. Nothing about my code has changed and I haven't updated python or any packages. I tested the change you mentioned anyway, and nothing changed - everything works great. I'm using your library in a background service I keep running all the time, so I'll keep an eye on it and try to do more testing if/when the problem shows up again. |
This sounds like a bug in WASAPI. But it's probably instead some subtle issue in soundcard's use of WASAPI. I have honestly no idea what is going on, though. That said, Bluetooth audio support on Windows has always been a bit flakey in my experience, and your experiences with the issue half-solving itself on reboot seems to confirm that. I will say that there are probably more robust ways of "just" playing audio on the default device than using soundcard. If I remember correctly, the WASAPI has a few functions for playing something without selecting an audio device first. But soundcard is specifically about playing/recording from a particular sound card, and thus does not use the simple APIs. Which conversely apparently leads to these connection/disconnection issues. Sorry I can't be of much help, there. But please do let me know if you find out more about this behavior. |
Thanks, knowing to check into WASAPI narrows it down for me and hopefully I’ll be able to find the issue. |
I use two bluetooth devices with my computer: a speaker and headphones. When I call
default_speaker()
while either are connected (and set to default automatically by windows), it returns the headphones - even if they aren't connected. Trying to play through the returned speaker object throws an error, so it's clearly not just the wrong name.The really weird part is it sometimes works flawlessly, letting me switch between speakers, headphones, and analog out without any trouble. I haven't figured out what's causing the difference in behavior, but I wanted to note what I've found in case someone else runs into the same thing.
Thanks for making this library, it's been really useful for me so far. I'll make sure to update this if I figure out anything more.
The text was updated successfully, but these errors were encountered: