diff options
author | Charles Lombardo <clombardo169@gmail.com> | 2024-01-15 19:52:01 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-15 19:52:01 +0100 |
commit | 34db13486afb055e39b5d92ddc288a7078816daf (patch) | |
tree | 140f4be1c0f6be36d4317253c60f51efabc1b31f /src/audio_core/device/device_session.cpp | |
parent | Merge pull request #12652 from liamwhite/huge-pile-of-spirv-spaghetti (diff) | |
parent | audio: fetch process object from handle table (diff) | |
download | yuzu-34db13486afb055e39b5d92ddc288a7078816daf.tar yuzu-34db13486afb055e39b5d92ddc288a7078816daf.tar.gz yuzu-34db13486afb055e39b5d92ddc288a7078816daf.tar.bz2 yuzu-34db13486afb055e39b5d92ddc288a7078816daf.tar.lz yuzu-34db13486afb055e39b5d92ddc288a7078816daf.tar.xz yuzu-34db13486afb055e39b5d92ddc288a7078816daf.tar.zst yuzu-34db13486afb055e39b5d92ddc288a7078816daf.zip |
Diffstat (limited to 'src/audio_core/device/device_session.cpp')
-rw-r--r-- | src/audio_core/device/device_session.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/audio_core/device/device_session.cpp b/src/audio_core/device/device_session.cpp index ee42ae529..3c214ec00 100644 --- a/src/audio_core/device/device_session.cpp +++ b/src/audio_core/device/device_session.cpp @@ -10,6 +10,8 @@ #include "core/core_timing.h" #include "core/memory.h" +#include "core/hle/kernel/k_process.h" + namespace AudioCore { using namespace std::literals; @@ -25,7 +27,7 @@ DeviceSession::~DeviceSession() { } Result DeviceSession::Initialize(std::string_view name_, SampleFormat sample_format_, - u16 channel_count_, size_t session_id_, u32 handle_, + u16 channel_count_, size_t session_id_, Kernel::KProcess* handle_, u64 applet_resource_user_id_, Sink::StreamType type_) { if (stream) { Finalize(); @@ -36,6 +38,7 @@ Result DeviceSession::Initialize(std::string_view name_, SampleFormat sample_for channel_count = channel_count_; session_id = session_id_; handle = handle_; + handle->Open(); applet_resource_user_id = applet_resource_user_id_; if (type == Sink::StreamType::In) { @@ -54,6 +57,11 @@ void DeviceSession::Finalize() { sink->CloseStream(stream); stream = nullptr; } + + if (handle) { + handle->Close(); + handle = nullptr; + } } void DeviceSession::Start() { @@ -91,7 +99,7 @@ void DeviceSession::AppendBuffers(std::span<const AudioBuffer> buffers) { stream->AppendBuffer(new_buffer, tmp_samples); } else { Core::Memory::CpuGuestMemory<s16, Core::Memory::GuestMemoryFlags::UnsafeRead> samples( - system.ApplicationMemory(), buffer.samples, buffer.size / sizeof(s16)); + handle->GetMemory(), buffer.samples, buffer.size / sizeof(s16)); stream->AppendBuffer(new_buffer, samples); } } @@ -100,7 +108,7 @@ void DeviceSession::AppendBuffers(std::span<const AudioBuffer> buffers) { void DeviceSession::ReleaseBuffer(const AudioBuffer& buffer) const { if (type == Sink::StreamType::In) { auto samples{stream->ReleaseBuffer(buffer.size / sizeof(s16))}; - system.ApplicationMemory().WriteBlockUnsafe(buffer.samples, samples.data(), buffer.size); + handle->GetMemory().WriteBlockUnsafe(buffer.samples, samples.data(), buffer.size); } } |