mirror of
https://github.com/ryujinx-mirror/ryujinx.git
synced 2025-10-03 09:05:50 -05:00
Migrate Audio service to new IPC (#6285)
* Migrate audren to new IPC * Migrate audout * Migrate audin * Migrate hwopus * Bye bye old audio service * Switch volume control to IHardwareDeviceDriver * Somewhat unrelated changes * Remove Concentus reference from HLE * Implement OpenAudioRendererForManualExecution * Remove SetVolume/GetVolume methods that are not necessary * Remove SetVolume/GetVolume methods that are not necessary (2) * Fix incorrect volume update * PR feedback * PR feedback * Stub audrec * Init outParameter * Make FinalOutputRecorderParameter/Internal readonly * Make FinalOutputRecorder IDisposable * Fix HardwareOpusDecoderManager parameter buffers * Opus work buffer size and error handling improvements * Add AudioInProtocolName enum * Fix potential divisions by zero
This commit is contained in:
78
src/Ryujinx.Horizon/Audio/AudioManagers.cs
Normal file
78
src/Ryujinx.Horizon/Audio/AudioManagers.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
using Ryujinx.Audio;
|
||||
using Ryujinx.Audio.Input;
|
||||
using Ryujinx.Audio.Integration;
|
||||
using Ryujinx.Audio.Output;
|
||||
using Ryujinx.Audio.Renderer.Device;
|
||||
using Ryujinx.Audio.Renderer.Server;
|
||||
using Ryujinx.Cpu;
|
||||
using Ryujinx.Horizon.Sdk.Audio;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.Horizon.Audio
|
||||
{
|
||||
class AudioManagers : IDisposable
|
||||
{
|
||||
public AudioManager AudioManager { get; }
|
||||
public AudioOutputManager AudioOutputManager { get; }
|
||||
public AudioInputManager AudioInputManager { get; }
|
||||
public AudioRendererManager AudioRendererManager { get; }
|
||||
public VirtualDeviceSessionRegistry AudioDeviceSessionRegistry { get; }
|
||||
|
||||
public AudioManagers(IHardwareDeviceDriver audioDeviceDriver, ITickSource tickSource)
|
||||
{
|
||||
AudioManager = new AudioManager();
|
||||
AudioOutputManager = new AudioOutputManager();
|
||||
AudioInputManager = new AudioInputManager();
|
||||
AudioRendererManager = new AudioRendererManager(tickSource);
|
||||
AudioDeviceSessionRegistry = new VirtualDeviceSessionRegistry(audioDeviceDriver);
|
||||
|
||||
IWritableEvent[] audioOutputRegisterBufferEvents = new IWritableEvent[Constants.AudioOutSessionCountMax];
|
||||
|
||||
for (int i = 0; i < audioOutputRegisterBufferEvents.Length; i++)
|
||||
{
|
||||
audioOutputRegisterBufferEvents[i] = new AudioEvent();
|
||||
}
|
||||
|
||||
AudioOutputManager.Initialize(audioDeviceDriver, audioOutputRegisterBufferEvents);
|
||||
|
||||
IWritableEvent[] audioInputRegisterBufferEvents = new IWritableEvent[Constants.AudioInSessionCountMax];
|
||||
|
||||
for (int i = 0; i < audioInputRegisterBufferEvents.Length; i++)
|
||||
{
|
||||
audioInputRegisterBufferEvents[i] = new AudioEvent();
|
||||
}
|
||||
|
||||
AudioInputManager.Initialize(audioDeviceDriver, audioInputRegisterBufferEvents);
|
||||
|
||||
IWritableEvent[] systemEvents = new IWritableEvent[Constants.AudioRendererSessionCountMax];
|
||||
|
||||
for (int i = 0; i < systemEvents.Length; i++)
|
||||
{
|
||||
systemEvents[i] = new AudioEvent();
|
||||
}
|
||||
|
||||
AudioManager.Initialize(audioDeviceDriver.GetUpdateRequiredEvent(), AudioOutputManager.Update, AudioInputManager.Update);
|
||||
|
||||
AudioRendererManager.Initialize(systemEvents, audioDeviceDriver);
|
||||
|
||||
AudioManager.Start();
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
AudioManager.Dispose();
|
||||
AudioOutputManager.Dispose();
|
||||
AudioInputManager.Dispose();
|
||||
AudioRendererManager.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(disposing: true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user