Improve main() error handling
Parse the command-line arguments first, and do not ignore avformat network init failure. At the end, deinit the avformat network.
This commit is contained in:
parent
bb8afa9324
commit
de106747b6
1 changed files with 14 additions and 4 deletions
|
@ -47,9 +47,7 @@ int parse_args(struct args *args, int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
av_register_all();
|
int res;
|
||||||
avformat_network_init();
|
|
||||||
SDL_LogSetAllPriority(SDL_LOG_PRIORITY_DEBUG);
|
|
||||||
|
|
||||||
struct args args = {
|
struct args args = {
|
||||||
.serial = NULL,
|
.serial = NULL,
|
||||||
|
@ -59,5 +57,17 @@ int main(int argc, char *argv[]) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return show_screen(args.serial, args.port) ? 0 : 1;
|
av_register_all();
|
||||||
|
|
||||||
|
if (avformat_network_init()) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_LogSetAllPriority(SDL_LOG_PRIORITY_DEBUG);
|
||||||
|
|
||||||
|
res = show_screen(args.serial, args.port) ? 0 : 1;
|
||||||
|
|
||||||
|
avformat_network_deinit(); // ignore failure
|
||||||
|
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue