mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-08-03 14:49:29 +00:00
proper way to destroy and init installer
This commit is contained in:
parent
527d55b0c0
commit
d6e35b0090
3 changed files with 10 additions and 22 deletions
|
@ -5,7 +5,6 @@
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "command.h"
|
#include "command.h"
|
||||||
|
|
||||||
|
|
||||||
// NOTE(adopi) this can be more generic:
|
// NOTE(adopi) this can be more generic:
|
||||||
// it could be used with a command queue instead of a filename queue
|
// it could be used with a command queue instead of a filename queue
|
||||||
// then we would have a generic invoker (useful if we want to handle more async commands)
|
// then we would have a generic invoker (useful if we want to handle more async commands)
|
||||||
|
@ -82,9 +81,6 @@ void installer_destroy(struct installer *installer) {
|
||||||
SDL_DestroyMutex(installer->mutex);
|
SDL_DestroyMutex(installer->mutex);
|
||||||
apk_queue_destroy(&installer->queue);
|
apk_queue_destroy(&installer->queue);
|
||||||
SDL_free((void *) installer->serial);
|
SDL_free((void *) installer->serial);
|
||||||
installer->initialized = SDL_FALSE;
|
|
||||||
installer->stopped = SDL_FALSE;
|
|
||||||
installer->current_process = PROCESS_NONE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool installer_install_apk(struct installer *installer, const char *apk) {
|
SDL_bool installer_install_apk(struct installer *installer, const char *apk) {
|
||||||
|
|
|
@ -27,17 +27,6 @@ struct installer {
|
||||||
struct apk_queue queue;
|
struct apk_queue queue;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define INSTALLER_INITIALIZER { \
|
|
||||||
.serial = NULL, \
|
|
||||||
.thread = NULL, \
|
|
||||||
.mutex = NULL, \
|
|
||||||
.event_cond = NULL, \
|
|
||||||
.stopped = SDL_FALSE, \
|
|
||||||
.initialized = SDL_FALSE, \
|
|
||||||
.current_process = PROCESS_NONE \
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
SDL_bool installer_init(struct installer *installer, const char *serial);
|
SDL_bool installer_init(struct installer *installer, const char *serial);
|
||||||
void installer_destroy(struct installer *installer);
|
void installer_destroy(struct installer *installer);
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ static struct screen screen = SCREEN_INITIALIZER;
|
||||||
static struct frames frames;
|
static struct frames frames;
|
||||||
static struct decoder decoder;
|
static struct decoder decoder;
|
||||||
static struct controller controller;
|
static struct controller controller;
|
||||||
static struct installer installer = INSTALLER_INITIALIZER;
|
static struct installer installer;
|
||||||
|
|
||||||
static struct input_manager input_manager = {
|
static struct input_manager input_manager = {
|
||||||
.controller = &controller,
|
.controller = &controller,
|
||||||
|
@ -152,8 +152,11 @@ SDL_bool scrcpy(const char *serial, Uint16 local_port, Uint16 max_size, Uint32 b
|
||||||
goto finally_destroy_server;
|
goto finally_destroy_server;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(adopi) check failure
|
if (!installer_init(&installer,server.serial)) {
|
||||||
installer_init(&installer,server.serial);
|
ret = SDL_FALSE;
|
||||||
|
server_stop(&server);
|
||||||
|
goto finally_destroy_frames;
|
||||||
|
}
|
||||||
|
|
||||||
decoder_init(&decoder, &frames, device_socket);
|
decoder_init(&decoder, &frames, device_socket);
|
||||||
|
|
||||||
|
@ -191,13 +194,13 @@ finally_destroy_controller:
|
||||||
controller_destroy(&controller);
|
controller_destroy(&controller);
|
||||||
finally_stop_decoder:
|
finally_stop_decoder:
|
||||||
decoder_stop(&decoder);
|
decoder_stop(&decoder);
|
||||||
// stop installer
|
|
||||||
installer_stop(&installer);
|
|
||||||
installer_join(&installer);
|
|
||||||
installer_destroy(&installer);
|
|
||||||
// stop the server before decoder_join() to wake up the decoder
|
// stop the server before decoder_join() to wake up the decoder
|
||||||
server_stop(&server);
|
server_stop(&server);
|
||||||
decoder_join(&decoder);
|
decoder_join(&decoder);
|
||||||
|
finally_destroy_installer:
|
||||||
|
installer_stop(&installer);
|
||||||
|
installer_join(&installer);
|
||||||
|
installer_destroy(&installer);
|
||||||
finally_destroy_frames:
|
finally_destroy_frames:
|
||||||
frames_destroy(&frames);
|
frames_destroy(&frames);
|
||||||
finally_destroy_server:
|
finally_destroy_server:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue