[audio] persistent device volume control

This commit is contained in:
xbzk
2026-09-13 18:33:44 -03:00
parent 5d150cac5c
commit 2f94f7708b
4 changed files with 22 additions and 12 deletions
+3 -5
View File
@@ -261,6 +261,7 @@ SinkStream* CubebSink::AcquireSinkStream(Core::System& system, u32 system_channe
system_channels = system_channels_;
SinkStreamPtr& stream = sink_streams.emplace_back(std::make_unique<CubebSinkStream>(
ctx, device_channels, system_channels, output_device, input_device, name, type, system));
stream->SetDeviceVolume(device_volume);
return stream.get();
}
@@ -280,14 +281,11 @@ void CubebSink::CloseStreams() {
}
f32 CubebSink::GetDeviceVolume() const {
if (sink_streams.empty()) {
return 1.0f;
}
return sink_streams[0]->GetDeviceVolume();
return device_volume;
}
void CubebSink::SetDeviceVolume(f32 volume) {
device_volume = volume;
for (auto& stream : sink_streams) {
stream->SetDeviceVolume(volume);
}
+11 -2
View File
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
@@ -38,6 +41,7 @@ public:
StreamType type) override {
if (null_sink == nullptr) {
null_sink = std::make_unique<NullSinkStreamImpl>(system, type);
null_sink->SetDeviceVolume(device_volume);
}
return null_sink.get();
}
@@ -45,9 +49,14 @@ public:
void CloseStream(SinkStream*) override {}
void CloseStreams() override {}
f32 GetDeviceVolume() const override {
return 1.0f;
return device_volume;
}
void SetDeviceVolume(f32 volume) override {
device_volume = volume;
if (null_sink != nullptr) {
null_sink->SetDeviceVolume(volume);
}
}
void SetDeviceVolume(f32 volume) override {}
void SetSystemVolume(f32 volume) override {}
private:
+3 -5
View File
@@ -246,6 +246,7 @@ SinkStream* SDLSink::AcquireSinkStream(Core::System& system, u32 system_channels
system_channels = system_channels_;
SinkStreamPtr& stream = sink_streams.emplace_back(std::make_unique<SDLSinkStream>(
device_channels, system_channels, output_device, input_device, type, system));
stream->SetDeviceVolume(device_volume);
return stream.get();
}
@@ -264,14 +265,11 @@ void SDLSink::CloseStreams() {
}
f32 SDLSink::GetDeviceVolume() const {
if (sink_streams.empty()) {
return 1.0f;
}
return sink_streams[0]->GetDeviceVolume();
return device_volume;
}
void SDLSink::SetDeviceVolume(f32 volume) {
device_volume = volume;
for (auto& stream : sink_streams) {
stream->SetDeviceVolume(volume);
}
+5
View File
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
@@ -96,6 +99,8 @@ public:
}
protected:
/// Master volume, persists stream lifetimes
f32 device_volume{1.0f};
/// Number of device channels supported by the hardware
u32 device_channels{2};
/// Number of channels the game is sending