Fixed some issues mentioned in comments

This commit is contained in:
CapsLock 2019-02-06 00:45:59 +01:00
parent 8d4ff03b7f
commit 3eaf39fda7
3 changed files with 17 additions and 8 deletions

View file

@ -215,7 +215,7 @@ static SDL_bool parse_args(struct args *args, int argc, char *argv[]) {
{"bit-rate", required_argument, NULL, 'b'},
{"crop", required_argument, NULL, 'c'},
{"fullscreen", no_argument, NULL, 'f'},
{"no-window", no_argument, NULL, 'n'},
{"no-window", no_argument, NULL, 'n'},
{"help", no_argument, NULL, 'h'},
{"max-size", required_argument, NULL, 'm'},
{"port", required_argument, NULL, 'p'},
@ -226,7 +226,7 @@ static SDL_bool parse_args(struct args *args, int argc, char *argv[]) {
{NULL, 0, NULL, 0 },
};
int c;
while ((c = getopt_long(argc, argv, "b:c:fnhm:p:r:s:tv", long_options, NULL)) != -1) {
while ((c = getopt_long(argc, argv, "b:c:fhm:np:r:s:tv", long_options, NULL)) != -1) {
switch (c) {
case 'b':
if (!parse_bit_rate(optarg, &args->bit_rate)) {
@ -239,9 +239,6 @@ static SDL_bool parse_args(struct args *args, int argc, char *argv[]) {
case 'f':
args->fullscreen = SDL_TRUE;
break;
case 'n':
args->no_window = SDL_TRUE;
break;
case 'h':
args->help = SDL_TRUE;
break;
@ -250,6 +247,9 @@ static SDL_bool parse_args(struct args *args, int argc, char *argv[]) {
return SDL_FALSE;
}
break;
case 'n':
args->no_window = SDL_TRUE;
break;
case 'p':
if (!parse_port(optarg, &args->port)) {
return SDL_FALSE;
@ -273,6 +273,11 @@ static SDL_bool parse_args(struct args *args, int argc, char *argv[]) {
}
}
if (args->no_window && args->record_filename == NULL) {
LOGE("Nothing to do: you asked to have no video feedback (by providing --no_window/-n argument) and did not specified a filename where video feed should be saved (--record/-r argument)");
return SDL_FALSE;
}
int index = optind;
if (index < argc) {
LOGE("Unexpected additional argument: %s", argv[index]);

View file

@ -82,6 +82,7 @@ static SDL_bool event_loop(void) {
if (!screen.has_frame) {
screen.has_frame = SDL_TRUE;
// this is the very first frame, show the window
if (!no_window) {
screen_show_window(&screen);
}
@ -145,6 +146,8 @@ static void wait_show_touches(process_t process) {
SDL_bool scrcpy(const struct scrcpy_options *options) {
SDL_bool send_frame_meta = !!options->record_filename;
no_window = options->no_window;
if (!server_start(&server, options->serial, options->port,
options->max_size, options->bit_rate, options->crop,
send_frame_meta)) {
@ -208,7 +211,6 @@ SDL_bool scrcpy(const struct scrcpy_options *options) {
}
decoder_init(&decoder, &frames, device_socket, rec);
// now we consumed the header values, the socket receives the video stream
// start the decoder
if (!decoder_start(&decoder)) {
@ -237,11 +239,11 @@ SDL_bool scrcpy(const struct scrcpy_options *options) {
show_touches_waited = SDL_TRUE;
}
if (options->fullscreen) {
if (!no_window && options->fullscreen) {
screen_switch_fullscreen(&screen);
}
no_window = options->no_window;
ret = event_loop();
LOGD("quit...");

View file

@ -16,6 +16,7 @@ struct screen {
struct size windowed_window_size;
SDL_bool has_frame;
SDL_bool fullscreen;
SDL_bool no_window;
};
#define SCREEN_INITIALIZER { \
@ -32,6 +33,7 @@ struct screen {
}, \
.has_frame = SDL_FALSE, \
.fullscreen = SDL_FALSE, \
.no_window = SDL_FALSE, \
}
// init SDL and set appropriate hints