summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/hle/service/audio/audin_u.cpp16
-rw-r--r--src/core/hle/service/audio/audout_u.cpp20
-rw-r--r--src/core/hle/service/audio/audren_u.cpp23
-rw-r--r--src/core/hle/service/audio/hwopus.cpp9
-rw-r--r--src/core/hle/service/nvdrv/nvdrv_interface.cpp25
-rw-r--r--src/core/hle/service/nvdrv/nvdrv_interface.h5
6 files changed, 53 insertions, 45 deletions
diff --git a/src/core/hle/service/audio/audin_u.cpp b/src/core/hle/service/audio/audin_u.cpp
index c8d574993..526a39130 100644
--- a/src/core/hle/service/audio/audin_u.cpp
+++ b/src/core/hle/service/audio/audin_u.cpp
@@ -5,7 +5,7 @@
5#include "audio_core/renderer/audio_device.h" 5#include "audio_core/renderer/audio_device.h"
6#include "common/common_funcs.h" 6#include "common/common_funcs.h"
7#include "common/logging/log.h" 7#include "common/logging/log.h"
8#include "common/settings.h" 8#include "common/scratch_buffer.h"
9#include "common/string_util.h" 9#include "common/string_util.h"
10#include "core/core.h" 10#include "core/core.h"
11#include "core/hle/kernel/k_event.h" 11#include "core/hle/kernel/k_event.h"
@@ -124,12 +124,15 @@ private:
124 124
125 void GetReleasedAudioInBuffer(HLERequestContext& ctx) { 125 void GetReleasedAudioInBuffer(HLERequestContext& ctx) {
126 const auto write_buffer_size = ctx.GetWriteBufferNumElements<u64>(); 126 const auto write_buffer_size = ctx.GetWriteBufferNumElements<u64>();
127 tmp_buffer.resize_destructive(write_buffer_size); 127 released_buffer.resize_destructive(write_buffer_size);
128 tmp_buffer[0] = 0; 128 released_buffer[0] = 0;
129 129
130 const auto count = impl->GetReleasedBuffers(tmp_buffer); 130 const auto count = impl->GetReleasedBuffers(released_buffer);
131 131
132 ctx.WriteBuffer(tmp_buffer); 132 LOG_TRACE(Service_Audio, "called. Session {} released {} buffers",
133 impl->GetSystem().GetSessionId(), count);
134
135 ctx.WriteBuffer(released_buffer);
133 136
134 IPC::ResponseBuilder rb{ctx, 3}; 137 IPC::ResponseBuilder rb{ctx, 3};
135 rb.Push(ResultSuccess); 138 rb.Push(ResultSuccess);
@@ -155,7 +158,6 @@ private:
155 LOG_DEBUG(Service_Audio, "called. Buffer count={}", buffer_count); 158 LOG_DEBUG(Service_Audio, "called. Buffer count={}", buffer_count);
156 159
157 IPC::ResponseBuilder rb{ctx, 3}; 160 IPC::ResponseBuilder rb{ctx, 3};
158
159 rb.Push(ResultSuccess); 161 rb.Push(ResultSuccess);
160 rb.Push(buffer_count); 162 rb.Push(buffer_count);
161 } 163 }
@@ -195,7 +197,7 @@ private:
195 KernelHelpers::ServiceContext service_context; 197 KernelHelpers::ServiceContext service_context;
196 Kernel::KEvent* event; 198 Kernel::KEvent* event;
197 std::shared_ptr<AudioCore::AudioIn::In> impl; 199 std::shared_ptr<AudioCore::AudioIn::In> impl;
198 Common::ScratchBuffer<u64> tmp_buffer; 200 Common::ScratchBuffer<u64> released_buffer;
199}; 201};
200 202
201AudInU::AudInU(Core::System& system_) 203AudInU::AudInU(Core::System& system_)
diff --git a/src/core/hle/service/audio/audout_u.cpp b/src/core/hle/service/audio/audout_u.cpp
index 032c8c11f..23f84a29f 100644
--- a/src/core/hle/service/audio/audout_u.cpp
+++ b/src/core/hle/service/audio/audout_u.cpp
@@ -9,6 +9,7 @@
9#include "audio_core/renderer/audio_device.h" 9#include "audio_core/renderer/audio_device.h"
10#include "common/common_funcs.h" 10#include "common/common_funcs.h"
11#include "common/logging/log.h" 11#include "common/logging/log.h"
12#include "common/scratch_buffer.h"
12#include "common/string_util.h" 13#include "common/string_util.h"
13#include "common/swap.h" 14#include "common/swap.h"
14#include "core/core.h" 15#include "core/core.h"
@@ -102,8 +103,8 @@ private:
102 AudioOutBuffer buffer{}; 103 AudioOutBuffer buffer{};
103 std::memcpy(&buffer, in_buffer.data(), sizeof(AudioOutBuffer)); 104 std::memcpy(&buffer, in_buffer.data(), sizeof(AudioOutBuffer));
104 105
105 [[maybe_unused]] auto sessionid{impl->GetSystem().GetSessionId()}; 106 LOG_TRACE(Service_Audio, "called. Session {} Appending buffer {:08X}",
106 LOG_TRACE(Service_Audio, "called. Session {} Appending buffer {:08X}", sessionid, tag); 107 impl->GetSystem().GetSessionId(), tag);
107 108
108 auto result = impl->AppendBuffer(buffer, tag); 109 auto result = impl->AppendBuffer(buffer, tag);
109 110
@@ -123,12 +124,15 @@ private:
123 124
124 void GetReleasedAudioOutBuffers(HLERequestContext& ctx) { 125 void GetReleasedAudioOutBuffers(HLERequestContext& ctx) {
125 const auto write_buffer_size = ctx.GetWriteBufferNumElements<u64>(); 126 const auto write_buffer_size = ctx.GetWriteBufferNumElements<u64>();
126 tmp_buffer.resize_destructive(write_buffer_size); 127 released_buffer.resize_destructive(write_buffer_size);
127 tmp_buffer[0] = 0; 128 released_buffer[0] = 0;
128 129
129 const auto count = impl->GetReleasedBuffers(tmp_buffer); 130 const auto count = impl->GetReleasedBuffers(released_buffer);
130 131
131 ctx.WriteBuffer(tmp_buffer); 132 ctx.WriteBuffer(released_buffer);
133
134 LOG_TRACE(Service_Audio, "called. Session {} released {} buffers",
135 impl->GetSystem().GetSessionId(), count);
132 136
133 IPC::ResponseBuilder rb{ctx, 3}; 137 IPC::ResponseBuilder rb{ctx, 3};
134 rb.Push(ResultSuccess); 138 rb.Push(ResultSuccess);
@@ -154,7 +158,6 @@ private:
154 LOG_DEBUG(Service_Audio, "called. Buffer count={}", buffer_count); 158 LOG_DEBUG(Service_Audio, "called. Buffer count={}", buffer_count);
155 159
156 IPC::ResponseBuilder rb{ctx, 3}; 160 IPC::ResponseBuilder rb{ctx, 3};
157
158 rb.Push(ResultSuccess); 161 rb.Push(ResultSuccess);
159 rb.Push(buffer_count); 162 rb.Push(buffer_count);
160 } 163 }
@@ -165,7 +168,6 @@ private:
165 LOG_DEBUG(Service_Audio, "called. Played samples={}", samples_played); 168 LOG_DEBUG(Service_Audio, "called. Played samples={}", samples_played);
166 169
167 IPC::ResponseBuilder rb{ctx, 4}; 170 IPC::ResponseBuilder rb{ctx, 4};
168
169 rb.Push(ResultSuccess); 171 rb.Push(ResultSuccess);
170 rb.Push(samples_played); 172 rb.Push(samples_played);
171 } 173 }
@@ -205,7 +207,7 @@ private:
205 KernelHelpers::ServiceContext service_context; 207 KernelHelpers::ServiceContext service_context;
206 Kernel::KEvent* event; 208 Kernel::KEvent* event;
207 std::shared_ptr<AudioCore::AudioOut::Out> impl; 209 std::shared_ptr<AudioCore::AudioOut::Out> impl;
208 Common::ScratchBuffer<u64> tmp_buffer; 210 Common::ScratchBuffer<u64> released_buffer;
209}; 211};
210 212
211AudOutU::AudOutU(Core::System& system_) 213AudOutU::AudOutU(Core::System& system_)
diff --git a/src/core/hle/service/audio/audren_u.cpp b/src/core/hle/service/audio/audren_u.cpp
index 12845c23a..003870176 100644
--- a/src/core/hle/service/audio/audren_u.cpp
+++ b/src/core/hle/service/audio/audren_u.cpp
@@ -15,6 +15,7 @@
15#include "common/common_funcs.h" 15#include "common/common_funcs.h"
16#include "common/logging/log.h" 16#include "common/logging/log.h"
17#include "common/polyfill_ranges.h" 17#include "common/polyfill_ranges.h"
18#include "common/scratch_buffer.h"
18#include "common/string_util.h" 19#include "common/string_util.h"
19#include "core/core.h" 20#include "core/core.h"
20#include "core/hle/kernel/k_event.h" 21#include "core/hle/kernel/k_event.h"
@@ -119,23 +120,23 @@ private:
119 auto is_buffer_b{ctx.BufferDescriptorB()[0].Size() != 0}; 120 auto is_buffer_b{ctx.BufferDescriptorB()[0].Size() != 0};
120 if (is_buffer_b) { 121 if (is_buffer_b) {
121 const auto buffersB{ctx.BufferDescriptorB()}; 122 const auto buffersB{ctx.BufferDescriptorB()};
122 tmp_output.resize_destructive(buffersB[0].Size()); 123 output_buffer.resize_destructive(buffersB[0].Size());
123 tmp_performance.resize_destructive(buffersB[1].Size()); 124 performance_buffer.resize_destructive(buffersB[1].Size());
124 } else { 125 } else {
125 const auto buffersC{ctx.BufferDescriptorC()}; 126 const auto buffersC{ctx.BufferDescriptorC()};
126 tmp_output.resize_destructive(buffersC[0].Size()); 127 output_buffer.resize_destructive(buffersC[0].Size());
127 tmp_performance.resize_destructive(buffersC[1].Size()); 128 performance_buffer.resize_destructive(buffersC[1].Size());
128 } 129 }
129 130
130 auto result = impl->RequestUpdate(input, tmp_performance, tmp_output); 131 auto result = impl->RequestUpdate(input, performance_buffer, output_buffer);
131 132
132 if (result.IsSuccess()) { 133 if (result.IsSuccess()) {
133 if (is_buffer_b) { 134 if (is_buffer_b) {
134 ctx.WriteBufferB(tmp_output.data(), tmp_output.size(), 0); 135 ctx.WriteBufferB(output_buffer.data(), output_buffer.size(), 0);
135 ctx.WriteBufferB(tmp_performance.data(), tmp_performance.size(), 1); 136 ctx.WriteBufferB(performance_buffer.data(), performance_buffer.size(), 1);
136 } else { 137 } else {
137 ctx.WriteBufferC(tmp_output.data(), tmp_output.size(), 0); 138 ctx.WriteBufferC(output_buffer.data(), output_buffer.size(), 0);
138 ctx.WriteBufferC(tmp_performance.data(), tmp_performance.size(), 1); 139 ctx.WriteBufferC(performance_buffer.data(), performance_buffer.size(), 1);
139 } 140 }
140 } else { 141 } else {
141 LOG_ERROR(Service_Audio, "RequestUpdate failed error 0x{:02X}!", result.description); 142 LOG_ERROR(Service_Audio, "RequestUpdate failed error 0x{:02X}!", result.description);
@@ -233,8 +234,8 @@ private:
233 Kernel::KEvent* rendered_event; 234 Kernel::KEvent* rendered_event;
234 Manager& manager; 235 Manager& manager;
235 std::unique_ptr<Renderer> impl; 236 std::unique_ptr<Renderer> impl;
236 Common::ScratchBuffer<u8> tmp_output; 237 Common::ScratchBuffer<u8> output_buffer;
237 Common::ScratchBuffer<u8> tmp_performance; 238 Common::ScratchBuffer<u8> performance_buffer;
238}; 239};
239 240
240class IAudioDevice final : public ServiceFramework<IAudioDevice> { 241class IAudioDevice final : public ServiceFramework<IAudioDevice> {
diff --git a/src/core/hle/service/audio/hwopus.cpp b/src/core/hle/service/audio/hwopus.cpp
index c835f6cb7..fa77007f3 100644
--- a/src/core/hle/service/audio/hwopus.cpp
+++ b/src/core/hle/service/audio/hwopus.cpp
@@ -11,6 +11,7 @@
11 11
12#include "common/assert.h" 12#include "common/assert.h"
13#include "common/logging/log.h" 13#include "common/logging/log.h"
14#include "common/scratch_buffer.h"
14#include "core/hle/service/audio/hwopus.h" 15#include "core/hle/service/audio/hwopus.h"
15#include "core/hle/service/ipc_helpers.h" 16#include "core/hle/service/ipc_helpers.h"
16 17
@@ -68,13 +69,13 @@ private:
68 ExtraBehavior extra_behavior) { 69 ExtraBehavior extra_behavior) {
69 u32 consumed = 0; 70 u32 consumed = 0;
70 u32 sample_count = 0; 71 u32 sample_count = 0;
71 tmp_samples.resize_destructive(ctx.GetWriteBufferNumElements<opus_int16>()); 72 samples.resize_destructive(ctx.GetWriteBufferNumElements<opus_int16>());
72 73
73 if (extra_behavior == ExtraBehavior::ResetContext) { 74 if (extra_behavior == ExtraBehavior::ResetContext) {
74 ResetDecoderContext(); 75 ResetDecoderContext();
75 } 76 }
76 77
77 if (!DecodeOpusData(consumed, sample_count, ctx.ReadBuffer(), tmp_samples, performance)) { 78 if (!DecodeOpusData(consumed, sample_count, ctx.ReadBuffer(), samples, performance)) {
78 LOG_ERROR(Audio, "Failed to decode opus data"); 79 LOG_ERROR(Audio, "Failed to decode opus data");
79 IPC::ResponseBuilder rb{ctx, 2}; 80 IPC::ResponseBuilder rb{ctx, 2};
80 // TODO(ogniK): Use correct error code 81 // TODO(ogniK): Use correct error code
@@ -90,7 +91,7 @@ private:
90 if (performance) { 91 if (performance) {
91 rb.Push<u64>(*performance); 92 rb.Push<u64>(*performance);
92 } 93 }
93 ctx.WriteBuffer(tmp_samples); 94 ctx.WriteBuffer(samples);
94 } 95 }
95 96
96 bool DecodeOpusData(u32& consumed, u32& sample_count, std::span<const u8> input, 97 bool DecodeOpusData(u32& consumed, u32& sample_count, std::span<const u8> input,
@@ -154,7 +155,7 @@ private:
154 OpusDecoderPtr decoder; 155 OpusDecoderPtr decoder;
155 u32 sample_rate; 156 u32 sample_rate;
156 u32 channel_count; 157 u32 channel_count;
157 Common::ScratchBuffer<opus_int16> tmp_samples; 158 Common::ScratchBuffer<opus_int16> samples;
158}; 159};
159 160
160class IHardwareOpusDecoderManager final : public ServiceFramework<IHardwareOpusDecoderManager> { 161class IHardwareOpusDecoderManager final : public ServiceFramework<IHardwareOpusDecoderManager> {
diff --git a/src/core/hle/service/nvdrv/nvdrv_interface.cpp b/src/core/hle/service/nvdrv/nvdrv_interface.cpp
index 348207e25..c8a880e84 100644
--- a/src/core/hle/service/nvdrv/nvdrv_interface.cpp
+++ b/src/core/hle/service/nvdrv/nvdrv_interface.cpp
@@ -2,7 +2,6 @@
2// SPDX-FileCopyrightText: 2021 Skyline Team and Contributors 2// SPDX-FileCopyrightText: 2021 Skyline Team and Contributors
3// SPDX-License-Identifier: GPL-3.0-or-later 3// SPDX-License-Identifier: GPL-3.0-or-later
4 4
5#include <cinttypes>
6#include "common/logging/log.h" 5#include "common/logging/log.h"
7#include "core/core.h" 6#include "core/core.h"
8#include "core/hle/kernel/k_event.h" 7#include "core/hle/kernel/k_event.h"
@@ -63,12 +62,12 @@ void NVDRV::Ioctl1(HLERequestContext& ctx) {
63 } 62 }
64 63
65 // Check device 64 // Check device
66 tmp_output.resize_destructive(ctx.GetWriteBufferSize(0)); 65 output_buffer.resize_destructive(ctx.GetWriteBufferSize(0));
67 const auto input_buffer = ctx.ReadBuffer(0); 66 const auto input_buffer = ctx.ReadBuffer(0);
68 67
69 const auto nv_result = nvdrv->Ioctl1(fd, command, input_buffer, tmp_output); 68 const auto nv_result = nvdrv->Ioctl1(fd, command, input_buffer, output_buffer);
70 if (command.is_out != 0) { 69 if (command.is_out != 0) {
71 ctx.WriteBuffer(tmp_output); 70 ctx.WriteBuffer(output_buffer);
72 } 71 }
73 72
74 IPC::ResponseBuilder rb{ctx, 3}; 73 IPC::ResponseBuilder rb{ctx, 3};
@@ -90,12 +89,12 @@ void NVDRV::Ioctl2(HLERequestContext& ctx) {
90 89
91 const auto input_buffer = ctx.ReadBuffer(0); 90 const auto input_buffer = ctx.ReadBuffer(0);
92 const auto input_inlined_buffer = ctx.ReadBuffer(1); 91 const auto input_inlined_buffer = ctx.ReadBuffer(1);
93 tmp_output.resize_destructive(ctx.GetWriteBufferSize(0)); 92 output_buffer.resize_destructive(ctx.GetWriteBufferSize(0));
94 93
95 const auto nv_result = 94 const auto nv_result =
96 nvdrv->Ioctl2(fd, command, input_buffer, input_inlined_buffer, tmp_output); 95 nvdrv->Ioctl2(fd, command, input_buffer, input_inlined_buffer, output_buffer);
97 if (command.is_out != 0) { 96 if (command.is_out != 0) {
98 ctx.WriteBuffer(tmp_output); 97 ctx.WriteBuffer(output_buffer);
99 } 98 }
100 99
101 IPC::ResponseBuilder rb{ctx, 3}; 100 IPC::ResponseBuilder rb{ctx, 3};
@@ -116,12 +115,14 @@ void NVDRV::Ioctl3(HLERequestContext& ctx) {
116 } 115 }
117 116
118 const auto input_buffer = ctx.ReadBuffer(0); 117 const auto input_buffer = ctx.ReadBuffer(0);
119 tmp_output.resize_destructive(ctx.GetWriteBufferSize(0)); 118 output_buffer.resize_destructive(ctx.GetWriteBufferSize(0));
120 tmp_output_inline.resize_destructive(ctx.GetWriteBufferSize(1)); 119 inline_output_buffer.resize_destructive(ctx.GetWriteBufferSize(1));
121 const auto nv_result = nvdrv->Ioctl3(fd, command, input_buffer, tmp_output, tmp_output_inline); 120
121 const auto nv_result =
122 nvdrv->Ioctl3(fd, command, input_buffer, output_buffer, inline_output_buffer);
122 if (command.is_out != 0) { 123 if (command.is_out != 0) {
123 ctx.WriteBuffer(tmp_output, 0); 124 ctx.WriteBuffer(output_buffer, 0);
124 ctx.WriteBuffer(tmp_output_inline, 1); 125 ctx.WriteBuffer(inline_output_buffer, 1);
125 } 126 }
126 127
127 IPC::ResponseBuilder rb{ctx, 3}; 128 IPC::ResponseBuilder rb{ctx, 3};
diff --git a/src/core/hle/service/nvdrv/nvdrv_interface.h b/src/core/hle/service/nvdrv/nvdrv_interface.h
index 4b593ff90..6e98115dc 100644
--- a/src/core/hle/service/nvdrv/nvdrv_interface.h
+++ b/src/core/hle/service/nvdrv/nvdrv_interface.h
@@ -4,6 +4,7 @@
4#pragma once 4#pragma once
5 5
6#include <memory> 6#include <memory>
7
7#include "common/scratch_buffer.h" 8#include "common/scratch_buffer.h"
8#include "core/hle/service/nvdrv/nvdrv.h" 9#include "core/hle/service/nvdrv/nvdrv.h"
9#include "core/hle/service/service.h" 10#include "core/hle/service/service.h"
@@ -34,8 +35,8 @@ private:
34 35
35 u64 pid{}; 36 u64 pid{};
36 bool is_initialized{}; 37 bool is_initialized{};
37 Common::ScratchBuffer<u8> tmp_output; 38 Common::ScratchBuffer<u8> output_buffer;
38 Common::ScratchBuffer<u8> tmp_output_inline; 39 Common::ScratchBuffer<u8> inline_output_buffer;
39}; 40};
40 41
41} // namespace Service::Nvidia 42} // namespace Service::Nvidia