diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/kernel/hle_ipc.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/kernel/hle_ipc.h | 23 | ||||
| -rw-r--r-- | src/core/hle/service/audio/audout_u.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/service/audio/audren_u.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/service/set/set.cpp | 2 |
5 files changed, 25 insertions, 10 deletions
diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp index 911e6fbc1..8f40bdd5a 100644 --- a/src/core/hle/kernel/hle_ipc.cpp +++ b/src/core/hle/kernel/hle_ipc.cpp | |||
| @@ -301,10 +301,6 @@ size_t HLERequestContext::WriteBuffer(const void* buffer, size_t size, int buffe | |||
| 301 | return size; | 301 | return size; |
| 302 | } | 302 | } |
| 303 | 303 | ||
| 304 | size_t HLERequestContext::WriteBuffer(const std::vector<u8>& buffer, int buffer_index) const { | ||
| 305 | return WriteBuffer(buffer.data(), buffer.size(), buffer_index); | ||
| 306 | } | ||
| 307 | |||
| 308 | size_t HLERequestContext::GetReadBufferSize(int buffer_index) const { | 304 | size_t HLERequestContext::GetReadBufferSize(int buffer_index) const { |
| 309 | const bool is_buffer_a{BufferDescriptorA().size() && BufferDescriptorA()[buffer_index].Size()}; | 305 | const bool is_buffer_a{BufferDescriptorA().size() && BufferDescriptorA()[buffer_index].Size()}; |
| 310 | return is_buffer_a ? BufferDescriptorA()[buffer_index].Size() | 306 | return is_buffer_a ? BufferDescriptorA()[buffer_index].Size() |
diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h index 88f93ad22..01b805df8 100644 --- a/src/core/hle/kernel/hle_ipc.h +++ b/src/core/hle/kernel/hle_ipc.h | |||
| @@ -5,8 +5,10 @@ | |||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <array> | 7 | #include <array> |
| 8 | #include <iterator> | ||
| 8 | #include <memory> | 9 | #include <memory> |
| 9 | #include <string> | 10 | #include <string> |
| 11 | #include <type_traits> | ||
| 10 | #include <vector> | 12 | #include <vector> |
| 11 | #include <boost/container/small_vector.hpp> | 13 | #include <boost/container/small_vector.hpp> |
| 12 | #include "common/common_types.h" | 14 | #include "common/common_types.h" |
| @@ -171,8 +173,25 @@ public: | |||
| 171 | /// Helper function to write a buffer using the appropriate buffer descriptor | 173 | /// Helper function to write a buffer using the appropriate buffer descriptor |
| 172 | size_t WriteBuffer(const void* buffer, size_t size, int buffer_index = 0) const; | 174 | size_t WriteBuffer(const void* buffer, size_t size, int buffer_index = 0) const; |
| 173 | 175 | ||
| 174 | /// Helper function to write a buffer using the appropriate buffer descriptor | 176 | /* Helper function to write a buffer using the appropriate buffer descriptor |
| 175 | size_t WriteBuffer(const std::vector<u8>& buffer, int buffer_index = 0) const; | 177 | * |
| 178 | * @tparam ContiguousContainer an arbitrary container that satisfies the | ||
| 179 | * ContiguousContainer concept in the C++ standard library. | ||
| 180 | * | ||
| 181 | * @param container The container to write the data of into a buffer. | ||
| 182 | * @param buffer_index The buffer in particular to write to. | ||
| 183 | */ | ||
| 184 | template <typename ContiguousContainer, | ||
| 185 | typename = std::enable_if_t<!std::is_pointer_v<ContiguousContainer>>> | ||
| 186 | size_t WriteBuffer(const ContiguousContainer& container, int buffer_index = 0) const { | ||
| 187 | using ContiguousType = typename ContiguousContainer::value_type; | ||
| 188 | |||
| 189 | static_assert(std::is_trivially_copyable_v<ContiguousType>, | ||
| 190 | "Container to WriteBuffer must contain trivially copyable objects"); | ||
| 191 | |||
| 192 | return WriteBuffer(std::data(container), std::size(container) * sizeof(ContiguousType), | ||
| 193 | buffer_index); | ||
| 194 | } | ||
| 176 | 195 | ||
| 177 | /// Helper function to get the size of the input buffer | 196 | /// Helper function to get the size of the input buffer |
| 178 | size_t GetReadBufferSize(int buffer_index = 0) const; | 197 | size_t GetReadBufferSize(int buffer_index = 0) const; |
diff --git a/src/core/hle/service/audio/audout_u.cpp b/src/core/hle/service/audio/audout_u.cpp index 8bf273b22..4217ea4fb 100644 --- a/src/core/hle/service/audio/audout_u.cpp +++ b/src/core/hle/service/audio/audout_u.cpp | |||
| @@ -168,7 +168,7 @@ void AudOutU::ListAudioOutsImpl(Kernel::HLERequestContext& ctx) { | |||
| 168 | IPC::RequestParser rp{ctx}; | 168 | IPC::RequestParser rp{ctx}; |
| 169 | 169 | ||
| 170 | const std::string audio_interface = "AudioInterface"; | 170 | const std::string audio_interface = "AudioInterface"; |
| 171 | ctx.WriteBuffer(audio_interface.c_str(), audio_interface.size()); | 171 | ctx.WriteBuffer(audio_interface); |
| 172 | 172 | ||
| 173 | IPC::ResponseBuilder rb = rp.MakeBuilder(3, 0, 0); | 173 | IPC::ResponseBuilder rb = rp.MakeBuilder(3, 0, 0); |
| 174 | 174 | ||
diff --git a/src/core/hle/service/audio/audren_u.cpp b/src/core/hle/service/audio/audren_u.cpp index 2a8b3e216..6903f52d6 100644 --- a/src/core/hle/service/audio/audren_u.cpp +++ b/src/core/hle/service/audio/audren_u.cpp | |||
| @@ -299,7 +299,7 @@ private: | |||
| 299 | IPC::RequestParser rp{ctx}; | 299 | IPC::RequestParser rp{ctx}; |
| 300 | 300 | ||
| 301 | const std::string audio_interface = "AudioInterface"; | 301 | const std::string audio_interface = "AudioInterface"; |
| 302 | ctx.WriteBuffer(audio_interface.c_str(), audio_interface.size()); | 302 | ctx.WriteBuffer(audio_interface); |
| 303 | 303 | ||
| 304 | IPC::ResponseBuilder rb = rp.MakeBuilder(3, 0, 0); | 304 | IPC::ResponseBuilder rb = rp.MakeBuilder(3, 0, 0); |
| 305 | rb.Push(RESULT_SUCCESS); | 305 | rb.Push(RESULT_SUCCESS); |
| @@ -324,7 +324,7 @@ private: | |||
| 324 | IPC::RequestParser rp{ctx}; | 324 | IPC::RequestParser rp{ctx}; |
| 325 | 325 | ||
| 326 | const std::string audio_interface = "AudioDevice"; | 326 | const std::string audio_interface = "AudioDevice"; |
| 327 | ctx.WriteBuffer(audio_interface.c_str(), audio_interface.size()); | 327 | ctx.WriteBuffer(audio_interface); |
| 328 | 328 | ||
| 329 | IPC::ResponseBuilder rb = rp.MakeBuilder(3, 0, 0); | 329 | IPC::ResponseBuilder rb = rp.MakeBuilder(3, 0, 0); |
| 330 | rb.Push(RESULT_SUCCESS); | 330 | rb.Push(RESULT_SUCCESS); |
diff --git a/src/core/hle/service/set/set.cpp b/src/core/hle/service/set/set.cpp index bd295cdf6..886133b74 100644 --- a/src/core/hle/service/set/set.cpp +++ b/src/core/hle/service/set/set.cpp | |||
| @@ -31,7 +31,7 @@ void SET::GetAvailableLanguageCodes(Kernel::HLERequestContext& ctx) { | |||
| 31 | LanguageCode::ZH_HANS, | 31 | LanguageCode::ZH_HANS, |
| 32 | LanguageCode::ZH_HANT, | 32 | LanguageCode::ZH_HANT, |
| 33 | }}; | 33 | }}; |
| 34 | ctx.WriteBuffer(available_language_codes.data(), available_language_codes.size()); | 34 | ctx.WriteBuffer(available_language_codes); |
| 35 | 35 | ||
| 36 | IPC::ResponseBuilder rb{ctx, 4}; | 36 | IPC::ResponseBuilder rb{ctx, 4}; |
| 37 | rb.Push(RESULT_SUCCESS); | 37 | rb.Push(RESULT_SUCCESS); |