From f7eadc1f11f990bd9b7815b0e4544118be716f9a Mon Sep 17 00:00:00 2001 From: Sepalani Date: Wed, 2 Oct 2024 14:58:04 +0400 Subject: [PATCH] IOS/USB: Lock microphone buffer less frequently --- Source/Core/Core/IOS/USB/Emulated/Microphone.cpp | 4 ++-- Source/Core/Core/IOS/USB/Emulated/Microphone.h | 2 +- Source/Core/Core/IOS/USB/Emulated/WiiSpeak.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Core/Core/IOS/USB/Emulated/Microphone.cpp b/Source/Core/Core/IOS/USB/Emulated/Microphone.cpp index dc128d60db..400029f695 100644 --- a/Source/Core/Core/IOS/USB/Emulated/Microphone.cpp +++ b/Source/Core/Core/IOS/USB/Emulated/Microphone.cpp @@ -188,9 +188,9 @@ u16 Microphone::ReadIntoBuffer(u8* ptr, u32 size) return static_cast(ptr - begin); } -bool Microphone::HasData() const +bool Microphone::HasData(u32 sample_count = BUFF_SIZE_SAMPLES) const { - return m_samples_avail > 0; + return m_samples_avail >= sample_count; } const WiiSpeakState& Microphone::GetSampler() const diff --git a/Source/Core/Core/IOS/USB/Emulated/Microphone.h b/Source/Core/Core/IOS/USB/Emulated/Microphone.h index f3b476bc1f..30af6b09c5 100644 --- a/Source/Core/Core/IOS/USB/Emulated/Microphone.h +++ b/Source/Core/Core/IOS/USB/Emulated/Microphone.h @@ -23,7 +23,7 @@ public: Microphone(const WiiSpeakState& sampler); ~Microphone(); - bool HasData() const; + bool HasData(u32 sample_count) const; u16 ReadIntoBuffer(u8* ptr, u32 size); const WiiSpeakState& GetSampler() const; diff --git a/Source/Core/Core/IOS/USB/Emulated/WiiSpeak.cpp b/Source/Core/Core/IOS/USB/Emulated/WiiSpeak.cpp index 58eb297f3e..0456a328eb 100644 --- a/Source/Core/Core/IOS/USB/Emulated/WiiSpeak.cpp +++ b/Source/Core/Core/IOS/USB/Emulated/WiiSpeak.cpp @@ -191,7 +191,7 @@ int WiiSpeak::SubmitTransfer(std::unique_ptr cmd) { // Transfer: Wii Speak -> Wii u16 size = 0; - if (m_microphone && m_microphone->HasData()) + if (m_microphone && m_microphone->HasData(cmd->length / sizeof(s16))) size = m_microphone->ReadIntoBuffer(packets, cmd->length); for (std::size_t i = 0; i < cmd->num_packets; i++) {