IOS/USB: Lock microphone buffer less frequently

This commit is contained in:
Sepalani 2024-10-02 14:58:04 +04:00
parent 82a03ca73b
commit f7eadc1f11
3 changed files with 4 additions and 4 deletions

View file

@ -188,9 +188,9 @@ u16 Microphone::ReadIntoBuffer(u8* ptr, u32 size)
return static_cast<u16>(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

View file

@ -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;

View file

@ -191,7 +191,7 @@ int WiiSpeak::SubmitTransfer(std::unique_ptr<IsoMessage> 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++)
{