Bläddra i källkod

Force exclusive mode on WASAPI output

Since BASS already uses non-exclusive WASAPI for normal output, there's
no point in allowing buggier non-exclusive WASAPI output.
Clément Wolf 3 veckor sedan
förälder
incheckning
9827a8ef44

+ 0 - 1
src/App/Osu/Osu.cpp

@@ -384,7 +384,6 @@ Osu::Osu(int instanceID) {
         ->setCallback(fastdelegate::MakeDelegate(sound_engine, &SoundEngine::restart));
     convar->getConVarByName("win_snd_wasapi_buffer_size")->setCallback(_RESTART_SOUND_ENGINE_ON_CHANGE);
     convar->getConVarByName("win_snd_wasapi_period_size")->setCallback(_RESTART_SOUND_ENGINE_ON_CHANGE);
-    convar->getConVarByName("win_snd_wasapi_exclusive")->setCallback(_RESTART_SOUND_ENGINE_ON_CHANGE);
     convar->getConVarByName("asio_buffer_size")->setCallback(_RESTART_SOUND_ENGINE_ON_CHANGE);
 
     // Initialize skin after sound engine has started, or else sounds won't load properly

+ 1 - 0
src/App/Osu/OsuChangelog.cpp

@@ -51,6 +51,7 @@ OsuChangelog::OsuChangelog(Osu *osu) : OsuScreenBackable(osu) {
     latest.changes.push_back("- Fixed replay playback starting too fast");
     latest.changes.push_back("- Fixed restarting SoundEngine not kicking the player out of play mode");
     latest.changes.push_back("- Fixed ALT key not working on linux");
+    latest.changes.push_back("- Forced exclusive mode when using WASAPI output");
     latest.changes.push_back("- Disabled score submission when mods are toggled mid-game");
     latest.changes.push_back("- Removed support for the Nintendo Switch");
     latest.changes.push_back("- Updated protocol version");

+ 0 - 3
src/App/Osu/OsuOptionsMenu.cpp

@@ -733,9 +733,6 @@ OsuOptionsMenu::OsuOptionsMenu(Osu *osu) : OsuScreenBackable(osu) {
             addLabel("Windows 10: Start at 1 ms,")->setTextColor(0xff666666);
             addLabel("and if crackling: increment until fixed.")->setTextColor(0xff666666);
             addLabel("(lower is better, non-wasapi has ~40 ms minimum)")->setTextColor(0xff666666);
-            addCheckbox("Exclusive Mode",
-                        "Dramatically reduces latency, but prevents other applications from capturing/playing audio.",
-                        convar->getConVarByName("win_snd_wasapi_exclusive"));
             addLabel("");
             addLabel("");
             addLabel("WARNING: Only if you know what you are doing")->setTextColor(0xffff0000);

+ 2 - 2
src/App/Osu/OsuVolumeOverlay.cpp

@@ -261,7 +261,7 @@ bool OsuVolumeOverlay::canChangeVolume() {
 }
 
 void OsuVolumeOverlay::gainFocus() {
-    if(engine->getSound()->isWASAPI() && convar->getConVarByName("win_snd_wasapi_exclusive")->getBool()) {
+    if(engine->getSound()->isWASAPI()) {
         // NOTE: wasapi exclusive mode controls the system volume, so don't bother
         return;
     }
@@ -271,7 +271,7 @@ void OsuVolumeOverlay::gainFocus() {
 }
 
 void OsuVolumeOverlay::loseFocus() {
-    if(engine->getSound()->isWASAPI() && convar->getConVarByName("win_snd_wasapi_exclusive")->getBool()) {
+    if(engine->getSound()->isWASAPI()) {
         // NOTE: wasapi exclusive mode controls the system volume, so don't bother
         return;
     }

+ 2 - 10
src/Engine/SoundEngine.cpp

@@ -59,8 +59,6 @@ ConVar win_snd_wasapi_buffer_size(
 ConVar win_snd_wasapi_period_size(
     "win_snd_wasapi_period_size", 0.0f, FCVAR_NONE,
     "interval between OutputWasapiProc calls in seconds (e.g. 0.016 = 16 ms) (0 = use default)");
-ConVar win_snd_wasapi_exclusive("win_snd_wasapi_exclusive", false, FCVAR_NONE,
-                                "whether to use exclusive device mode to further reduce latency");
 
 ConVar asio_buffer_size("asio_buffer_size", -1, FCVAR_NONE,
                         "buffer size in samples (usually 44100 samples per second)");
@@ -239,10 +237,6 @@ void SoundEngine::updateOutputDevices(bool printInfo) {
         }
 
         soundDevice.driver = OutputDriver::BASS;
-        if(env->getOS() == Environment::OS::OS_WINDOWS && soundDevice.name != UString("No sound")) {
-            soundDevice.name.append(" [DirectSound]");
-        }
-
         m_outputDevices.push_back(soundDevice);
 
         debugLog("DSOUND: Device %i = \"%s\", enabled = %i, default = %i\n", d, deviceInfo.name, (int)isEnabled,
@@ -486,11 +480,9 @@ bool SoundEngine::initializeOutputDevice(OUTPUT_DEVICE device) {
 
         // BASS_WASAPI_RAW ignores sound "enhancements" that some sound cards offer (adds latency)
         // BASS_MIXER_NONSTOP prevents some sound cards from going to sleep when there is no output
-        auto flags = BASS_WASAPI_RAW | BASS_MIXER_NONSTOP;
-        if(win_snd_wasapi_exclusive.getBool()) flags |= BASS_WASAPI_EXCLUSIVE;
+        auto flags = BASS_WASAPI_RAW | BASS_MIXER_NONSTOP | BASS_WASAPI_EXCLUSIVE;
 
-        debugLog("WASAPI Exclusive Mode = %i, bufferSize = %f, updatePeriod = %f\n",
-                 (int)win_snd_wasapi_exclusive.getBool(), bufferSize, updatePeriod);
+        debugLog("WASAPI bufferSize = %f, updatePeriod = %f\n", bufferSize, updatePeriod);
         if(!BASS_WASAPI_Init(device.id, 0, 0, flags, bufferSize, updatePeriod, OutputWasapiProc, NULL)) {
             const int errorCode = BASS_ErrorGetCode();
             if(errorCode == BASS_ERROR_WASAPI_BUFFER) {

+ 3 - 3
src/Engine/SoundEngine.h

@@ -13,9 +13,9 @@
 
 enum class OutputDriver {
     NONE,
-    BASS,
-    BASS_WASAPI,
-    BASS_ASIO,
+    BASS,         // directsound/wasapi non-exclusive mode/alsa
+    BASS_WASAPI,  // exclusive mode
+    BASS_ASIO,    // exclusive move
 };
 
 struct OUTPUT_DEVICE {