[xboxdrv] 44/78: Added some handling of LIBUSB_TRANSFER_NO_DEVICE errors to USBController

Andrey Rahmatullin wrar-guest at moszumanska.debian.org
Sun Feb 21 17:55:11 UTC 2016


This is an automated email from the git hooks/post-receive script.

wrar-guest pushed a commit to branch master
in repository xboxdrv.

commit 0b168bfa30b4812c6668b84092a710f7590fb70d
Author: Ingo Ruhnke <grumbel at gmail.com>
Date:   Sat Oct 24 12:45:21 2015 +0200

    Added some handling of LIBUSB_TRANSFER_NO_DEVICE errors to USBController
    
    Fixes #35
---
 src/usb_controller.cpp | 46 ++++++++++++++++++++++++++++++++--------------
 1 file changed, 32 insertions(+), 14 deletions(-)

diff --git a/src/usb_controller.cpp b/src/usb_controller.cpp
index 0d2b369..4014347 100644
--- a/src/usb_controller.cpp
+++ b/src/usb_controller.cpp
@@ -218,10 +218,21 @@ USBController::on_control(libusb_transfer* transfer)
 void
 USBController::on_write_data(libusb_transfer* transfer)
 {
-  if (transfer->status != LIBUSB_TRANSFER_COMPLETED)
+  if (transfer->status == LIBUSB_TRANSFER_COMPLETED)
   {
-    if (transfer->status != LIBUSB_TRANSFER_CANCELLED)
-      log_error("USB write failure: " << transfer->length << ": " << usb_transfer_strerror(transfer->status));
+    // ok
+  }
+  else if (transfer->status == LIBUSB_TRANSFER_CANCELLED)
+  {
+    // ok
+  }
+  else if (transfer->status == LIBUSB_TRANSFER_NO_DEVICE)
+  {
+    send_disconnect();
+  }
+  else
+  {
+    log_error("USB write failure: " << transfer->length << ": " << usb_transfer_strerror(transfer->status));
   }
 
   m_transfers.erase(transfer);
@@ -233,15 +244,7 @@ USBController::on_read_data(libusb_transfer* transfer)
 {
   assert(transfer);
 
-  if (transfer->status != LIBUSB_TRANSFER_COMPLETED)
-  {
-    if (transfer->status != LIBUSB_TRANSFER_CANCELLED)
-      log_error("USB read failure: " << transfer->length << ": " << usb_transfer_strerror(transfer->status));
-
-    m_transfers.erase(transfer);
-    libusb_free_transfer(transfer);
-  }
-  else
+  if (transfer->status == LIBUSB_TRANSFER_COMPLETED)
   {
     // process data
     XboxGenericMsg msg;
@@ -255,12 +258,27 @@ USBController::on_read_data(libusb_transfer* transfer)
     if (ret != LIBUSB_SUCCESS) // could also check for LIBUSB_ERROR_NO_DEVICE
     {
       log_error("failed to resubmit USB transfer: " << usb_strerror(ret));
-
+      m_transfers.erase(transfer);
       libusb_free_transfer(transfer);
-
       send_disconnect();
     }
   }
+  else if (transfer->status == LIBUSB_TRANSFER_CANCELLED)
+  {
+    // ok
+  }
+  else if (transfer->status == LIBUSB_TRANSFER_NO_DEVICE)
+  {
+    m_transfers.erase(transfer);
+    libusb_free_transfer(transfer);
+    send_disconnect();
+  }
+  else
+  {
+    log_error("USB read failure: " << transfer->length << ": " << usb_transfer_strerror(transfer->status));
+    m_transfers.erase(transfer);
+    libusb_free_transfer(transfer);
+  }
 }
 
 void

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/xboxdrv.git



More information about the Pkg-games-commits mailing list