mirror of https://github.com/Genymobile/scrcpy
Kill adb daemon in OTG mode on Windows
On Windows, it is not possible to open a USB device from several process, so HID events may only work if no adb daemon is running. PR #3011 <https://github.com/Genymobile/scrcpy/pull/3011>
This commit is contained in:
parent
3bb24b3926
commit
25296ae167
|
@ -204,6 +204,14 @@ sc_adb_start_server(struct sc_intr *intr, unsigned flags) {
|
|||
return process_check_success_intr(intr, pid, "adb start-server", flags);
|
||||
}
|
||||
|
||||
bool
|
||||
sc_adb_kill_server(struct sc_intr *intr, unsigned flags) {
|
||||
const char *const argv[] = SC_ADB_COMMAND("kill-server");
|
||||
|
||||
sc_pid pid = sc_adb_execute(argv, flags);
|
||||
return process_check_success_intr(intr, pid, "adb kill-server", flags);
|
||||
}
|
||||
|
||||
bool
|
||||
sc_adb_forward(struct sc_intr *intr, const char *serial, uint16_t local_port,
|
||||
const char *device_socket_name, unsigned flags) {
|
||||
|
|
|
@ -36,6 +36,9 @@ sc_adb_execute(const char *const argv[], unsigned flags);
|
|||
bool
|
||||
sc_adb_start_server(struct sc_intr *intr, unsigned flags);
|
||||
|
||||
bool
|
||||
sc_adb_kill_server(struct sc_intr *intr, unsigned flags);
|
||||
|
||||
bool
|
||||
sc_adb_forward(struct sc_intr *intr, const char *serial, uint16_t local_port,
|
||||
const char *device_socket_name, unsigned flags);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
#include "adb/adb.h"
|
||||
#include "events.h"
|
||||
#include "screen_otg.h"
|
||||
#include "util/log.h"
|
||||
|
@ -75,6 +76,15 @@ scrcpy_otg(struct scrcpy_options *options) {
|
|||
bool aoa_started = false;
|
||||
bool aoa_initialized = false;
|
||||
|
||||
#ifdef _WIN32
|
||||
// On Windows, only one process could open a USB device
|
||||
// <https://github.com/Genymobile/scrcpy/issues/2773>
|
||||
LOGI("Killing adb daemon (if any)...");
|
||||
unsigned flags = SC_ADB_NO_STDOUT | SC_ADB_NO_STDERR | SC_ADB_NO_LOGERR;
|
||||
// uninterruptible (intr == NULL), but in practice it's very quick
|
||||
sc_adb_kill_server(NULL, flags);
|
||||
#endif
|
||||
|
||||
static const struct sc_usb_callbacks cbs = {
|
||||
.on_disconnected = sc_usb_on_disconnected,
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue