mirror of
https://github.com/Genymobile/scrcpy
synced 2025-09-01 23:05:19 +00:00
Store serial in server instance
The serial is needed for many server actions, but this is an implementation detail, so the caller should not have to provide it on every call. Instead, store the serial in the server instance on server_start(). This paves the way to implement the "adb forward" fallback properly.
This commit is contained in:
@@ -103,9 +103,9 @@ SDL_bool scrcpy(const char *serial, Uint16 local_port, Uint16 max_size, Uint32 b
|
||||
// managed by the event loop. This blocking call blocks the event loop, so
|
||||
// timeout the connection not to block indefinitely in case of SIGTERM.
|
||||
#define SERVER_CONNECT_TIMEOUT_MS 2000
|
||||
socket_t device_socket = server_connect_to(&server, serial, SERVER_CONNECT_TIMEOUT_MS);
|
||||
socket_t device_socket = server_connect_to(&server, SERVER_CONNECT_TIMEOUT_MS);
|
||||
if (device_socket == INVALID_SOCKET) {
|
||||
server_stop(&server, serial);
|
||||
server_stop(&server);
|
||||
ret = SDL_FALSE;
|
||||
goto finally_destroy_server;
|
||||
}
|
||||
@@ -117,13 +117,13 @@ SDL_bool scrcpy(const char *serial, Uint16 local_port, Uint16 max_size, Uint32 b
|
||||
// therefore, we transmit the screen size before the video stream, to be able
|
||||
// to init the window immediately
|
||||
if (!device_read_info(device_socket, device_name, &frame_size)) {
|
||||
server_stop(&server, serial);
|
||||
server_stop(&server);
|
||||
ret = SDL_FALSE;
|
||||
goto finally_destroy_server;
|
||||
}
|
||||
|
||||
if (!frames_init(&frames)) {
|
||||
server_stop(&server, serial);
|
||||
server_stop(&server);
|
||||
ret = SDL_FALSE;
|
||||
goto finally_destroy_server;
|
||||
}
|
||||
@@ -134,7 +134,7 @@ SDL_bool scrcpy(const char *serial, Uint16 local_port, Uint16 max_size, Uint32 b
|
||||
// start the decoder
|
||||
if (!decoder_start(&decoder)) {
|
||||
ret = SDL_FALSE;
|
||||
server_stop(&server, serial);
|
||||
server_stop(&server);
|
||||
goto finally_destroy_frames;
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ finally_destroy_controller:
|
||||
finally_stop_decoder:
|
||||
decoder_stop(&decoder);
|
||||
// stop the server before decoder_join() to wake up the decoder
|
||||
server_stop(&server, serial);
|
||||
server_stop(&server);
|
||||
decoder_join(&decoder);
|
||||
finally_destroy_frames:
|
||||
frames_destroy(&frames);
|
||||
|
Reference in New Issue
Block a user