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

Ruffle not switching audio #10704

Open
ActionWavele opened this issue Apr 16, 2023 · 10 comments
Open

Ruffle not switching audio #10704

ActionWavele opened this issue Apr 16, 2023 · 10 comments
Labels
audio Issues relating to audio playback bug Something isn't working desktop

Comments

@ActionWavele
Copy link

Describe the bug

when I open ruffle and then plug in my headphones, ruffle does not switch audio to my headphones, while everthing else does

Expected behavior

pretty sure this never used to be an issue

Affected platform

Desktop app

Operating system

Windows 10

Browser

No response

Additional information

No response

@ActionWavele ActionWavele added the bug Something isn't working label Apr 16, 2023
@ActionWavele ActionWavele changed the title Ruff not switching audio Ruffle not switching audio Apr 16, 2023
@n0samu
Copy link
Member

n0samu commented Apr 16, 2023

I just tried it and I cannot reproduce the issue. Maybe it's an issue with your PC's audio drivers.

@n0samu n0samu added audio Issues relating to audio playback desktop and removed bug Something isn't working labels Apr 16, 2023
@ActionWavele
Copy link
Author

I don't really update my drivers mich, so I'm not sure

@torokati44
Copy link
Member

@ActionWavele
Copy link
Author

maybe, if I was having this problem 5 years ago

@ActionWavele
Copy link
Author

ActionWavele commented May 2, 2023

No, its definitely Ruffle desktop
I tried NG player, with headphones in, wait till music plays, then unplugged, and it swapped to my speakers (which I forgot were max volume) then plug back headphones, and it switched to headphones as normal. then I tried web demo Ruffle, and same thing, no prob.

Desktop still has the issue where unplugging headphones just kills audio, no matter how many time I switch, or mess with volume mixer

I have no idea what kind of driver would only make Ruffle desktop not work, and everything else work just fine.

@n0samu n0samu added the bug Something isn't working label May 2, 2023
@n0samu
Copy link
Member

n0samu commented May 2, 2023

Okay, I finally managed to reproduce the issue. It happens on my Windows laptop when I unplug USB-C headphones, which use a separate driver from the Realtek driver for the built-in speakers and headphone jack. Here is the error that occurs:
ERROR ruffle_desktop::audio: Audio stream error: The requested device is no longer available. For example, it has been unplugged.

@n0samu
Copy link
Member

n0samu commented May 2, 2023

@ActionWavele
Copy link
Author

ActionWavele commented May 2, 2023

I don't even use USB C headphones
I just have one with a 3.5mm jack

I do get the same error when using ruffle from the command line

@sidit77
Copy link

sidit77 commented May 2, 2023

The problem is that querying the current default output with WASAPI returns the specific device (i.e. Realtek(R) Speakers) that is the current default rather than a "proxy value" that always points to the default audio device. This means that the program itself has to change its output device whenever the default output device changes (for example by registering a IMMNotificationClient) . If you don't do this the audio will keep playing on the speakers even if you plug in headphones.

You can easily reproduce this using just the cpal example synth_tones:

  1. Set the default output to speakers
    image
  2. Start the example
  3. Switch to another output while the example is playing
  4. The example should continue to play over the speaker

However, by using a ActivateAudioInterfaceAsync you can actually get a "proxy value" that always points to current default output. This is what I implemented in RustAudio/cpal#754.

@n0samu
Copy link
Member

n0samu commented May 2, 2023

Thank you for the explanation and for rebasing your PR! Looking forward to seeing it merged in the future 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
audio Issues relating to audio playback bug Something isn't working desktop
Projects
None yet
Development

No branches or pull requests

4 participants