Permalink
Browse files

Fix BT passthrough by sending larger packets

Fixes a critical regression from 8bb08d1.

In that commit, I replaced a 1024 byte buffer with a SHCIEventCommand.
However, it looks like some Bluetooth adapters actually require such
a large buffer, so this change needs to be reverted.
  • Loading branch information...
leoetlino committed Jul 5, 2018
1 parent e3a52b3 commit 5a289de27a167bdeaad9ffebcef02910f1c0eedf
Showing with 7 additions and 6 deletions.
  1. +7 −6 Source/Core/Core/IOS/USB/Bluetooth/BTReal.cpp
@@ -357,16 +357,17 @@ void BluetoothReal::WaitForHCICommandComplete(const u16 opcode)
{
int actual_length;
SHCIEventCommand packet;
std::vector<u8> buffer(1024);
// Only try 100 transfers at most, to avoid being stuck in an infinite loop
for (int tries = 0; tries < 100; ++tries)
{
const int ret = libusb_interrupt_transfer(m_handle, HCI_EVENT, reinterpret_cast<u8*>(&packet),
sizeof(packet), &actual_length, 20);
if (ret == 0 && actual_length == sizeof(packet) &&
packet.EventType == HCI_EVENT_COMMAND_COMPL && packet.Opcode == opcode)
{
const int ret = libusb_interrupt_transfer(m_handle, HCI_EVENT, buffer.data(),
static_cast<int>(buffer.size()), &actual_length, 20);
if (ret != 0 || actual_length < sizeof(packet))
continue;
std::memcpy(&packet, buffer.data(), sizeof(packet));
if (packet.EventType == HCI_EVENT_COMMAND_COMPL && packet.Opcode == opcode)
break;
}
}
}

0 comments on commit 5a289de

Please sign in to comment.