aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Audio.Backends.SoundIo/SoundIoHardwareDeviceSession.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2024-02-22 16:58:33 -0300
committerGitHub <noreply@github.com>2024-02-22 16:58:33 -0300
commitd4d0a48bfe89d6e8e12ce16829bb2c440b56007c (patch)
tree2376566ed2c06181b3dbc547b1f99f5b533d918b /src/Ryujinx.Audio.Backends.SoundIo/SoundIoHardwareDeviceSession.cs
parent57d8afd0c99bb43d1ba1e3cc630d257c5da92741 (diff)
Migrate Audio service to new IPC (#6285)1.1.1211
* 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
Diffstat (limited to 'src/Ryujinx.Audio.Backends.SoundIo/SoundIoHardwareDeviceSession.cs')
-rw-r--r--src/Ryujinx.Audio.Backends.SoundIo/SoundIoHardwareDeviceSession.cs17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/Ryujinx.Audio.Backends.SoundIo/SoundIoHardwareDeviceSession.cs b/src/Ryujinx.Audio.Backends.SoundIo/SoundIoHardwareDeviceSession.cs
index 123cfd27..f60982e3 100644
--- a/src/Ryujinx.Audio.Backends.SoundIo/SoundIoHardwareDeviceSession.cs
+++ b/src/Ryujinx.Audio.Backends.SoundIo/SoundIoHardwareDeviceSession.cs
@@ -18,16 +18,18 @@ namespace Ryujinx.Audio.Backends.SoundIo
private readonly DynamicRingBuffer _ringBuffer;
private ulong _playedSampleCount;
private readonly ManualResetEvent _updateRequiredEvent;
+ private float _volume;
private int _disposeState;
- public SoundIoHardwareDeviceSession(SoundIoHardwareDeviceDriver driver, IVirtualMemoryManager memoryManager, SampleFormat requestedSampleFormat, uint requestedSampleRate, uint requestedChannelCount, float requestedVolume) : base(memoryManager, requestedSampleFormat, requestedSampleRate, requestedChannelCount)
+ public SoundIoHardwareDeviceSession(SoundIoHardwareDeviceDriver driver, IVirtualMemoryManager memoryManager, SampleFormat requestedSampleFormat, uint requestedSampleRate, uint requestedChannelCount) : base(memoryManager, requestedSampleFormat, requestedSampleRate, requestedChannelCount)
{
_driver = driver;
_updateRequiredEvent = _driver.GetUpdateRequiredEvent();
_queuedBuffers = new ConcurrentQueue<SoundIoAudioBuffer>();
_ringBuffer = new DynamicRingBuffer();
+ _volume = 1f;
- SetupOutputStream(requestedVolume);
+ SetupOutputStream(driver.Volume);
}
private void SetupOutputStream(float requestedVolume)
@@ -47,7 +49,7 @@ namespace Ryujinx.Audio.Backends.SoundIo
public override float GetVolume()
{
- return _outputStream.Volume;
+ return _volume;
}
public override void PrepareToClose() { }
@@ -63,7 +65,14 @@ namespace Ryujinx.Audio.Backends.SoundIo
public override void SetVolume(float volume)
{
- _outputStream.SetVolume(volume);
+ _volume = volume;
+
+ _outputStream.SetVolume(_driver.Volume * volume);
+ }
+
+ public void UpdateMasterVolume(float newVolume)
+ {
+ _outputStream.SetVolume(newVolume * _volume);
}
public override void Start()