diff options
| author | 2022-12-25 13:42:32 -0500 | |
|---|---|---|
| committer | 2022-12-25 17:04:02 -0500 | |
| commit | 7ffd62424804eceb73f01b1c4e8dc216134c8295 (patch) | |
| tree | 2bfe2a9b5d0a3f0857c73475cbdf24f6fe66c740 /src/core/hle/service/audio | |
| parent | fsp_srv: Use ReadBufferSpan (diff) | |
| download | yuzu-7ffd62424804eceb73f01b1c4e8dc216134c8295.tar.gz yuzu-7ffd62424804eceb73f01b1c4e8dc216134c8295.tar.xz yuzu-7ffd62424804eceb73f01b1c4e8dc216134c8295.zip | |
service: Use ReadBufferSpan where it is trivial to do so
Diffstat (limited to 'src/core/hle/service/audio')
| -rw-r--r-- | src/core/hle/service/audio/audin_u.cpp | 6 | ||||
| -rw-r--r-- | src/core/hle/service/audio/audout_u.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/service/audio/audren_u.cpp | 6 | ||||
| -rw-r--r-- | src/core/hle/service/audio/hwopus.cpp | 6 |
4 files changed, 11 insertions, 11 deletions
diff --git a/src/core/hle/service/audio/audin_u.cpp b/src/core/hle/service/audio/audin_u.cpp index 053e8f9dd..f3dd8397d 100644 --- a/src/core/hle/service/audio/audin_u.cpp +++ b/src/core/hle/service/audio/audin_u.cpp | |||
| @@ -98,7 +98,7 @@ private: | |||
| 98 | LOG_ERROR(Service_Audio, "Input buffer is too small for an AudioInBuffer!"); | 98 | LOG_ERROR(Service_Audio, "Input buffer is too small for an AudioInBuffer!"); |
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | const auto& in_buffer = ctx.ReadBuffer(); | 101 | const auto& in_buffer = ctx.ReadBufferSpan(); |
| 102 | AudioInBuffer buffer{}; | 102 | AudioInBuffer buffer{}; |
| 103 | std::memcpy(&buffer, in_buffer.data(), sizeof(AudioInBuffer)); | 103 | std::memcpy(&buffer, in_buffer.data(), sizeof(AudioInBuffer)); |
| 104 | 104 | ||
| @@ -266,7 +266,7 @@ void AudInU::OpenAudioIn(Kernel::HLERequestContext& ctx) { | |||
| 266 | IPC::RequestParser rp{ctx}; | 266 | IPC::RequestParser rp{ctx}; |
| 267 | auto in_params{rp.PopRaw<AudioInParameter>()}; | 267 | auto in_params{rp.PopRaw<AudioInParameter>()}; |
| 268 | auto applet_resource_user_id{rp.PopRaw<u64>()}; | 268 | auto applet_resource_user_id{rp.PopRaw<u64>()}; |
| 269 | const auto device_name_data{ctx.ReadBuffer()}; | 269 | const auto device_name_data{ctx.ReadBufferSpan()}; |
| 270 | auto device_name = Common::StringFromBuffer(device_name_data); | 270 | auto device_name = Common::StringFromBuffer(device_name_data); |
| 271 | auto handle{ctx.GetCopyHandle(0)}; | 271 | auto handle{ctx.GetCopyHandle(0)}; |
| 272 | 272 | ||
| @@ -317,7 +317,7 @@ void AudInU::OpenAudioInProtocolSpecified(Kernel::HLERequestContext& ctx) { | |||
| 317 | auto protocol_specified{rp.PopRaw<u64>()}; | 317 | auto protocol_specified{rp.PopRaw<u64>()}; |
| 318 | auto in_params{rp.PopRaw<AudioInParameter>()}; | 318 | auto in_params{rp.PopRaw<AudioInParameter>()}; |
| 319 | auto applet_resource_user_id{rp.PopRaw<u64>()}; | 319 | auto applet_resource_user_id{rp.PopRaw<u64>()}; |
| 320 | const auto device_name_data{ctx.ReadBuffer()}; | 320 | const auto device_name_data{ctx.ReadBufferSpan()}; |
| 321 | auto device_name = Common::StringFromBuffer(device_name_data); | 321 | auto device_name = Common::StringFromBuffer(device_name_data); |
| 322 | auto handle{ctx.GetCopyHandle(0)}; | 322 | auto handle{ctx.GetCopyHandle(0)}; |
| 323 | 323 | ||
diff --git a/src/core/hle/service/audio/audout_u.cpp b/src/core/hle/service/audio/audout_u.cpp index 29751f075..4bf388055 100644 --- a/src/core/hle/service/audio/audout_u.cpp +++ b/src/core/hle/service/audio/audout_u.cpp | |||
| @@ -105,7 +105,7 @@ private: | |||
| 105 | LOG_ERROR(Service_Audio, "Input buffer is too small for an AudioOutBuffer!"); | 105 | LOG_ERROR(Service_Audio, "Input buffer is too small for an AudioOutBuffer!"); |
| 106 | } | 106 | } |
| 107 | 107 | ||
| 108 | const auto& in_buffer = ctx.ReadBuffer(); | 108 | const auto& in_buffer = ctx.ReadBufferSpan(); |
| 109 | AudioOutBuffer buffer{}; | 109 | AudioOutBuffer buffer{}; |
| 110 | std::memcpy(&buffer, in_buffer.data(), sizeof(AudioOutBuffer)); | 110 | std::memcpy(&buffer, in_buffer.data(), sizeof(AudioOutBuffer)); |
| 111 | 111 | ||
| @@ -264,7 +264,7 @@ void AudOutU::OpenAudioOut(Kernel::HLERequestContext& ctx) { | |||
| 264 | IPC::RequestParser rp{ctx}; | 264 | IPC::RequestParser rp{ctx}; |
| 265 | auto in_params{rp.PopRaw<AudioOutParameter>()}; | 265 | auto in_params{rp.PopRaw<AudioOutParameter>()}; |
| 266 | auto applet_resource_user_id{rp.PopRaw<u64>()}; | 266 | auto applet_resource_user_id{rp.PopRaw<u64>()}; |
| 267 | const auto device_name_data{ctx.ReadBuffer()}; | 267 | const auto device_name_data{ctx.ReadBufferSpan()}; |
| 268 | auto device_name = Common::StringFromBuffer(device_name_data); | 268 | auto device_name = Common::StringFromBuffer(device_name_data); |
| 269 | auto handle{ctx.GetCopyHandle(0)}; | 269 | auto handle{ctx.GetCopyHandle(0)}; |
| 270 | 270 | ||
diff --git a/src/core/hle/service/audio/audren_u.cpp b/src/core/hle/service/audio/audren_u.cpp index 3a1c231b6..1a48c155e 100644 --- a/src/core/hle/service/audio/audren_u.cpp +++ b/src/core/hle/service/audio/audren_u.cpp | |||
| @@ -112,7 +112,7 @@ private: | |||
| 112 | void RequestUpdate(Kernel::HLERequestContext& ctx) { | 112 | void RequestUpdate(Kernel::HLERequestContext& ctx) { |
| 113 | LOG_TRACE(Service_Audio, "called"); | 113 | LOG_TRACE(Service_Audio, "called"); |
| 114 | 114 | ||
| 115 | std::vector<u8> input{ctx.ReadBuffer(0)}; | 115 | const auto input{ctx.ReadBufferSpan(0)}; |
| 116 | 116 | ||
| 117 | // These buffers are written manually to avoid an issue with WriteBuffer throwing errors for | 117 | // These buffers are written manually to avoid an issue with WriteBuffer throwing errors for |
| 118 | // checking size 0. Performance size is 0 for most games. | 118 | // checking size 0. Performance size is 0 for most games. |
| @@ -306,7 +306,7 @@ private: | |||
| 306 | IPC::RequestParser rp{ctx}; | 306 | IPC::RequestParser rp{ctx}; |
| 307 | const f32 volume = rp.Pop<f32>(); | 307 | const f32 volume = rp.Pop<f32>(); |
| 308 | 308 | ||
| 309 | const auto device_name_buffer = ctx.ReadBuffer(); | 309 | const auto device_name_buffer = ctx.ReadBufferSpan(); |
| 310 | const std::string name = Common::StringFromBuffer(device_name_buffer); | 310 | const std::string name = Common::StringFromBuffer(device_name_buffer); |
| 311 | 311 | ||
| 312 | LOG_DEBUG(Service_Audio, "called. name={}, volume={}", name, volume); | 312 | LOG_DEBUG(Service_Audio, "called. name={}, volume={}", name, volume); |
| @@ -320,7 +320,7 @@ private: | |||
| 320 | } | 320 | } |
| 321 | 321 | ||
| 322 | void GetAudioDeviceOutputVolume(Kernel::HLERequestContext& ctx) { | 322 | void GetAudioDeviceOutputVolume(Kernel::HLERequestContext& ctx) { |
| 323 | const auto device_name_buffer = ctx.ReadBuffer(); | 323 | const auto device_name_buffer = ctx.ReadBufferSpan(); |
| 324 | const std::string name = Common::StringFromBuffer(device_name_buffer); | 324 | const std::string name = Common::StringFromBuffer(device_name_buffer); |
| 325 | 325 | ||
| 326 | LOG_DEBUG(Service_Audio, "called. Name={}", name); | 326 | LOG_DEBUG(Service_Audio, "called. Name={}", name); |
diff --git a/src/core/hle/service/audio/hwopus.cpp b/src/core/hle/service/audio/hwopus.cpp index 825fb8bcc..7c3f25c67 100644 --- a/src/core/hle/service/audio/hwopus.cpp +++ b/src/core/hle/service/audio/hwopus.cpp | |||
| @@ -74,7 +74,7 @@ private: | |||
| 74 | ResetDecoderContext(); | 74 | ResetDecoderContext(); |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | if (!DecodeOpusData(consumed, sample_count, ctx.ReadBuffer(), samples, performance)) { | 77 | if (!DecodeOpusData(consumed, sample_count, ctx.ReadBufferSpan(), samples, performance)) { |
| 78 | LOG_ERROR(Audio, "Failed to decode opus data"); | 78 | LOG_ERROR(Audio, "Failed to decode opus data"); |
| 79 | IPC::ResponseBuilder rb{ctx, 2}; | 79 | IPC::ResponseBuilder rb{ctx, 2}; |
| 80 | // TODO(ogniK): Use correct error code | 80 | // TODO(ogniK): Use correct error code |
| @@ -93,7 +93,7 @@ private: | |||
| 93 | ctx.WriteBuffer(samples); | 93 | ctx.WriteBuffer(samples); |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | bool DecodeOpusData(u32& consumed, u32& sample_count, const std::vector<u8>& input, | 96 | bool DecodeOpusData(u32& consumed, u32& sample_count, std::span<const u8> input, |
| 97 | std::vector<opus_int16>& output, u64* out_performance_time) const { | 97 | std::vector<opus_int16>& output, u64* out_performance_time) const { |
| 98 | const auto start_time = std::chrono::steady_clock::now(); | 98 | const auto start_time = std::chrono::steady_clock::now(); |
| 99 | const std::size_t raw_output_sz = output.size() * sizeof(opus_int16); | 99 | const std::size_t raw_output_sz = output.size() * sizeof(opus_int16); |
| @@ -257,7 +257,7 @@ void HwOpus::GetWorkBufferSizeEx(Kernel::HLERequestContext& ctx) { | |||
| 257 | 257 | ||
| 258 | void HwOpus::GetWorkBufferSizeForMultiStreamEx(Kernel::HLERequestContext& ctx) { | 258 | void HwOpus::GetWorkBufferSizeForMultiStreamEx(Kernel::HLERequestContext& ctx) { |
| 259 | OpusMultiStreamParametersEx param; | 259 | OpusMultiStreamParametersEx param; |
| 260 | std::memcpy(¶m, ctx.ReadBuffer().data(), ctx.GetReadBufferSize()); | 260 | std::memcpy(¶m, ctx.ReadBufferSpan().data(), ctx.GetReadBufferSize()); |
| 261 | 261 | ||
| 262 | const auto sample_rate = param.sample_rate; | 262 | const auto sample_rate = param.sample_rate; |
| 263 | const auto channel_count = param.channel_count; | 263 | const auto channel_count = param.channel_count; |