Fix BT passthrough by sending larger packets

Fixes a critical regression from 8bb08d1ca6.

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.
This commit is contained in:
Léo Lam 2018-07-05 09:31:57 +02:00
parent e3a52b3361
commit 5a289de27a
1 changed files with 7 additions and 6 deletions

View File

@ -357,17 +357,18 @@ 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;
}
}
}
void BluetoothReal::SendHCIResetCommand()