djanatyn / ssbm-nix

Nix expressions for Super Smash Bros. Melee players.
31 stars 17 forks source link

Audio is not adjustable #16

Closed ursi closed 3 years ago

ursi commented 3 years ago

Even changing Volume in ~/.config/slippi-netplay/Config/Dolphin.ini has no effect

image

djanatyn commented 3 years ago

Hmm, I haven't looked too much into this interface - I'll try to take a look at what Dolphin is doing when you adjust the volume bar.

I did a quick search on upstream issues (in project-slippi/Ishiiruka). I couldn't find anything related, so you might consider creating an issue there. They'll be much more familiar with the code involved:

As a workaround, it looks like your audio backend is Pulse. I think you should be able to adjust the volume for an application called dolphin-emu.

There are a few ways to do that, one of the most common is through a tool called pavucontrol (which you might already be doing):

dolphin-audio

I tend to use pulsemixer to adjust my volume.

djanatyn commented 3 years ago

After reading through a bit of the audio code, it doesn't look like there's support for adjusting PulseAudio volume within Dolphin.

I saw some comments from developers that also suggested this:

I tried to find the code for the volume slider. It looks like it toggles visibility based on the backend:

void AudioConfigPane::ToggleBackendSpecificControls(const std::string& backend)
{
    m_dpl2_decoder_checkbox->Enable(AudioCommon::SupportsDPL2Decoder(backend));

    bool supports_latency_control = AudioCommon::SupportsLatencyControl(backend);
    m_audio_latency_spinctrl->Enable(supports_latency_control);
    m_audio_latency_label->Enable(supports_latency_control);

    bool supports_volume_changes = AudioCommon::SupportsVolumeChanges(backend);
    m_volume_slider->Enable(supports_volume_changes);
    m_volume_text->Enable(supports_volume_changes);
}

We can look at the definition of SupportsVolumeChanges:

bool SupportsVolumeChanges(const std::string& backend)
{
    // FIXME: this one should ask the backend whether it supports it.
    //       but getting the backend from string etc. is probably
    //       too much just to enable/disable a stupid slider...
    return backend == BACKEND_COREAUDIO 
        || backend == BACKEND_OPENAL 
        || backend == BACKEND_XAUDIO2 
        || backend == BACKEND_DIRECTSOUND 
        || backend == BACKEND_CUBEB 
        || backend.find(BACKEND_EXCLUSIVE_WASAPI) != std::string::npos 
        || backend == BACKEND_SHARED_WASAPI;
}

Note the absence of BACKEND_PULSEAUDIO.

Interestingly, it looks like this was supported at one point?

Based on this, I think we can safely say that volume changes are not supported within Dolphin for PulseAudio backends.

ursi commented 3 years ago

Wow, nice work! I guess that solves that. Also I feel so dumb - on my old computer I used pavucontrol all the time to switch between headphones and my monitor speakers, but my new computer somehow switches the output device automatically, which lead me to forget that that program existed. It does the trick just fine, thanks!