diff options
| author | 2024-01-16 00:09:00 +0000 | |
|---|---|---|
| committer | 2024-01-16 00:09:00 +0000 | |
| commit | 90ab89a0b0174f8df559b79dc06a03479d959f93 (patch) | |
| tree | 3d11a790e44945e309f0e68f5332b33b42e72bbb /src/audio_core | |
| parent | Fix typos in arrays.xml (diff) | |
| parent | Merge pull request #12681 from t895/stick-toggles (diff) | |
| download | yuzu-90ab89a0b0174f8df559b79dc06a03479d959f93.tar.gz yuzu-90ab89a0b0174f8df559b79dc06a03479d959f93.tar.xz yuzu-90ab89a0b0174f8df559b79dc06a03479d959f93.zip | |
Merge remote-tracking branch 'origin/master' into typos3
Diffstat (limited to 'src/audio_core')
| -rw-r--r-- | src/audio_core/device/device_session.cpp | 14 | ||||
| -rw-r--r-- | src/audio_core/device/device_session.h | 12 | ||||
| -rw-r--r-- | src/audio_core/in/audio_in_system.cpp | 2 | ||||
| -rw-r--r-- | src/audio_core/in/audio_in_system.h | 13 | ||||
| -rw-r--r-- | src/audio_core/out/audio_out_system.cpp | 4 | ||||
| -rw-r--r-- | src/audio_core/out/audio_out_system.h | 13 |
6 files changed, 36 insertions, 22 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 @@ | |||
| 10 | #include "core/core_timing.h" | 10 | #include "core/core_timing.h" |
| 11 | #include "core/memory.h" | 11 | #include "core/memory.h" |
| 12 | 12 | ||
| 13 | #include "core/hle/kernel/k_process.h" | ||
| 14 | |||
| 13 | namespace AudioCore { | 15 | namespace AudioCore { |
| 14 | 16 | ||
| 15 | using namespace std::literals; | 17 | using namespace std::literals; |
| @@ -25,7 +27,7 @@ DeviceSession::~DeviceSession() { | |||
| 25 | } | 27 | } |
| 26 | 28 | ||
| 27 | Result DeviceSession::Initialize(std::string_view name_, SampleFormat sample_format_, | 29 | Result DeviceSession::Initialize(std::string_view name_, SampleFormat sample_format_, |
| 28 | u16 channel_count_, size_t session_id_, u32 handle_, | 30 | u16 channel_count_, size_t session_id_, Kernel::KProcess* handle_, |
| 29 | u64 applet_resource_user_id_, Sink::StreamType type_) { | 31 | u64 applet_resource_user_id_, Sink::StreamType type_) { |
| 30 | if (stream) { | 32 | if (stream) { |
| 31 | Finalize(); | 33 | Finalize(); |
| @@ -36,6 +38,7 @@ Result DeviceSession::Initialize(std::string_view name_, SampleFormat sample_for | |||
| 36 | channel_count = channel_count_; | 38 | channel_count = channel_count_; |
| 37 | session_id = session_id_; | 39 | session_id = session_id_; |
| 38 | handle = handle_; | 40 | handle = handle_; |
| 41 | handle->Open(); | ||
| 39 | applet_resource_user_id = applet_resource_user_id_; | 42 | applet_resource_user_id = applet_resource_user_id_; |
| 40 | 43 | ||
| 41 | if (type == Sink::StreamType::In) { | 44 | if (type == Sink::StreamType::In) { |
| @@ -54,6 +57,11 @@ void DeviceSession::Finalize() { | |||
| 54 | sink->CloseStream(stream); | 57 | sink->CloseStream(stream); |
| 55 | stream = nullptr; | 58 | stream = nullptr; |
| 56 | } | 59 | } |
| 60 | |||
| 61 | if (handle) { | ||
| 62 | handle->Close(); | ||
| 63 | handle = nullptr; | ||
| 64 | } | ||
| 57 | } | 65 | } |
| 58 | 66 | ||
| 59 | void DeviceSession::Start() { | 67 | void DeviceSession::Start() { |
| @@ -91,7 +99,7 @@ void DeviceSession::AppendBuffers(std::span<const AudioBuffer> buffers) { | |||
| 91 | stream->AppendBuffer(new_buffer, tmp_samples); | 99 | stream->AppendBuffer(new_buffer, tmp_samples); |
| 92 | } else { | 100 | } else { |
| 93 | Core::Memory::CpuGuestMemory<s16, Core::Memory::GuestMemoryFlags::UnsafeRead> samples( | 101 | Core::Memory::CpuGuestMemory<s16, Core::Memory::GuestMemoryFlags::UnsafeRead> samples( |
| 94 | system.ApplicationMemory(), buffer.samples, buffer.size / sizeof(s16)); | 102 | handle->GetMemory(), buffer.samples, buffer.size / sizeof(s16)); |
| 95 | stream->AppendBuffer(new_buffer, samples); | 103 | stream->AppendBuffer(new_buffer, samples); |
| 96 | } | 104 | } |
| 97 | } | 105 | } |
| @@ -100,7 +108,7 @@ void DeviceSession::AppendBuffers(std::span<const AudioBuffer> buffers) { | |||
| 100 | void DeviceSession::ReleaseBuffer(const AudioBuffer& buffer) const { | 108 | void DeviceSession::ReleaseBuffer(const AudioBuffer& buffer) const { |
| 101 | if (type == Sink::StreamType::In) { | 109 | if (type == Sink::StreamType::In) { |
| 102 | auto samples{stream->ReleaseBuffer(buffer.size / sizeof(s16))}; | 110 | auto samples{stream->ReleaseBuffer(buffer.size / sizeof(s16))}; |
| 103 | system.ApplicationMemory().WriteBlockUnsafe(buffer.samples, samples.data(), buffer.size); | 111 | handle->GetMemory().WriteBlockUnsafe(buffer.samples, samples.data(), buffer.size); |
| 104 | } | 112 | } |
| 105 | } | 113 | } |
| 106 | 114 | ||
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; | |||
| 20 | } // namespace Timing | 20 | } // namespace Timing |
| 21 | } // namespace Core | 21 | } // namespace Core |
| 22 | 22 | ||
| 23 | namespace Kernel { | ||
| 24 | class KProcess; | ||
| 25 | } // namespace Kernel | ||
| 26 | |||
| 23 | namespace AudioCore { | 27 | namespace AudioCore { |
| 24 | 28 | ||
| 25 | namespace Sink { | 29 | namespace Sink { |
| @@ -44,13 +48,13 @@ public: | |||
| 44 | * @param sample_format - Sample format for this device's output. | 48 | * @param sample_format - Sample format for this device's output. |
| 45 | * @param channel_count - Number of channels for this device (2 or 6). | 49 | * @param channel_count - Number of channels for this device (2 or 6). |
| 46 | * @param session_id - This session's id. | 50 | * @param session_id - This session's id. |
| 47 | * @param handle - Handle for this device session (unused). | 51 | * @param handle - Process handle for this device session. |
| 48 | * @param applet_resource_user_id - Applet resource user id for this device session (unused). | 52 | * @param applet_resource_user_id - Applet resource user id for this device session (unused). |
| 49 | * @param type - Type of this stream (Render, In, Out). | 53 | * @param type - Type of this stream (Render, In, Out). |
| 50 | * @return Result code for this call. | 54 | * @return Result code for this call. |
| 51 | */ | 55 | */ |
| 52 | Result Initialize(std::string_view name, SampleFormat sample_format, u16 channel_count, | 56 | Result Initialize(std::string_view name, SampleFormat sample_format, u16 channel_count, |
| 53 | size_t session_id, u32 handle, u64 applet_resource_user_id, | 57 | size_t session_id, Kernel::KProcess* handle, u64 applet_resource_user_id, |
| 54 | Sink::StreamType type); | 58 | Sink::StreamType type); |
| 55 | 59 | ||
| 56 | /** | 60 | /** |
| @@ -137,8 +141,8 @@ private: | |||
| 137 | u16 channel_count{}; | 141 | u16 channel_count{}; |
| 138 | /// Session id of this device session | 142 | /// Session id of this device session |
| 139 | size_t session_id{}; | 143 | size_t session_id{}; |
| 140 | /// Handle of this device session | 144 | /// Process handle of device memory owner |
| 141 | u32 handle{}; | 145 | Kernel::KProcess* handle{}; |
| 142 | /// Applet resource user id of this device session | 146 | /// Applet resource user id of this device session |
| 143 | u64 applet_resource_user_id{}; | 147 | u64 applet_resource_user_id{}; |
| 144 | /// Total number of samples played by this device session | 148 | /// Total number of samples played by this device session |
diff --git a/src/audio_core/in/audio_in_system.cpp b/src/audio_core/in/audio_in_system.cpp index 579129121..b2dd3ef9f 100644 --- a/src/audio_core/in/audio_in_system.cpp +++ b/src/audio_core/in/audio_in_system.cpp | |||
| @@ -57,7 +57,7 @@ Result System::IsConfigValid(const std::string_view device_name, | |||
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | Result System::Initialize(std::string device_name, const AudioInParameter& in_params, | 59 | Result System::Initialize(std::string device_name, const AudioInParameter& in_params, |
| 60 | const u32 handle_, const u64 applet_resource_user_id_) { | 60 | Kernel::KProcess* handle_, const u64 applet_resource_user_id_) { |
| 61 | auto result{IsConfigValid(device_name, in_params)}; | 61 | auto result{IsConfigValid(device_name, in_params)}; |
| 62 | if (result.IsError()) { | 62 | if (result.IsError()) { |
| 63 | return result; | 63 | return result; |
diff --git a/src/audio_core/in/audio_in_system.h b/src/audio_core/in/audio_in_system.h index 1c5154638..ee048190c 100644 --- a/src/audio_core/in/audio_in_system.h +++ b/src/audio_core/in/audio_in_system.h | |||
| @@ -19,7 +19,8 @@ class System; | |||
| 19 | 19 | ||
| 20 | namespace Kernel { | 20 | namespace Kernel { |
| 21 | class KEvent; | 21 | class KEvent; |
| 22 | } | 22 | class KProcess; |
| 23 | } // namespace Kernel | ||
| 23 | 24 | ||
| 24 | namespace AudioCore::AudioIn { | 25 | namespace AudioCore::AudioIn { |
| 25 | 26 | ||
| @@ -93,12 +94,12 @@ public: | |||
| 93 | * | 94 | * |
| 94 | * @param device_name - The name of the requested input device. | 95 | * @param device_name - The name of the requested input device. |
| 95 | * @param in_params - Input parameters, see AudioInParameter. | 96 | * @param in_params - Input parameters, see AudioInParameter. |
| 96 | * @param handle - Unused. | 97 | * @param handle - Process handle. |
| 97 | * @param applet_resource_user_id - Unused. | 98 | * @param applet_resource_user_id - Unused. |
| 98 | * @return Result code. | 99 | * @return Result code. |
| 99 | */ | 100 | */ |
| 100 | Result Initialize(std::string device_name, const AudioInParameter& in_params, u32 handle, | 101 | Result Initialize(std::string device_name, const AudioInParameter& in_params, |
| 101 | u64 applet_resource_user_id); | 102 | Kernel::KProcess* handle, u64 applet_resource_user_id); |
| 102 | 103 | ||
| 103 | /** | 104 | /** |
| 104 | * Start this system. | 105 | * Start this system. |
| @@ -244,8 +245,8 @@ public: | |||
| 244 | private: | 245 | private: |
| 245 | /// Core system | 246 | /// Core system |
| 246 | Core::System& system; | 247 | Core::System& system; |
| 247 | /// (Unused) | 248 | /// Process handle |
| 248 | u32 handle{}; | 249 | Kernel::KProcess* handle{}; |
| 249 | /// (Unused) | 250 | /// (Unused) |
| 250 | u64 applet_resource_user_id{}; | 251 | u64 applet_resource_user_id{}; |
| 251 | /// Buffer event, signalled when a buffer is ready | 252 | /// Buffer event, signalled when a buffer is ready |
diff --git a/src/audio_core/out/audio_out_system.cpp b/src/audio_core/out/audio_out_system.cpp index 0adf64bd3..7b3ff4e88 100644 --- a/src/audio_core/out/audio_out_system.cpp +++ b/src/audio_core/out/audio_out_system.cpp | |||
| @@ -48,8 +48,8 @@ Result System::IsConfigValid(std::string_view device_name, | |||
| 48 | return Service::Audio::ResultInvalidChannelCount; | 48 | return Service::Audio::ResultInvalidChannelCount; |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | Result System::Initialize(std::string device_name, const AudioOutParameter& in_params, u32 handle_, | 51 | Result System::Initialize(std::string device_name, const AudioOutParameter& in_params, |
| 52 | u64 applet_resource_user_id_) { | 52 | Kernel::KProcess* handle_, u64 applet_resource_user_id_) { |
| 53 | auto result = IsConfigValid(device_name, in_params); | 53 | auto result = IsConfigValid(device_name, in_params); |
| 54 | if (result.IsError()) { | 54 | if (result.IsError()) { |
| 55 | return result; | 55 | return result; |
diff --git a/src/audio_core/out/audio_out_system.h b/src/audio_core/out/audio_out_system.h index b95cb91be..82aada185 100644 --- a/src/audio_core/out/audio_out_system.h +++ b/src/audio_core/out/audio_out_system.h | |||
| @@ -19,7 +19,8 @@ class System; | |||
| 19 | 19 | ||
| 20 | namespace Kernel { | 20 | namespace Kernel { |
| 21 | class KEvent; | 21 | class KEvent; |
| 22 | } | 22 | class KProcess; |
| 23 | } // namespace Kernel | ||
| 23 | 24 | ||
| 24 | namespace AudioCore::AudioOut { | 25 | namespace AudioCore::AudioOut { |
| 25 | 26 | ||
| @@ -84,12 +85,12 @@ public: | |||
| 84 | * | 85 | * |
| 85 | * @param device_name - The name of the requested output device. | 86 | * @param device_name - The name of the requested output device. |
| 86 | * @param in_params - Input parameters, see AudioOutParameter. | 87 | * @param in_params - Input parameters, see AudioOutParameter. |
| 87 | * @param handle - Unused. | 88 | * @param handle - Process handle. |
| 88 | * @param applet_resource_user_id - Unused. | 89 | * @param applet_resource_user_id - Unused. |
| 89 | * @return Result code. | 90 | * @return Result code. |
| 90 | */ | 91 | */ |
| 91 | Result Initialize(std::string device_name, const AudioOutParameter& in_params, u32 handle, | 92 | Result Initialize(std::string device_name, const AudioOutParameter& in_params, |
| 92 | u64 applet_resource_user_id); | 93 | Kernel::KProcess* handle, u64 applet_resource_user_id); |
| 93 | 94 | ||
| 94 | /** | 95 | /** |
| 95 | * Start this system. | 96 | * Start this system. |
| @@ -228,8 +229,8 @@ public: | |||
| 228 | private: | 229 | private: |
| 229 | /// Core system | 230 | /// Core system |
| 230 | Core::System& system; | 231 | Core::System& system; |
| 231 | /// (Unused) | 232 | /// Process handle |
| 232 | u32 handle{}; | 233 | Kernel::KProcess* handle{}; |
| 233 | /// (Unused) | 234 | /// (Unused) |
| 234 | u64 applet_resource_user_id{}; | 235 | u64 applet_resource_user_id{}; |
| 235 | /// Buffer event, signalled when a buffer is ready | 236 | /// Buffer event, signalled when a buffer is ready |