summaryrefslogtreecommitdiffstats
path: root/src/audio_core/device
diff options
context:
space:
mode:
Diffstat (limited to 'src/audio_core/device')
-rw-r--r--src/audio_core/device/device_session.cpp14
-rw-r--r--src/audio_core/device/device_session.h12
2 files changed, 19 insertions, 7 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);
}
}
diff --git a/src/audio_core/device/device_session.h b/src/audio_core/device/device_session.h
index 7d52f362d..f3fae2617 100644
--- a/src/audio_core/device/device_session.h
+++ b/src/audio_core/device/device_session.h
@@ -20,6 +20,10 @@ struct EventType;
} // namespace Timing
} // namespace Core
+namespace Kernel {
+class KProcess;
+} // namespace Kernel
+
namespace AudioCore {
namespace Sink {
@@ -44,13 +48,13 @@ public:
* @param sample_format - Sample format for this device's output.
* @param channel_count - Number of channels for this device (2 or 6).
* @param session_id - This session's id.
- * @param handle - Handle for this device session (unused).
+ * @param handle - Process handle for this device session.
* @param applet_resource_user_id - Applet resource user id for this device session (unused).
* @param type - Type of this stream (Render, In, Out).
* @return Result code for this call.
*/
Result Initialize(std::string_view name, SampleFormat sample_format, u16 channel_count,
- size_t session_id, u32 handle, u64 applet_resource_user_id,
+ size_t session_id, Kernel::KProcess* handle, u64 applet_resource_user_id,
Sink::StreamType type);
/**
@@ -137,8 +141,8 @@ private:
u16 channel_count{};
/// Session id of this device session
size_t session_id{};
- /// Handle of this device session
- u32 handle{};
+ /// Process handle of device memory owner
+ Kernel::KProcess* handle{};
/// Applet resource user id of this device session
u64 applet_resource_user_id{};
/// Total number of samples played by this device session