Haydn: Part 1 (#2007)
* Haydn: Part 1 Based on my reverse of audio 11.0.0. As always, core implementation under LGPLv3 for the same reasons as for Amadeus. This place the bases of a more flexible audio system while making audout & audin accurate. This have the following improvements: - Complete reimplementation of audout and audin. - Audin currently only have a dummy backend. - Dramatically reduce CPU usage by up to 50% in common cases (SoundIO and OpenAL). - Audio Renderer now can output to 5.1 devices when supported. - Audio Renderer init its backend on demand instead of keeping two up all the time. - All backends implementation are now in their own project. - Ryujinx.Audio.Renderer was renamed Ryujinx.Audio and was refactored because of this. As a note, games having issues with OpenAL haven't improved and will not because of OpenAL design (stopping when buffers finish playing causing possible audio "pops" when buffers are very small). * Update for latest hexkyz's edits on Switchbrew * audren: Rollback channel configuration changes * Address gdkchan's comments * Fix typo in OpenAL backend driver * Address last comments * Fix a nit * Address gdkchan's comments
This commit is contained in:
parent
1c49089ff0
commit
f556c80d02
249 changed files with 5614 additions and 2712 deletions
|
@ -2,9 +2,11 @@ using LibHac;
|
|||
using LibHac.Bcat;
|
||||
using LibHac.Fs;
|
||||
using LibHac.FsSystem;
|
||||
using Ryujinx.Audio.Renderer;
|
||||
using Ryujinx.Audio;
|
||||
using Ryujinx.Audio.Input;
|
||||
using Ryujinx.Audio.Integration;
|
||||
using Ryujinx.Audio.Output;
|
||||
using Ryujinx.Audio.Renderer.Device;
|
||||
using Ryujinx.Audio.Renderer.Integration;
|
||||
using Ryujinx.Audio.Renderer.Server;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Configuration;
|
||||
|
@ -51,6 +53,9 @@ namespace Ryujinx.HLE.HOS
|
|||
internal Switch Device { get; private set; }
|
||||
|
||||
internal SurfaceFlinger SurfaceFlinger { get; private set; }
|
||||
internal AudioManager AudioManager { get; private set; }
|
||||
internal AudioOutputManager AudioOutputManager { get; private set; }
|
||||
internal AudioInputManager AudioInputManager { get; private set; }
|
||||
internal AudioRendererManager AudioRendererManager { get; private set; }
|
||||
internal VirtualDeviceSessionRegistry AudioDeviceSessionRegistry { get; private set; }
|
||||
|
||||
|
@ -206,29 +211,48 @@ namespace Ryujinx.HLE.HOS
|
|||
|
||||
private void InitializeAudioRenderer()
|
||||
{
|
||||
AudioManager = new AudioManager();
|
||||
AudioOutputManager = new AudioOutputManager();
|
||||
AudioInputManager = new AudioInputManager();
|
||||
AudioRendererManager = new AudioRendererManager();
|
||||
AudioDeviceSessionRegistry = new VirtualDeviceSessionRegistry();
|
||||
|
||||
IWritableEvent[] writableEvents = new IWritableEvent[RendererConstants.AudioRendererSessionCountMax];
|
||||
IWritableEvent[] audioOutputRegisterBufferEvents = new IWritableEvent[Constants.AudioOutSessionCountMax];
|
||||
|
||||
for (int i = 0; i < writableEvents.Length; i++)
|
||||
for (int i = 0; i < audioOutputRegisterBufferEvents.Length; i++)
|
||||
{
|
||||
KEvent registerBufferEvent = new KEvent(KernelContext);
|
||||
|
||||
audioOutputRegisterBufferEvents[i] = new AudioKernelEvent(registerBufferEvent);
|
||||
}
|
||||
|
||||
AudioOutputManager.Initialize(Device.AudioDeviceDriver, audioOutputRegisterBufferEvents);
|
||||
|
||||
IWritableEvent[] audioInputRegisterBufferEvents = new IWritableEvent[Constants.AudioInSessionCountMax];
|
||||
|
||||
for (int i = 0; i < audioInputRegisterBufferEvents.Length; i++)
|
||||
{
|
||||
KEvent registerBufferEvent = new KEvent(KernelContext);
|
||||
|
||||
audioInputRegisterBufferEvents[i] = new AudioKernelEvent(registerBufferEvent);
|
||||
}
|
||||
|
||||
AudioInputManager.Initialize(Device.AudioDeviceDriver, audioInputRegisterBufferEvents);
|
||||
|
||||
IWritableEvent[] systemEvents = new IWritableEvent[Constants.AudioRendererSessionCountMax];
|
||||
|
||||
for (int i = 0; i < systemEvents.Length; i++)
|
||||
{
|
||||
KEvent systemEvent = new KEvent(KernelContext);
|
||||
|
||||
writableEvents[i] = new AudioKernelEvent(systemEvent);
|
||||
systemEvents[i] = new AudioKernelEvent(systemEvent);
|
||||
}
|
||||
|
||||
HardwareDevice[] devices = new HardwareDevice[RendererConstants.AudioRendererSessionCountMax];
|
||||
AudioManager.Initialize(Device.AudioDeviceDriver.GetUpdateRequiredEvent(), AudioOutputManager.Update, AudioInputManager.Update);
|
||||
|
||||
// TODO: don't hardcode those values.
|
||||
// TODO: keep the device somewhere and dispose it when exiting.
|
||||
// TODO: This is kind of wrong, we should have an high level API for that and mix all buffers between them.
|
||||
for (int i = 0; i < devices.Length; i++)
|
||||
{
|
||||
devices[i] = new AalHardwareDevice(i, Device.AudioOut, 2, RendererConstants.TargetSampleRate);
|
||||
}
|
||||
AudioRendererManager.Initialize(systemEvents, Device.AudioDeviceDriver);
|
||||
|
||||
AudioRendererManager.Initialize(writableEvents, devices);
|
||||
AudioManager.Start();
|
||||
}
|
||||
|
||||
public void InitializeServices()
|
||||
|
@ -363,6 +387,10 @@ namespace Ryujinx.HLE.HOS
|
|||
// This is safe as KThread that are likely to call ioctls are going to be terminated by the post handler hook on the SVC facade.
|
||||
INvDrvServices.Destroy();
|
||||
|
||||
AudioManager.Dispose();
|
||||
AudioOutputManager.Dispose();
|
||||
AudioInputManager.Dispose();
|
||||
|
||||
AudioRendererManager.Dispose();
|
||||
|
||||
KernelContext.Dispose();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue