summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/audio
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2022-11-23 19:25:14 +0100
committerLioncash <mathew1800@gmail.com>2022-11-23 19:43:20 +0100
commit97f273e94e83a679f42faa9c81916a1c058112e1 (patch)
treee2a2777ae3bec31b544516988fae36e8080150ff /src/core/hle/service/audio
parenthle_ipc: Add helper functions for getting number of buffer elements (diff)
downloadyuzu-97f273e94e83a679f42faa9c81916a1c058112e1.tar
yuzu-97f273e94e83a679f42faa9c81916a1c058112e1.tar.gz
yuzu-97f273e94e83a679f42faa9c81916a1c058112e1.tar.bz2
yuzu-97f273e94e83a679f42faa9c81916a1c058112e1.tar.lz
yuzu-97f273e94e83a679f42faa9c81916a1c058112e1.tar.xz
yuzu-97f273e94e83a679f42faa9c81916a1c058112e1.tar.zst
yuzu-97f273e94e83a679f42faa9c81916a1c058112e1.zip
Diffstat (limited to 'src/core/hle/service/audio')
-rw-r--r--src/core/hle/service/audio/audin_u.cpp10
-rw-r--r--src/core/hle/service/audio/audout_u.cpp10
-rw-r--r--src/core/hle/service/audio/audren_u.cpp6
-rw-r--r--src/core/hle/service/audio/hwopus.cpp2
4 files changed, 14 insertions, 14 deletions
diff --git a/src/core/hle/service/audio/audin_u.cpp b/src/core/hle/service/audio/audin_u.cpp
index 608925dfc..053e8f9dd 100644
--- a/src/core/hle/service/audio/audin_u.cpp
+++ b/src/core/hle/service/audio/audin_u.cpp
@@ -122,10 +122,10 @@ private:
}
void GetReleasedAudioInBuffer(Kernel::HLERequestContext& ctx) {
- auto write_buffer_size = ctx.GetWriteBufferSize() / sizeof(u64);
- std::vector<u64> released_buffers(write_buffer_size, 0);
+ const auto write_buffer_size = ctx.GetWriteBufferNumElements<u64>();
+ std::vector<u64> released_buffers(write_buffer_size);
- auto count = impl->GetReleasedBuffers(released_buffers);
+ const auto count = impl->GetReleasedBuffers(released_buffers);
[[maybe_unused]] std::string tags{};
for (u32 i = 0; i < count; i++) {
@@ -228,7 +228,7 @@ void AudInU::ListAudioIns(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_Audio, "called");
const auto write_count =
- static_cast<u32>(ctx.GetWriteBufferSize() / sizeof(AudioDevice::AudioDeviceName));
+ static_cast<u32>(ctx.GetWriteBufferNumElements<AudioDevice::AudioDeviceName>());
std::vector<AudioDevice::AudioDeviceName> device_names{};
u32 out_count{0};
@@ -248,7 +248,7 @@ void AudInU::ListAudioInsAutoFiltered(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_Audio, "called");
const auto write_count =
- static_cast<u32>(ctx.GetWriteBufferSize() / sizeof(AudioDevice::AudioDeviceName));
+ static_cast<u32>(ctx.GetWriteBufferNumElements<AudioDevice::AudioDeviceName>());
std::vector<AudioDevice::AudioDeviceName> device_names{};
u32 out_count{0};
diff --git a/src/core/hle/service/audio/audout_u.cpp b/src/core/hle/service/audio/audout_u.cpp
index 122290c6a..29751f075 100644
--- a/src/core/hle/service/audio/audout_u.cpp
+++ b/src/core/hle/service/audio/audout_u.cpp
@@ -129,16 +129,16 @@ private:
}
void GetReleasedAudioOutBuffers(Kernel::HLERequestContext& ctx) {
- auto write_buffer_size = ctx.GetWriteBufferSize() / sizeof(u64);
- std::vector<u64> released_buffers(write_buffer_size, 0);
+ const auto write_buffer_size = ctx.GetWriteBufferNumElements<u64>();
+ std::vector<u64> released_buffers(write_buffer_size);
- auto count = impl->GetReleasedBuffers(released_buffers);
+ const auto count = impl->GetReleasedBuffers(released_buffers);
[[maybe_unused]] std::string tags{};
for (u32 i = 0; i < count; i++) {
tags += fmt::format("{:08X}, ", released_buffers[i]);
}
- [[maybe_unused]] auto sessionid{impl->GetSystem().GetSessionId()};
+ [[maybe_unused]] const auto sessionid{impl->GetSystem().GetSessionId()};
LOG_TRACE(Service_Audio, "called. Session {} released {} buffers: {}", sessionid, count,
tags);
@@ -244,7 +244,7 @@ void AudOutU::ListAudioOuts(Kernel::HLERequestContext& ctx) {
std::scoped_lock l{impl->mutex};
const auto write_count =
- static_cast<u32>(ctx.GetWriteBufferSize() / sizeof(AudioDevice::AudioDeviceName));
+ static_cast<u32>(ctx.GetWriteBufferNumElements<AudioDevice::AudioDeviceName>());
std::vector<AudioDevice::AudioDeviceName> device_names{};
if (write_count > 0) {
device_names.emplace_back("DeviceOut");
diff --git a/src/core/hle/service/audio/audren_u.cpp b/src/core/hle/service/audio/audren_u.cpp
index 13423dca6..034ee273f 100644
--- a/src/core/hle/service/audio/audren_u.cpp
+++ b/src/core/hle/service/audio/audren_u.cpp
@@ -274,7 +274,7 @@ public:
private:
void ListAudioDeviceName(Kernel::HLERequestContext& ctx) {
- const size_t in_count = ctx.GetWriteBufferSize() / sizeof(AudioDevice::AudioDeviceName);
+ const size_t in_count = ctx.GetWriteBufferNumElements<AudioDevice::AudioDeviceName>();
std::vector<AudioDevice::AudioDeviceName> out_names{};
@@ -335,7 +335,7 @@ private:
}
void GetActiveAudioDeviceName(Kernel::HLERequestContext& ctx) {
- const auto write_size = ctx.GetWriteBufferSize() / sizeof(char);
+ const auto write_size = ctx.GetWriteBufferSize();
std::string out_name{"AudioTvOutput"};
LOG_DEBUG(Service_Audio, "(STUBBED) called. Name={}", out_name);
@@ -387,7 +387,7 @@ private:
}
void ListAudioOutputDeviceName(Kernel::HLERequestContext& ctx) {
- const size_t in_count = ctx.GetWriteBufferSize() / sizeof(AudioDevice::AudioDeviceName);
+ const size_t in_count = ctx.GetWriteBufferNumElements<AudioDevice::AudioDeviceName>();
std::vector<AudioDevice::AudioDeviceName> out_names{};
diff --git a/src/core/hle/service/audio/hwopus.cpp b/src/core/hle/service/audio/hwopus.cpp
index 8bafc3a98..825fb8bcc 100644
--- a/src/core/hle/service/audio/hwopus.cpp
+++ b/src/core/hle/service/audio/hwopus.cpp
@@ -68,7 +68,7 @@ private:
ExtraBehavior extra_behavior) {
u32 consumed = 0;
u32 sample_count = 0;
- std::vector<opus_int16> samples(ctx.GetWriteBufferSize() / sizeof(opus_int16));
+ std::vector<opus_int16> samples(ctx.GetWriteBufferNumElements<opus_int16>());
if (extra_behavior == ExtraBehavior::ResetContext) {
ResetDecoderContext();