Compare commits

..

1 Commits

Author SHA1 Message Date
xbzk 2f94f7708b [audio] persistent device volume control 2026-09-13 19:33:57 -03:00
7 changed files with 28 additions and 20 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
+3 -4
View File
@@ -42,7 +42,7 @@ u64 DynarmicCallbacks32::MemoryRead64(u32 vaddr) {
std::optional<u32> DynarmicCallbacks32::MemoryReadCode(u32 vaddr) {
if (!m_memory.IsValidVirtualAddressRange(vaddr, sizeof(u32)))
return std::nullopt;
auto const aligned_vaddr = vaddr & u32(~Core::Memory::YUZU_PAGEMASK);
auto const aligned_vaddr = vaddr & ~Core::Memory::YUZU_PAGEMASK;
if (last_code_addr != aligned_vaddr) {
m_memory.ReadBlock(aligned_vaddr, &cached_code_page, sizeof(cached_code_page));
last_code_addr = aligned_vaddr;
@@ -427,13 +427,12 @@ void ArmDynarmic32::SignalInterrupt(Kernel::KThread* thread) {
}
void ArmDynarmic32::ClearInstructionCache() {
m_cb->last_code_addr = u32(-1);
m_cb->last_code_addr = u64(-1);
m_jit->ClearCache();
}
void ArmDynarmic32::InvalidateCacheRange(u64 addr, std::size_t size) {
m_cb->last_code_addr = u32(-1);
m_jit->InvalidateCacheRange(u32(addr), size);
m_jit->InvalidateCacheRange(static_cast<u32>(addr), size);
}
} // namespace Core
+2 -2
View File
@@ -36,7 +36,7 @@ public:
u64 MemoryRead64(u32 vaddr) override;
std::optional<u32> MemoryReadCode(u32 vaddr) override;
void InstructionSynchronizationBarrierRaised() override {
last_code_addr = u32(-1); //reset back, force refetch
last_code_addr = u64(-1); //reset back, force refetch
}
void MemoryWrite8(u32 vaddr, u8 value) override;
void MemoryWrite16(u32 vaddr, u16 value) override;
@@ -54,7 +54,7 @@ public:
void ReturnException(u32 pc, Dynarmic::HaltReason hr);
//
Dynarmic::CodePage cached_code_page;
u32 last_code_addr = u32(-1);
u64 last_code_addr = u64(-1);
ArmDynarmic32& m_parent;
Core::Memory::Memory& m_memory;
Kernel::KProcess* m_process{};
+1 -2
View File
@@ -105,7 +105,7 @@ void DynarmicCallbacks64::InstructionCacheOperationRaised(Dynarmic::A64::Instruc
last_code_addr = u64(-1); //invalidate cached page
switch (op) {
case Dynarmic::A64::InstructionCacheOperation::InvalidateByVAToPoU: {
constexpr u64 ICACHE_LINE_SIZE = 64;
static constexpr u64 ICACHE_LINE_SIZE = 64;
const u64 cache_line_start = value & ~(ICACHE_LINE_SIZE - 1);
m_parent.InvalidateCacheRange(cache_line_start, ICACHE_LINE_SIZE);
break;
@@ -458,7 +458,6 @@ void ArmDynarmic64::ClearInstructionCache() {
}
void ArmDynarmic64::InvalidateCacheRange(u64 addr, std::size_t size) {
m_cb->last_code_addr = u64(-1);
m_jit->InvalidateCacheRange(addr, size);
}