From 838724c588c5343422b1736ba73c4f309feaca00 Mon Sep 17 00:00:00 2001 From: David <25727384+ogniK5377@users.noreply.github.com> Date: Sun, 24 Jun 2018 10:46:29 +1000 Subject: [PATCH] Removed duplicate structs, changed AudioRendererResponse -> UpdateDataHeader (#583) * Removed duplicate structs, changed AudioRendererResponse -> UpdateDataHeader According to game symbols(SMO), there's references to UpdateDataHeader which seems to be what AudioRendererResponse actually is * oops * AudioRendererParameters should be AudioRendererParameter according to SMO --- src/core/hle/service/audio/audren_u.cpp | 51 +++++++++---------------- src/core/hle/service/audio/audren_u.h | 4 +- 2 files changed, 21 insertions(+), 34 deletions(-) diff --git a/src/core/hle/service/audio/audren_u.cpp b/src/core/hle/service/audio/audren_u.cpp index 653ded8e9..2188b5625 100644 --- a/src/core/hle/service/audio/audren_u.cpp +++ b/src/core/hle/service/audio/audren_u.cpp @@ -17,7 +17,7 @@ constexpr u64 audio_ticks{static_cast(CoreTiming::BASE_CLOCK_RATE / 200)}; class IAudioRenderer final : public ServiceFramework { public: - IAudioRenderer(AudioRendererParameters audren_params) + IAudioRenderer(AudioRendererParameter audren_params) : ServiceFramework("IAudioRenderer"), worker_params(audren_params) { static const FunctionInfo functions[] = { {0, nullptr, "GetAudioRendererSampleRate"}, @@ -58,22 +58,22 @@ private: } void RequestUpdateAudioRenderer(Kernel::HLERequestContext& ctx) { - AudioRendererConfig config; + UpdateDataHeader config{}; auto buf = ctx.ReadBuffer(); - std::memcpy(&config, buf.data(), sizeof(AudioRendererConfig)); + std::memcpy(&config, buf.data(), sizeof(UpdateDataHeader)); u32 memory_pool_count = worker_params.effect_count + (worker_params.voice_count * 4); std::vector mem_pool_info(memory_pool_count); std::memcpy(mem_pool_info.data(), - buf.data() + sizeof(AudioRendererConfig) + config.behavior_size, + buf.data() + sizeof(UpdateDataHeader) + config.behavior_size, memory_pool_count * sizeof(MemoryPoolInfo)); - AudioRendererResponse response_data{worker_params}; + UpdateDataHeader response_data{worker_params}; ASSERT(ctx.GetWriteBufferSize() == response_data.total_size); std::vector output(response_data.total_size); - std::memcpy(output.data(), &response_data, sizeof(AudioRendererResponse)); + std::memcpy(output.data(), &response_data, sizeof(UpdateDataHeader)); std::vector memory_pool(memory_pool_count); for (unsigned i = 0; i < memory_pool.size(); i++) { if (mem_pool_info[i].pool_state == MemoryPoolStates::RequestAttach) @@ -83,7 +83,7 @@ private: else memory_pool[i].state = mem_pool_info[i].pool_state; } - std::memcpy(output.data() + sizeof(AudioRendererResponse), memory_pool.data(), + std::memcpy(output.data() + sizeof(UpdateDataHeader), memory_pool.data(), response_data.memory_pools_size); ctx.WriteBuffer(output); @@ -146,53 +146,40 @@ private: }; static_assert(sizeof(MemoryPoolInfo) == 0x20, "MemoryPoolInfo has wrong size"); - struct AudioRendererConfig { - u32 revision; - u32 behavior_size; - u32 memory_pools_size; - u32 voices_size; - u32 voice_resource_size; - u32 effects_size; - u32 mixes_size; - u32 sinks_size; - u32 performance_buffer_size; - INSERT_PADDING_WORDS(6); - u32 total_size; - }; - static_assert(sizeof(AudioRendererConfig) == 0x40, "AudioRendererConfig has wrong size"); + struct UpdateDataHeader { + UpdateDataHeader() {} - struct AudioRendererResponse { - AudioRendererResponse(const AudioRendererParameters& config) { + UpdateDataHeader(const AudioRendererParameter& config) { revision = config.revision; - error_info_size = 0xb0; + behavior_size = 0xb0; memory_pools_size = (config.effect_count + (config.voice_count * 4)) * 0x10; voices_size = config.voice_count * 0x10; effects_size = config.effect_count * 0x10; sinks_size = config.sink_count * 0x20; performance_manager_size = 0x10; - total_size = sizeof(AudioRendererResponse) + error_info_size + memory_pools_size + + total_size = sizeof(UpdateDataHeader) + behavior_size + memory_pools_size + voices_size + effects_size + sinks_size + performance_manager_size; } u32_le revision; - u32_le error_info_size; + u32_le behavior_size; u32_le memory_pools_size; u32_le voices_size; - u32_le unknown_10; + u32_le voice_resource_size; u32_le effects_size; - u32_le unknown_18; + u32_le mixes_size; u32_le sinks_size; u32_le performance_manager_size; INSERT_PADDING_WORDS(6); u32_le total_size; }; - static_assert(sizeof(AudioRendererResponse) == 0x40, "AudioRendererResponse has wrong size"); + static_assert(sizeof(UpdateDataHeader) == 0x40, "UpdateDataHeader has wrong size"); /// This is used to trigger the audio event callback. CoreTiming::EventType* audio_event; Kernel::SharedPtr system_event; - AudioRendererParameters worker_params; + AudioRendererParameter worker_params; }; class IAudioDevice final : public ServiceFramework { @@ -291,7 +278,7 @@ AudRenU::AudRenU() : ServiceFramework("audren:u") { void AudRenU::OpenAudioRenderer(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; - auto params = rp.PopRaw(); + auto params = rp.PopRaw(); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(RESULT_SUCCESS); @@ -302,7 +289,7 @@ void AudRenU::OpenAudioRenderer(Kernel::HLERequestContext& ctx) { void AudRenU::GetAudioRendererWorkBufferSize(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; - auto params = rp.PopRaw(); + auto params = rp.PopRaw(); u64 buffer_sz = Common::AlignUp(4 * params.unknown_8, 0x40); buffer_sz += params.unknown_c * 1024; diff --git a/src/core/hle/service/audio/audren_u.h b/src/core/hle/service/audio/audren_u.h index e8baf99ee..b9b81db4f 100644 --- a/src/core/hle/service/audio/audren_u.h +++ b/src/core/hle/service/audio/audren_u.h @@ -12,7 +12,7 @@ class HLERequestContext; namespace Service::Audio { -struct AudioRendererParameters { +struct AudioRendererParameter { u32_le sample_rate; u32_le sample_count; u32_le unknown_8; @@ -28,7 +28,7 @@ struct AudioRendererParameters { INSERT_PADDING_WORDS(1); u32_le revision; }; -static_assert(sizeof(AudioRendererParameters) == 52, "AudioRendererParameters is an invalid size"); +static_assert(sizeof(AudioRendererParameter) == 52, "AudioRendererParameter is an invalid size"); class AudRenU final : public ServiceFramework { public: