Remove unused lock statement

This commit is contained in:
Travis Nickles 2017-11-11 22:52:17 -06:00
parent 37a067515d
commit 2f6498a37b

View File

@ -1126,6 +1126,9 @@ namespace DS4Windows
{ {
if (Mac != null) if (Mac != null)
{ {
// Wait for output report to be written
StopOutputUpdate();
Console.WriteLine("Trying to disconnect BT device " + Mac); Console.WriteLine("Trying to disconnect BT device " + Mac);
IntPtr btHandle = IntPtr.Zero; IntPtr btHandle = IntPtr.Zero;
int IOCTL_BTH_DISCONNECT_DEVICE = 0x41000c; int IOCTL_BTH_DISCONNECT_DEVICE = 0x41000c;
@ -1141,34 +1144,30 @@ namespace DS4Windows
long lbtAddr = BitConverter.ToInt64(btAddr, 0); long lbtAddr = BitConverter.ToInt64(btAddr, 0);
bool success = false; bool success = false;
// Wait for output report to be written
lock (outputReport) NativeMethods.BLUETOOTH_FIND_RADIO_PARAMS p = new NativeMethods.BLUETOOTH_FIND_RADIO_PARAMS();
p.dwSize = Marshal.SizeOf(typeof(NativeMethods.BLUETOOTH_FIND_RADIO_PARAMS));
IntPtr searchHandle = NativeMethods.BluetoothFindFirstRadio(ref p, ref btHandle);
int bytesReturned = 0;
while (!success && btHandle != IntPtr.Zero)
{ {
NativeMethods.BLUETOOTH_FIND_RADIO_PARAMS p = new NativeMethods.BLUETOOTH_FIND_RADIO_PARAMS(); success = NativeMethods.DeviceIoControl(btHandle, IOCTL_BTH_DISCONNECT_DEVICE, ref lbtAddr, 8, IntPtr.Zero, 0, ref bytesReturned, IntPtr.Zero);
p.dwSize = Marshal.SizeOf(typeof(NativeMethods.BLUETOOTH_FIND_RADIO_PARAMS)); NativeMethods.CloseHandle(btHandle);
IntPtr searchHandle = NativeMethods.BluetoothFindFirstRadio(ref p, ref btHandle); if (!success)
int bytesReturned = 0;
while (!success && btHandle != IntPtr.Zero)
{ {
success = NativeMethods.DeviceIoControl(btHandle, IOCTL_BTH_DISCONNECT_DEVICE, ref lbtAddr, 8, IntPtr.Zero, 0, ref bytesReturned, IntPtr.Zero); if (!NativeMethods.BluetoothFindNextRadio(searchHandle, ref btHandle))
NativeMethods.CloseHandle(btHandle); btHandle = IntPtr.Zero;
if (!success)
{
if (!NativeMethods.BluetoothFindNextRadio(searchHandle, ref btHandle))
btHandle = IntPtr.Zero;
}
} }
NativeMethods.BluetoothFindRadioClose(searchHandle);
Console.WriteLine("Disconnect successful: " + success);
} }
NativeMethods.BluetoothFindRadioClose(searchHandle);
Console.WriteLine("Disconnect successful: " + success);
success = true; // XXX return value indicates failure, but it still works? success = true; // XXX return value indicates failure, but it still works?
if (success) if (success)
{ {
IsDisconnecting = true; IsDisconnecting = true;
StopOutputUpdate();
if (callRemoval) if (callRemoval)
{ {
@ -1195,15 +1194,14 @@ namespace DS4Windows
disconnectReport[1] = 0x02; disconnectReport[1] = 0x02;
Array.Clear(disconnectReport, 2, 63); Array.Clear(disconnectReport, 2, 63);
lock (outputReport) if (remove)
{ StopOutputUpdate();
result = hDevice.WriteFeatureReport(disconnectReport);
} result = hDevice.WriteFeatureReport(disconnectReport);
if (result && remove) if (result && remove)
{ {
isDisconnecting = true; isDisconnecting = true;
StopOutputUpdate();
uiContext.Send(new SendOrPostCallback(delegate (object state4) uiContext.Send(new SendOrPostCallback(delegate (object state4)
{ {