@@ -1834,28 +1834,28 @@ hackrf_libusb_transfer_callback(struct libusb_transfer* usb_transfer)
18341834 device -> streaming = false;
18351835 device -> flush = false;
18361836 }
1837- // Now we can release the lock. Our transfer was either
1838- // cancelled or restarted, not both.
1839- pthread_mutex_unlock (& device -> transfer_lock );
18401837
18411838 // If a data transfer was resubmitted successfully, we're done.
1842- if (resubmit && result == LIBUSB_SUCCESS )
1843- return ;
1844-
1845- // Otherwise, no further calls should be made to the TX callback.
1846- device -> streaming = false;
1839+ if (!resubmit || result != LIBUSB_SUCCESS ) {
1840+ // No further calls should be made to the TX callback.
1841+ device -> streaming = false;
18471842
1848- // If this is the last transfer, signal that all are now finished.
1849- pthread_mutex_lock (& device -> all_finished_lock );
1850- if (device -> active_transfers == 1 ) {
1851- if (!device -> flush ) {
1852- device -> active_transfers = 0 ;
1853- pthread_cond_broadcast (& device -> all_finished_cv );
1843+ // If this is the last transfer, signal that all are now finished.
1844+ pthread_mutex_lock (& device -> all_finished_lock );
1845+ if (device -> active_transfers == 1 ) {
1846+ if (!device -> flush ) {
1847+ device -> active_transfers = 0 ;
1848+ pthread_cond_broadcast (& device -> all_finished_cv );
1849+ }
1850+ } else {
1851+ device -> active_transfers -- ;
18541852 }
1855- } else {
1856- device -> active_transfers -- ;
1853+ pthread_mutex_unlock (& device -> all_finished_lock );
18571854 }
1858- pthread_mutex_unlock (& device -> all_finished_lock );
1855+
1856+ // Now we can release the lock. Our transfer was either
1857+ // cancelled or restarted, not both.
1858+ pthread_mutex_unlock (& device -> transfer_lock );
18591859}
18601860
18611861static int kill_transfer_thread (hackrf_device * device )
0 commit comments