audio: Implement a SDL2 backend (#2258)
* audio: Implement a SDL2 backend This adds support to SDL2 as an audio backend. It has the same compatibility level as OpenAL without its issues. I also took the liberty of restructuring the SDL2 code to have one shared project between audio and input. The configuration version was also incremented. * Address gdkchan's comments * Fix update logic * Add an heuristic to pick the correct target sample count wanted by the game * Address gdkchan's comments * Address Ac_k's comments * Fix audren output * Address gdkchan's comments
This commit is contained in:
parent
106512229e
commit
eb056218a1
16 changed files with 511 additions and 14 deletions
|
@ -26,6 +26,7 @@
|
|||
<ProjectReference Include="..\Ryujinx.Input\Ryujinx.Input.csproj" />
|
||||
<ProjectReference Include="..\Ryujinx.Input.SDL2\Ryujinx.Input.SDL2.csproj" />
|
||||
<ProjectReference Include="..\Ryujinx.Audio.Backends.OpenAL\Ryujinx.Audio.Backends.OpenAL.csproj" />
|
||||
<ProjectReference Include="..\Ryujinx.Audio.Backends.SDL2\Ryujinx.Audio.Backends.SDL2.csproj" />
|
||||
<ProjectReference Include="..\Ryujinx.Audio.Backends.SoundIo\Ryujinx.Audio.Backends.SoundIo.csproj" />
|
||||
<ProjectReference Include="..\Ryujinx.Common\Ryujinx.Common.csproj" />
|
||||
<ProjectReference Include="..\Ryujinx.HLE\Ryujinx.HLE.csproj" />
|
||||
|
|
|
@ -5,6 +5,7 @@ using LibHac.Common;
|
|||
using LibHac.Ns;
|
||||
using Ryujinx.Audio.Backends.Dummy;
|
||||
using Ryujinx.Audio.Backends.OpenAL;
|
||||
using Ryujinx.Audio.Backends.SDL2;
|
||||
using Ryujinx.Audio.Backends.SoundIo;
|
||||
using Ryujinx.Audio.Integration;
|
||||
using Ryujinx.Common.Configuration;
|
||||
|
@ -327,7 +328,18 @@ namespace Ryujinx.Ui
|
|||
|
||||
IHardwareDeviceDriver deviceDriver = new DummyHardwareDeviceDriver();
|
||||
|
||||
if (ConfigurationState.Instance.System.AudioBackend.Value == AudioBackend.SoundIo)
|
||||
if (ConfigurationState.Instance.System.AudioBackend.Value == AudioBackend.SDL2)
|
||||
{
|
||||
if (SDL2HardwareDeviceDriver.IsSupported)
|
||||
{
|
||||
deviceDriver = new SDL2HardwareDeviceDriver();
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.Audio, "SDL2 audio is not supported, falling back to dummy audio out.");
|
||||
}
|
||||
}
|
||||
else if (ConfigurationState.Instance.System.AudioBackend.Value == AudioBackend.SoundIo)
|
||||
{
|
||||
if (SoundIoHardwareDeviceDriver.IsSupported)
|
||||
{
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using Gtk;
|
||||
using Ryujinx.Audio.Backends.OpenAL;
|
||||
using Ryujinx.Audio.Backends.SDL2;
|
||||
using Ryujinx.Audio.Backends.SoundIo;
|
||||
using Ryujinx.Common.Configuration;
|
||||
using Ryujinx.Common.Configuration.Hid;
|
||||
|
@ -302,6 +303,7 @@ namespace Ryujinx.Ui.Windows
|
|||
|
||||
TreeIter openAlIter = _audioBackendStore.AppendValues("OpenAL", AudioBackend.OpenAl);
|
||||
TreeIter soundIoIter = _audioBackendStore.AppendValues("SoundIO", AudioBackend.SoundIo);
|
||||
TreeIter sdl2Iter = _audioBackendStore.AppendValues("SDL2", AudioBackend.SDL2);
|
||||
TreeIter dummyIter = _audioBackendStore.AppendValues("Dummy", AudioBackend.Dummy);
|
||||
|
||||
_audioBackendSelect = ComboBox.NewWithModelAndEntry(_audioBackendStore);
|
||||
|
@ -316,6 +318,9 @@ namespace Ryujinx.Ui.Windows
|
|||
case AudioBackend.SoundIo:
|
||||
_audioBackendSelect.SetActiveIter(soundIoIter);
|
||||
break;
|
||||
case AudioBackend.SDL2:
|
||||
_audioBackendSelect.SetActiveIter(sdl2Iter);
|
||||
break;
|
||||
case AudioBackend.Dummy:
|
||||
_audioBackendSelect.SetActiveIter(dummyIter);
|
||||
break;
|
||||
|
@ -328,11 +333,13 @@ namespace Ryujinx.Ui.Windows
|
|||
|
||||
bool openAlIsSupported = false;
|
||||
bool soundIoIsSupported = false;
|
||||
bool sdl2IsSupported = false;
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
openAlIsSupported = OpenALHardwareDeviceDriver.IsSupported;
|
||||
soundIoIsSupported = SoundIoHardwareDeviceDriver.IsSupported;
|
||||
sdl2IsSupported = SDL2HardwareDeviceDriver.IsSupported;
|
||||
});
|
||||
|
||||
// This function runs whenever the dropdown is opened
|
||||
|
@ -342,6 +349,7 @@ namespace Ryujinx.Ui.Windows
|
|||
{
|
||||
AudioBackend.OpenAl => openAlIsSupported,
|
||||
AudioBackend.SoundIo => soundIoIsSupported,
|
||||
AudioBackend.SDL2 => sdl2IsSupported,
|
||||
AudioBackend.Dummy => true,
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue