aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMary <mary@mary.zone>2023-05-13 09:15:16 +0200
committerGitHub <noreply@github.com>2023-05-13 07:15:16 +0000
commit880fd3cfcb1c394b06bdb4cd3433e23379b4fbe7 (patch)
treeb88542f5b7711634554670fd6159f2f80529d5b9 /src
parentf679f25e084b7196f1eabd6a0e9ea60bca679a75 (diff)
audio: sdl2: Do not report 5.1 if the device doesn't support it (#4908)1.1.797
* amadeus: adjust VirtualDevice channel configuration reporting with HardwareDevice * audio: sdl2: Do not report 5.1 if device doesn't support it SDL2 5.1 to Stereo conversion is terrible and make everything sound quiet. Let's not expose 5.1 if not truly supported by the device.
Diffstat (limited to 'src')
-rw-r--r--src/Ryujinx.Audio.Backends.SDL2/SDL2HardwareDeviceDriver.cs27
-rw-r--r--src/Ryujinx.Audio/Renderer/Device/VirtualDevice.cs2
-rw-r--r--src/Ryujinx.Audio/Renderer/Device/VirtualDeviceSessionRegistry.cs19
-rw-r--r--src/Ryujinx.HLE/HOS/Horizon.cs2
4 files changed, 47 insertions, 3 deletions
diff --git a/src/Ryujinx.Audio.Backends.SDL2/SDL2HardwareDeviceDriver.cs b/src/Ryujinx.Audio.Backends.SDL2/SDL2HardwareDeviceDriver.cs
index b190b4c8..d3a73cfc 100644
--- a/src/Ryujinx.Audio.Backends.SDL2/SDL2HardwareDeviceDriver.cs
+++ b/src/Ryujinx.Audio.Backends.SDL2/SDL2HardwareDeviceDriver.cs
@@ -5,6 +5,7 @@ using Ryujinx.Memory;
using Ryujinx.SDL2.Common;
using System;
using System.Collections.Concurrent;
+using System.Runtime.InteropServices;
using System.Threading;
using static Ryujinx.Audio.Integration.IHardwareDeviceDriver;
@@ -18,6 +19,13 @@ namespace Ryujinx.Audio.Backends.SDL2
private readonly ManualResetEvent _pauseEvent;
private readonly ConcurrentDictionary<SDL2HardwareDeviceSession, byte> _sessions;
+ private bool _supportSurroundConfiguration;
+
+ // TODO: Add this to SDL2-CS
+ // NOTE: We use a DllImport here because of marshaling issue for spec.
+ [DllImport("SDL2")]
+ private static extern int SDL_GetDefaultAudioInfo(IntPtr name, out SDL_AudioSpec spec, int isCapture);
+
public SDL2HardwareDeviceDriver()
{
_updateRequiredEvent = new ManualResetEvent(false);
@@ -25,6 +33,20 @@ namespace Ryujinx.Audio.Backends.SDL2
_sessions = new ConcurrentDictionary<SDL2HardwareDeviceSession, byte>();
SDL2Driver.Instance.Initialize();
+
+ int res = SDL_GetDefaultAudioInfo(IntPtr.Zero, out var spec, 0);
+
+ if (res != 0)
+ {
+ Logger.Error?.Print(LogClass.Application,
+ $"SDL_GetDefaultAudioInfo failed with error \"{SDL_GetError()}\"");
+
+ _supportSurroundConfiguration = true;
+ }
+ else
+ {
+ _supportSurroundConfiguration = spec.channels == 6;
+ }
}
public static bool IsSupported => IsSupportedInternal();
@@ -164,6 +186,11 @@ namespace Ryujinx.Audio.Backends.SDL2
public bool SupportsChannelCount(uint channelCount)
{
+ if (channelCount == 6)
+ {
+ return _supportSurroundConfiguration;
+ }
+
return true;
}
diff --git a/src/Ryujinx.Audio/Renderer/Device/VirtualDevice.cs b/src/Ryujinx.Audio/Renderer/Device/VirtualDevice.cs
index 2fa030a8..90692b00 100644
--- a/src/Ryujinx.Audio/Renderer/Device/VirtualDevice.cs
+++ b/src/Ryujinx.Audio/Renderer/Device/VirtualDevice.cs
@@ -45,7 +45,7 @@ namespace Ryujinx.Audio.Renderer.Device
/// <param name="name">The name of the <see cref="VirtualDevice"/>.</param>
/// <param name="channelCount">The count of channels supported by the <see cref="VirtualDevice"/>.</param>
/// <param name="isExternalOutput">Indicate if the <see cref="VirtualDevice"/> is provided by an external interface.</param>
- private VirtualDevice(string name, uint channelCount, bool isExternalOutput)
+ public VirtualDevice(string name, uint channelCount, bool isExternalOutput)
{
Name = name;
ChannelCount = channelCount;
diff --git a/src/Ryujinx.Audio/Renderer/Device/VirtualDeviceSessionRegistry.cs b/src/Ryujinx.Audio/Renderer/Device/VirtualDeviceSessionRegistry.cs
index 927e45ad..696af90f 100644
--- a/src/Ryujinx.Audio/Renderer/Device/VirtualDeviceSessionRegistry.cs
+++ b/src/Ryujinx.Audio/Renderer/Device/VirtualDeviceSessionRegistry.cs
@@ -1,3 +1,4 @@
+using Ryujinx.Audio.Integration;
using System.Collections.Generic;
namespace Ryujinx.Audio.Renderer.Device
@@ -22,7 +23,23 @@ namespace Ryujinx.Audio.Renderer.Device
/// The current active <see cref="VirtualDevice"/>.
/// </summary>
// TODO: make this configurable
- public VirtualDevice ActiveDevice = VirtualDevice.Devices[2];
+ public VirtualDevice ActiveDevice { get; }
+
+ public VirtualDeviceSessionRegistry(IHardwareDeviceDriver driver)
+ {
+ uint channelCount;
+
+ if (driver.GetRealDeviceDriver().SupportsChannelCount(6))
+ {
+ channelCount = 6;
+ }
+ else
+ {
+ channelCount = 2;
+ }
+
+ ActiveDevice = new VirtualDevice("AudioTvOutput", channelCount, false);
+ }
/// <summary>
/// Get the associated <see cref="T:VirtualDeviceSession[]"/> from an AppletResourceId.
diff --git a/src/Ryujinx.HLE/HOS/Horizon.cs b/src/Ryujinx.HLE/HOS/Horizon.cs
index a71837ca..166761c2 100644
--- a/src/Ryujinx.HLE/HOS/Horizon.cs
+++ b/src/Ryujinx.HLE/HOS/Horizon.cs
@@ -261,7 +261,7 @@ namespace Ryujinx.HLE.HOS
AudioInputManager = new AudioInputManager();
AudioRendererManager = new AudioRendererManager(tickSource);
AudioRendererManager.SetVolume(Device.Configuration.AudioVolume);
- AudioDeviceSessionRegistry = new VirtualDeviceSessionRegistry();
+ AudioDeviceSessionRegistry = new VirtualDeviceSessionRegistry(Device.AudioDeviceDriver);
IWritableEvent[] audioOutputRegisterBufferEvents = new IWritableEvent[Constants.AudioOutSessionCountMax];