X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=futatabi%2Fmain.cpp;fp=futatabi%2Fmain.cpp;h=e6556d37aa91bff568111d4da8cadc4e609f8ac5;hb=9ffd4f03f314cc6e0254449593def95c9bc203d6;hp=4c54d332d24951b9118798b86c90ef3ab10e464b;hpb=a3b76e5ad9493b0af08fdcbe6d6b689d91496f85;p=nageru diff --git a/futatabi/main.cpp b/futatabi/main.cpp index 4c54d33..e6556d3 100644 --- a/futatabi/main.cpp +++ b/futatabi/main.cpp @@ -84,7 +84,7 @@ FrameOnDisk write_frame(int stream_idx, int64_t pts, const uint8_t *data, size_t FILE *fp = fopen(filename, "wb"); if (fp == nullptr) { perror(filename); - exit(1); + abort(); } lock_guard lock(frame_mu); @@ -109,26 +109,26 @@ FrameOnDisk write_frame(int stream_idx, int64_t pts, const uint8_t *data, size_t string serialized; if (!hdr.SerializeToString(&serialized)) { fprintf(stderr, "Frame header serialization failed.\n"); - exit(1); + abort(); } uint32_t len = htonl(serialized.size()); if (fwrite(frame_magic, frame_magic_len, 1, file.fp) != 1) { perror("fwrite"); - exit(1); + abort(); } if (fwrite(&len, sizeof(len), 1, file.fp) != 1) { perror("fwrite"); - exit(1); + abort(); } if (fwrite(serialized.data(), serialized.size(), 1, file.fp) != 1) { perror("fwrite"); - exit(1); + abort(); } off_t offset = ftell(file.fp); if (fwrite(data, size, 1, file.fp) != 1) { perror("fwrite"); - exit(1); + abort(); } fflush(file.fp); // No fsync(), though. We can accept losing a few frames. global_disk_space_estimator->report_write(filename, 8 + sizeof(len) + serialized.size() + size, pts); @@ -151,7 +151,7 @@ FrameOnDisk write_frame(int stream_idx, int64_t pts, const uint8_t *data, size_t // Start a new file next time. if (fclose(file.fp) != 0) { perror("fclose"); - exit(1); + abort(); } open_frame_files.erase(stream_idx); @@ -199,7 +199,7 @@ int main(int argc, char **argv) global_flags.stream_source = argv[optind]; } else { usage(); - exit(1); + abort(); } string frame_dir = global_flags.working_directory + "/frames"; @@ -208,7 +208,7 @@ int main(int argc, char **argv) fprintf(stderr, "%s does not exist, creating it.\n", frame_dir.c_str()); } else if (errno != EEXIST) { perror(global_flags.working_directory.c_str()); - exit(1); + abort(); } avformat_network_init(); @@ -237,7 +237,7 @@ int main(int argc, char **argv) global_share_widget = new QGLWidget(); if (!global_share_widget->isValid()) { fprintf(stderr, "Failed to initialize OpenGL. Futatabi needs at least OpenGL 4.5 to function properly.\n"); - exit(1); + abort(); } // Initialize Movit. @@ -246,7 +246,7 @@ int main(int argc, char **argv) QOpenGLContext *context = create_context(surface); if (!make_current(context, surface)) { printf("oops\n"); - exit(1); + abort(); } CHECK(movit::init_movit(MOVIT_SHADER_DIR, movit::MOVIT_DEBUG_OFF)); delete_context(context); @@ -284,7 +284,7 @@ void load_frame_file(const char *filename, const string &basename, unsigned file struct stat st; if (stat(filename, &st) == -1) { perror(filename); - exit(1); + abort(); } vector all_frames = db->load_frame_file(basename, st.st_size, filename_idx); @@ -302,7 +302,7 @@ void load_frame_file(const char *filename, const string &basename, unsigned file FILE *fp = fopen(filename, "rb"); if (fp == nullptr) { perror(filename); - exit(1); + abort(); } size_t magic_offset = 0; @@ -412,7 +412,7 @@ void load_existing_frames() if (de == nullptr) { if (errno != 0) { perror("readdir"); - exit(1); + abort(); } break; } @@ -424,7 +424,7 @@ void load_existing_frames() } if (progress.wasCanceled()) { - exit(1); + abort(); } } closedir(dir); @@ -442,7 +442,7 @@ void load_existing_frames() load_frame_file(frame_filenames[i].c_str(), frame_basenames[i], i, &db); progress.setValue(i + 3); if (progress.wasCanceled()) { - exit(1); + abort(); } }