]> git.sesse.net Git - nageru/commitdiff
On errors, abort() instead of exit(1); exit() in a multithreaded program just gives...
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 27 Mar 2019 23:56:20 +0000 (00:56 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 27 Mar 2019 23:56:20 +0000 (00:56 +0100)
41 files changed:
futatabi/db.cpp
futatabi/export.cpp
futatabi/flags.cpp
futatabi/flow.cpp
futatabi/flow_main.cpp
futatabi/frame_on_disk.cpp
futatabi/jpeg_frame_view.cpp
futatabi/main.cpp
futatabi/mainwindow.cpp
futatabi/player.cpp
futatabi/vaapi_jpeg_decoder.cpp
futatabi/video_stream.cpp
futatabi/vis.cpp
nageru/alsa_output.cpp
nageru/alsa_pool.cpp
nageru/analyzer.cpp
nageru/audio_encoder.cpp
nageru/audio_mixer.cpp
nageru/chroma_subsampler.cpp
nageru/decklink_capture.cpp
nageru/decklink_output.cpp
nageru/decklink_util.cpp
nageru/ffmpeg_capture.cpp
nageru/ffmpeg_util.cpp
nageru/flags.cpp
nageru/image_input.cpp
nageru/kaeru.cpp
nageru/main.cpp
nageru/mainwindow.cpp
nageru/mixer.cpp
nageru/mjpeg_encoder.cpp
nageru/quicksync_encoder.cpp
nageru/theme.cpp
nageru/v210_converter.cpp
nageru/x264_dynamic.cpp
nageru/x264_encoder.cpp
shared/bin2h.cpp
shared/context.cpp
shared/midi_device.cpp
shared/mux.cpp
shared/read_file.cpp

index 636b63ea54b8faf5b7d414738ef8775fbdf6a455..6764f84ce54aad90d1e82df50c5862d243b270da 100644 (file)
@@ -12,7 +12,7 @@ DB::DB(const string &filename)
        int ret = sqlite3_open(filename.c_str(), &db);
        if (ret != SQLITE_OK) {
                fprintf(stderr, "%s: %s\n", filename.c_str(), sqlite3_errmsg(db));
-               exit(1);
+               abort();
        }
 
        // Set an effectively infinite timeout for waiting for write locks;
@@ -20,7 +20,7 @@ DB::DB(const string &filename)
        ret = sqlite3_busy_timeout(db, 3600000);
        if (ret != SQLITE_OK) {
                fprintf(stderr, "sqlite3_busy_timeout: %s\n", sqlite3_errmsg(db));
-               exit(1);
+               abort();
        }
 
        sqlite3_exec(db, R"(
@@ -69,7 +69,7 @@ StateProto DB::get_state()
        int ret = sqlite3_prepare_v2(db, "SELECT state FROM state", -1, &stmt, 0);
        if (ret != SQLITE_OK) {
                fprintf(stderr, "SELECT prepare: %s\n", sqlite3_errmsg(db));
-               exit(1);
+               abort();
        }
 
        ret = sqlite3_step(stmt);
@@ -77,17 +77,17 @@ StateProto DB::get_state()
                bool ok = state.ParseFromArray(sqlite3_column_blob(stmt, 0), sqlite3_column_bytes(stmt, 0));
                if (!ok) {
                        fprintf(stderr, "State in database is corrupted!\n");
-                       exit(1);
+                       abort();
                }
        } else if (ret != SQLITE_DONE) {
                fprintf(stderr, "SELECT step: %s\n", sqlite3_errmsg(db));
-               exit(1);
+               abort();
        }
 
        ret = sqlite3_finalize(stmt);
        if (ret != SQLITE_OK) {
                fprintf(stderr, "SELECT finalize: %s\n", sqlite3_errmsg(db));
-               exit(1);
+               abort();
        }
 
        return state;
@@ -101,14 +101,14 @@ void DB::store_state(const StateProto &state)
        int ret = sqlite3_exec(db, "BEGIN", nullptr, nullptr, nullptr);
        if (ret != SQLITE_OK) {
                fprintf(stderr, "BEGIN: %s\n", sqlite3_errmsg(db));
-               exit(1);
+               abort();
        }
 
        sqlite3_stmt *stmt;
        ret = sqlite3_prepare_v2(db, "REPLACE INTO state VALUES (?)", -1, &stmt, 0);
        if (ret != SQLITE_OK) {
                fprintf(stderr, "REPLACE prepare: %s\n", sqlite3_errmsg(db));
-               exit(1);
+               abort();
        }
 
        sqlite3_bind_blob(stmt, 1, serialized.data(), serialized.size(), SQLITE_STATIC);
@@ -116,19 +116,19 @@ void DB::store_state(const StateProto &state)
        ret = sqlite3_step(stmt);
        if (ret == SQLITE_ROW) {
                fprintf(stderr, "REPLACE step: %s\n", sqlite3_errmsg(db));
-               exit(1);
+               abort();
        }
 
        ret = sqlite3_finalize(stmt);
        if (ret != SQLITE_OK) {
                fprintf(stderr, "REPLACE finalize: %s\n", sqlite3_errmsg(db));
-               exit(1);
+               abort();
        }
 
        ret = sqlite3_exec(db, "COMMIT", nullptr, nullptr, nullptr);
        if (ret != SQLITE_OK) {
                fprintf(stderr, "COMMIT: %s\n", sqlite3_errmsg(db));
-               exit(1);
+               abort();
        }
 }
 
@@ -140,7 +140,7 @@ SettingsProto DB::get_settings()
        int ret = sqlite3_prepare_v2(db, "SELECT settings FROM settings", -1, &stmt, 0);
        if (ret != SQLITE_OK) {
                fprintf(stderr, "SELECT prepare: %s\n", sqlite3_errmsg(db));
-               exit(1);
+               abort();
        }
 
        ret = sqlite3_step(stmt);
@@ -148,17 +148,17 @@ SettingsProto DB::get_settings()
                bool ok = settings.ParseFromArray(sqlite3_column_blob(stmt, 0), sqlite3_column_bytes(stmt, 0));
                if (!ok) {
                        fprintf(stderr, "State in database is corrupted!\n");
-                       exit(1);
+                       abort();
                }
        } else if (ret != SQLITE_DONE) {
                fprintf(stderr, "SELECT step: %s\n", sqlite3_errmsg(db));
-               exit(1);
+               abort();
        }
 
        ret = sqlite3_finalize(stmt);
        if (ret != SQLITE_OK) {
                fprintf(stderr, "SELECT finalize: %s\n", sqlite3_errmsg(db));
-               exit(1);
+               abort();
        }
 
        return settings;
@@ -172,14 +172,14 @@ void DB::store_settings(const SettingsProto &settings)
        int ret = sqlite3_exec(db, "BEGIN", nullptr, nullptr, nullptr);
        if (ret != SQLITE_OK) {
                fprintf(stderr, "BEGIN: %s\n", sqlite3_errmsg(db));
-               exit(1);
+               abort();
        }
 
        sqlite3_stmt *stmt;
        ret = sqlite3_prepare_v2(db, "REPLACE INTO settings VALUES (?)", -1, &stmt, 0);
        if (ret != SQLITE_OK) {
                fprintf(stderr, "REPLACE prepare: %s\n", sqlite3_errmsg(db));
-               exit(1);
+               abort();
        }
 
        sqlite3_bind_blob(stmt, 1, serialized.data(), serialized.size(), SQLITE_STATIC);
@@ -187,19 +187,19 @@ void DB::store_settings(const SettingsProto &settings)
        ret = sqlite3_step(stmt);
        if (ret == SQLITE_ROW) {
                fprintf(stderr, "REPLACE step: %s\n", sqlite3_errmsg(db));
-               exit(1);
+               abort();
        }
 
        ret = sqlite3_finalize(stmt);
        if (ret != SQLITE_OK) {
                fprintf(stderr, "REPLACE finalize: %s\n", sqlite3_errmsg(db));
-               exit(1);
+               abort();
        }
 
        ret = sqlite3_exec(db, "COMMIT", nullptr, nullptr, nullptr);
        if (ret != SQLITE_OK) {
                fprintf(stderr, "COMMIT: %s\n", sqlite3_errmsg(db));
-               exit(1);
+               abort();
        }
 }
 
@@ -211,7 +211,7 @@ vector<DB::FrameOnDiskAndStreamIdx> DB::load_frame_file(const string &filename,
        int ret = sqlite3_prepare_v2(db, "SELECT frames FROM filev2 WHERE filename=? AND size=?", -1, &stmt, 0);
        if (ret != SQLITE_OK) {
                fprintf(stderr, "SELECT prepare: %s\n", sqlite3_errmsg(db));
-               exit(1);
+               abort();
        }
 
        sqlite3_bind_text(stmt, 1, filename.data(), filename.size(), SQLITE_STATIC);
@@ -222,17 +222,17 @@ vector<DB::FrameOnDiskAndStreamIdx> DB::load_frame_file(const string &filename,
                bool ok = file_contents.ParseFromArray(sqlite3_column_blob(stmt, 0), sqlite3_column_bytes(stmt, 0));
                if (!ok) {
                        fprintf(stderr, "Frame list in database is corrupted!\n");
-                       exit(1);
+                       abort();
                }
        } else if (ret != SQLITE_DONE) {
                fprintf(stderr, "SELECT step: %s\n", sqlite3_errmsg(db));
-               exit(1);
+               abort();
        }
 
        ret = sqlite3_finalize(stmt);
        if (ret != SQLITE_OK) {
                fprintf(stderr, "SELECT finalize: %s\n", sqlite3_errmsg(db));
-               exit(1);
+               abort();
        }
 
        vector<FrameOnDiskAndStreamIdx> frames;
@@ -256,7 +256,7 @@ void DB::store_frame_file(const string &filename, size_t size, const vector<Fram
        int ret = sqlite3_exec(db, "BEGIN", nullptr, nullptr, nullptr);
        if (ret != SQLITE_OK) {
                fprintf(stderr, "BEGIN: %s\n", sqlite3_errmsg(db));
-               exit(1);
+               abort();
        }
 
        // Delete any existing instances with this filename.
@@ -290,7 +290,7 @@ void DB::store_frame_file(const string &filename, size_t size, const vector<Fram
        ret = sqlite3_prepare_v2(db, "REPLACE INTO filev2 (filename, size, frames) VALUES (?, ?, ?)", -1, &stmt, 0);
        if (ret != SQLITE_OK) {
                fprintf(stderr, "INSERT prepare: %s\n", sqlite3_errmsg(db));
-               exit(1);
+               abort();
        }
 
        sqlite3_bind_text(stmt, 1, filename.data(), filename.size(), SQLITE_STATIC);
@@ -300,20 +300,20 @@ void DB::store_frame_file(const string &filename, size_t size, const vector<Fram
        ret = sqlite3_step(stmt);
        if (ret == SQLITE_ROW) {
                fprintf(stderr, "REPLACE step: %s\n", sqlite3_errmsg(db));
-               exit(1);
+               abort();
        }
 
        ret = sqlite3_finalize(stmt);
        if (ret != SQLITE_OK) {
                fprintf(stderr, "REPLACE finalize: %s\n", sqlite3_errmsg(db));
-               exit(1);
+               abort();
        }
 
        // Commit.
        ret = sqlite3_exec(db, "COMMIT", nullptr, nullptr, nullptr);
        if (ret != SQLITE_OK) {
                fprintf(stderr, "COMMIT: %s\n", sqlite3_errmsg(db));
-               exit(1);
+               abort();
        }
 }
 
@@ -322,7 +322,7 @@ void DB::clean_unused_frame_files(const vector<string> &used_filenames)
        int ret = sqlite3_exec(db, "BEGIN", nullptr, nullptr, nullptr);
        if (ret != SQLITE_OK) {
                fprintf(stderr, "BEGIN: %s\n", sqlite3_errmsg(db));
-               exit(1);
+               abort();
        }
 
        ret = sqlite3_exec(db, R"(
@@ -332,7 +332,7 @@ void DB::clean_unused_frame_files(const vector<string> &used_filenames)
 
        if (ret != SQLITE_OK) {
                fprintf(stderr, "CREATE TEMPORARY TABLE: %s\n", sqlite3_errmsg(db));
-               exit(1);
+               abort();
        }
 
        // Insert the new rows.
@@ -340,7 +340,7 @@ void DB::clean_unused_frame_files(const vector<string> &used_filenames)
        ret = sqlite3_prepare_v2(db, "INSERT INTO used_filenames (filename) VALUES (?)", -1, &stmt, 0);
        if (ret != SQLITE_OK) {
                fprintf(stderr, "INSERT prepare: %s\n", sqlite3_errmsg(db));
-               exit(1);
+               abort();
        }
 
        for (const string &filename : used_filenames) {
@@ -349,20 +349,20 @@ void DB::clean_unused_frame_files(const vector<string> &used_filenames)
                ret = sqlite3_step(stmt);
                if (ret == SQLITE_ROW) {
                        fprintf(stderr, "INSERT step: %s\n", sqlite3_errmsg(db));
-                       exit(1);
+                       abort();
                }
 
                ret = sqlite3_reset(stmt);
                if (ret == SQLITE_ROW) {
                        fprintf(stderr, "INSERT reset: %s\n", sqlite3_errmsg(db));
-                       exit(1);
+                       abort();
                }
        }
 
        ret = sqlite3_finalize(stmt);
        if (ret != SQLITE_OK) {
                fprintf(stderr, "INSERT finalize: %s\n", sqlite3_errmsg(db));
-               exit(1);
+               abort();
        }
 
        ret = sqlite3_exec(db, R"(
@@ -372,7 +372,7 @@ void DB::clean_unused_frame_files(const vector<string> &used_filenames)
 
        if (ret != SQLITE_OK) {
                fprintf(stderr, "DELETE: %s\n", sqlite3_errmsg(db));
-               exit(1);
+               abort();
        }
 
        ret = sqlite3_exec(db, R"(
@@ -382,13 +382,13 @@ void DB::clean_unused_frame_files(const vector<string> &used_filenames)
 
        if (ret != SQLITE_OK) {
                fprintf(stderr, "DROP TABLE: %s\n", sqlite3_errmsg(db));
-               exit(1);
+               abort();
        }
 
        // Commit.
        ret = sqlite3_exec(db, "COMMIT", nullptr, nullptr, nullptr);
        if (ret != SQLITE_OK) {
                fprintf(stderr, "COMMIT: %s\n", sqlite3_errmsg(db));
-               exit(1);
+               abort();
        }
 }
index a865ac6e9369331a3806ef430c70c82b12d33392..5b8da136370a7dd8b649bce379e436daa7e8b176 100644 (file)
@@ -104,7 +104,7 @@ void export_multitrack_clip(const string &filename, const Clip &clip)
                AVStream *avstream_video = avformat_new_stream(avctx, nullptr);
                if (avstream_video == nullptr) {
                        fprintf(stderr, "avformat_new_stream() failed\n");
-                       exit(1);
+                       abort();
                }
                avstream_video->time_base = AVRational{ 1, TIMEBASE };
                avstream_video->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
index fa1fe6ec5878177a56472bd449ae343985b7a097..eea7c0700358f2752318e9d0d18fa56eff536d47 100644 (file)
@@ -85,7 +85,7 @@ void parse_flags(int argc, char *const argv[])
                                global_flags.output_framerate = num;
                        } else {
                                fprintf(stderr, "Invalid frame rate given (must be on the form N or N/M)\n");
-                               exit(1);
+                               abort();
                        }
                        break;
                }
@@ -123,19 +123,19 @@ void parse_flags(int argc, char *const argv[])
                        fprintf(stderr, "Unknown option '%s'\n", argv[option_index]);
                        fprintf(stderr, "\n");
                        usage();
-                       exit(1);
+                       abort();
                }
        }
 
        if (global_flags.interpolation_quality < 0 || global_flags.interpolation_quality > 4) {
                fprintf(stderr, "Interpolation quality must be 0, 1, 2, 3 or 4.\n");
                usage();
-               exit(1);
+               abort();
        }
        if (global_flags.cue_in_point_padding_seconds < 0.0 ||
            global_flags.cue_out_point_padding_seconds < 0.0) {
                fprintf(stderr, "Cue point padding cannot be negative.\n");
                usage();
-               exit(1);
+               abort();
        }
 }
index 90317da70a5ab62d4b72a9036f374cb24a50628f..8ae7bfc259fcfd9ddc3c4ea2b52cf11787b43ddf 100644 (file)
@@ -83,7 +83,7 @@ GLuint compile_shader(const string &shader_src, GLenum type)
                }
 
                fprintf(stderr, "Failed to compile shader:\n%s\n", src_with_lines.c_str());
-               exit(1);
+               abort();
        }
 
        return obj;
@@ -101,7 +101,7 @@ GLuint link_program(GLuint vs_obj, GLuint fs_obj)
                GLchar error_log[1024] = { 0 };
                glGetProgramInfoLog(program, 1024, nullptr, error_log);
                fprintf(stderr, "Error linking program: %s\n", error_log);
-               exit(1);
+               abort();
        }
        return program;
 }
index ef481a04b4ba8e7360214d442cdd3e0f05d44d2b..ef3b5bf976a8417f22b36ea995763987701a3edf 100644 (file)
@@ -54,7 +54,7 @@ GLuint load_texture(const char *filename, unsigned *width_ret, unsigned *height_
        SDL_Surface *surf = IMG_Load(filename);
        if (surf == nullptr) {
                fprintf(stderr, "IMG_Load(%s): %s\n", filename, IMG_GetError());
-               exit(1);
+               abort();
        }
 
        // For whatever reason, SDL doesn't support converting to YUV surfaces
@@ -62,7 +62,7 @@ GLuint load_texture(const char *filename, unsigned *width_ret, unsigned *height_
        SDL_Surface *rgb_surf = SDL_ConvertSurfaceFormat(surf, SDL_PIXELFORMAT_RGBA32, /*flags=*/0);
        if (rgb_surf == nullptr) {
                fprintf(stderr, "SDL_ConvertSurfaceFormat(%s): %s\n", filename, SDL_GetError());
-               exit(1);
+               abort();
        }
 
        SDL_FreeSurface(surf);
@@ -234,7 +234,7 @@ void compute_flow_only(int argc, char **argv, int optind)
        if (width1 != width2 || height1 != height2) {
                fprintf(stderr, "Image dimensions don't match (%dx%d versus %dx%d)\n",
                        width1, height1, width2, height2);
-               exit(1);
+               abort();
        }
 
        // Move them into an array texture, since that's how the rest of the code
@@ -298,7 +298,7 @@ void compute_flow_only(int argc, char **argv, int optind)
                if (width != width1 || height != height1) {
                        fprintf(stderr, "%s: Image dimensions don't match (%dx%d versus %dx%d)\n",
                                filename0, width, height, width1, height1);
-                       exit(1);
+                       abort();
                }
                glCopyImageSubData(tex0, GL_TEXTURE_2D, 0, 0, 0, 0, image_tex, GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, width1, height1, 1);
                glDeleteTextures(1, &tex0);
@@ -307,7 +307,7 @@ void compute_flow_only(int argc, char **argv, int optind)
                if (width != width1 || height != height1) {
                        fprintf(stderr, "%s: Image dimensions don't match (%dx%d versus %dx%d)\n",
                                filename1, width, height, width1, height1);
-                       exit(1);
+                       abort();
                }
                glCopyImageSubData(tex1, GL_TEXTURE_2D, 0, 0, 0, 0, image_tex, GL_TEXTURE_2D_ARRAY, 0, 0, 0, 1, width1, height1, 1);
                glDeleteTextures(1, &tex1);
@@ -347,7 +347,7 @@ void interpolate_image(int argc, char **argv, int optind)
        if (width1 != width2 || height1 != height2) {
                fprintf(stderr, "Image dimensions don't match (%dx%d versus %dx%d)\n",
                        width1, height1, width2, height2);
-               exit(1);
+               abort();
        }
 
        // Move them into an array texture, since that's how the rest of the code
@@ -462,13 +462,13 @@ int main(int argc, char **argv)
                        break;
                default:
                        fprintf(stderr, "Unknown option '%s'\n", argv[option_index]);
-                       exit(1);
+                       abort();
                };
        }
 
        if (SDL_Init(SDL_INIT_EVERYTHING) == -1) {
                fprintf(stderr, "SDL_Init failed: %s\n", SDL_GetError());
-               exit(1);
+               abort();
        }
        SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
        SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0);
index c3e3b4db496e4902e7239f61b2d53c98b57e7825..971cafd5d9c7d8b89ee5a208fa6c91a2539803e7 100644 (file)
@@ -66,7 +66,7 @@ string FrameReader::read_frame(FrameOnDisk frame)
                fd = open(filename.c_str(), O_RDONLY);
                if (fd == -1) {
                        perror(filename.c_str());
-                       exit(1);
+                       abort();
                }
 
                // We want readahead. (Ignore errors.)
@@ -83,7 +83,7 @@ string FrameReader::read_frame(FrameOnDisk frame)
                int ret = pread(fd, &str[offset], frame.size - offset, frame.offset + offset);
                if (ret <= 0) {
                        perror("pread");
-                       exit(1);
+                       abort();
                }
 
                offset += ret;
index d35964ce4c0709861d68b5cbfdcee18e2c9e1643..198affd38ecd5324cc58977dc75c94d2741ac930 100644 (file)
@@ -127,7 +127,7 @@ shared_ptr<Frame> decode_jpeg(const string &jpeg)
                        dinfo.comp_info[0].h_samp_factor, dinfo.comp_info[0].v_samp_factor,
                        dinfo.comp_info[1].h_samp_factor, dinfo.comp_info[1].v_samp_factor,
                        dinfo.comp_info[2].h_samp_factor, dinfo.comp_info[2].v_samp_factor);
-               exit(1);
+               abort();
        }
        dinfo.raw_data_out = true;
 
index 4c54d332d24951b9118798b86c90ef3ab10e464b..e6556d37aa91bff568111d4da8cadc4e609f8ac5 100644 (file)
@@ -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<mutex> 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<DB::FrameOnDiskAndStreamIdx> 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();
                }
        }
 
index 05ea5821a090451bf79fe8f8f80255d7e7e462c4..dfc2ea5b2ec5514158d4f11bad9d684574ed1342 100644 (file)
@@ -289,7 +289,7 @@ MainWindow::MainWindow()
                if (!load_midi_mapping_from_file(global_flags.midi_mapping_filename, &midi_mapping)) {
                        fprintf(stderr, "Couldn't load MIDI mapping '%s'; exiting.\n",
                                global_flags.midi_mapping_filename.c_str());
-                       exit(1);
+                       abort();
                }
                midi_mapper.set_midi_mapping(midi_mapping);
        }
index 687afd013f13033ddcfa3f1af161fa8bbf361286..611f0abce4151ceff3a9adc8e51da2dc14e987b3 100644 (file)
@@ -35,7 +35,7 @@ void Player::thread_func(AVFormatContext *file_avctx)
        QOpenGLContext *context = create_context(surface);
        if (!make_current(context, surface)) {
                printf("oops\n");
-               exit(1);
+               abort();
        }
 
        check_error();
index 1d0f771cddb2d2f27d414b7393320df44799b51b..d18a8735c11a23853ea6109b340c031dfee2a19c 100644 (file)
@@ -41,7 +41,7 @@ static mutex va_resources_mutex;
 #define CHECK_VASTATUS(va_status, func) \
        if (va_status != VA_STATUS_SUCCESS) { \
                fprintf(stderr, "%s:%d (%s) failed with %d\n", __func__, __LINE__, func, va_status); \
-               exit(1); \
+               abort(); \
        }
 
 #define CHECK_VASTATUS_RET(va_status, func) \
index 290168ea834a63f9dfc304c551433dfabe65ad5d..4b0336ce3b8384a68673e7a5cf6fd7a0f603e9b2 100644 (file)
@@ -600,7 +600,7 @@ void VideoStream::encode_thread_func()
        bool ok = make_current(context, surface);
        if (!ok) {
                fprintf(stderr, "Video stream couldn't get an OpenGL context\n");
-               exit(1);
+               abort();
        }
 
        while (!should_quit) {
index c67a0ccec6278a72b1feed7f4dd57b0e86ddf5eb..5585f6ad3bb3d0ed4037cc174a3d22de6741a39d 100644 (file)
@@ -12,7 +12,7 @@ int main(int argc, char **argv)
 {
        if (argc != 3) {
                fprintf(stderr, "Usage: ./vis input.flo out.ppm\n");
-               exit(1);
+               abort();
        }
 
        Flow flow = read_flow(argv[1]);
index 7dd10244b094d83b9f93c65af0b8e87dc4e5a5c6..bc2c89c761ea5a13817054ffb10b4fab7a594279 100644 (file)
@@ -14,7 +14,7 @@ void die_on_error(const char *func_name, int err)
 {
        if (err < 0) {
                fprintf(stderr, "%s: %s\n", func_name, snd_strerror(err));
-               exit(1);
+               abort();
        }
 }
 
@@ -74,7 +74,7 @@ try_again:
                ret = 0;
        } else if (ret < 0) {
                fprintf(stderr, "error: snd_pcm_writei() returned '%s'\n", snd_strerror(ret));
-               exit(1);
+               abort();
        } else if (ret > 0) {
                buffer.erase(buffer.begin(), buffer.begin() + ret * num_channels);
        }
index 978f236886256e529e448c6dbcd37c53be951bfc..bdff5af09917b0c13a79bc5453b3e255ffd02ff4 100644 (file)
@@ -44,7 +44,7 @@ ALSAPool::~ALSAPool()
        const uint64_t one = 1;
        if (write(should_quit_fd, &one, sizeof(one)) != sizeof(one)) {
                perror("write(should_quit_fd)");
-               exit(1);
+               abort();
        }
        inotify_thread.join();
 
index bdb80bc31b52c46d98ee4540220c606e706fd594..b08af1926f0165adcb85faebf97f20d001c06fbd 100644 (file)
@@ -41,7 +41,7 @@ Analyzer::Analyzer()
        context = create_context(surface);
        if (!make_current(context, surface)) {
                printf("oops\n");
-               exit(1);
+               abort();
        }
 
        grab_timer.setSingleShot(true);
@@ -96,7 +96,7 @@ void Analyzer::mixer_shutting_down()
 
        if (!make_current(context, surface)) {
                printf("oops\n");
-               exit(1);
+               abort();
        }
        glDeleteBuffers(1, &pbo);
        check_error();
@@ -111,7 +111,7 @@ void Analyzer::grab_clicked()
 
        if (!make_current(context, surface)) {
                printf("oops\n");
-               exit(1);
+               abort();
        }
 
        Mixer::DisplayFrame frame;
index a2ab14b60ddcc2dac567f8f0fc0b8e82931a09c5..0f7f9aac8c957e3d686c87daa863719d102982d1 100644 (file)
@@ -32,7 +32,7 @@ AudioEncoder::AudioEncoder(const string &codec_name, int bit_rate, const AVOutpu
        AVCodec *codec = avcodec_find_encoder_by_name(codec_name.c_str());
        if (codec == nullptr) {
                fprintf(stderr, "ERROR: Could not find codec '%s'\n", codec_name.c_str());
-               exit(1);
+               abort();
        }
 
        ctx = avcodec_alloc_context3(codec);
@@ -47,7 +47,7 @@ AudioEncoder::AudioEncoder(const string &codec_name, int bit_rate, const AVOutpu
        }
        if (avcodec_open2(ctx, codec, NULL) < 0) {
                fprintf(stderr, "Could not open codec '%s'\n", codec_name.c_str());
-               exit(1);
+               abort();
        }
 
        resampler = swr_alloc_set_opts(nullptr,
@@ -61,12 +61,12 @@ AudioEncoder::AudioEncoder(const string &codec_name, int bit_rate, const AVOutpu
                                       /*log_ctx=*/nullptr);
        if (resampler == nullptr) {
                fprintf(stderr, "Allocating resampler failed.\n");
-               exit(1);
+               abort();
        }
 
        if (swr_init(resampler) < 0) {
                fprintf(stderr, "Could not open resample context.\n");
-               exit(1);
+               abort();
        }
 
        audio_frame = av_frame_alloc();
@@ -116,18 +116,18 @@ void AudioEncoder::encode_audio_one_frame(const float *audio, size_t num_samples
 
        if (av_samples_alloc(audio_frame->data, nullptr, 2, num_samples, ctx->sample_fmt, 0) < 0) {
                fprintf(stderr, "Could not allocate %zu samples.\n", num_samples);
-               exit(1);
+               abort();
        }
 
        if (swr_convert(resampler, audio_frame->data, num_samples, reinterpret_cast<const uint8_t **>(&audio), num_samples) < 0) {
                fprintf(stderr, "Audio conversion failed.\n");
-               exit(1);
+               abort();
        }
 
        int err = avcodec_send_frame(ctx, audio_frame);
        if (err < 0) {
                fprintf(stderr, "avcodec_send_frame() failed with error %d\n", err);
-               exit(1);
+               abort();
        }
 
        for ( ;; ) {  // Termination condition within loop.
@@ -147,7 +147,7 @@ void AudioEncoder::encode_audio_one_frame(const float *audio, size_t num_samples
                        break;
                } else {
                        fprintf(stderr, "avcodec_receive_frame() failed with error %d\n", err);
-                       exit(1);
+                       abort();
                }
        }
 
@@ -183,7 +183,7 @@ void AudioEncoder::encode_last_audio()
                                break;
                        } else {
                                fprintf(stderr, "avcodec_receive_frame() failed with error %d\n", err);
-                               exit(1);
+                               abort();
                        }
                }
        }
index 891fb227c779f4917201345718b242bc3f71fd39..9b588d704d63303dccd354a40bafcbc7431f6d69 100644 (file)
@@ -206,7 +206,7 @@ AudioMixer::AudioMixer(unsigned num_capture_cards, unsigned num_ffmpeg_inputs)
                                                  &new_input_mapping)) {
                        fprintf(stderr, "Failed to load input mapping from '%s', exiting.\n",
                                global_flags.input_mapping_filename.c_str());
-                       exit(1);
+                       abort();
                }
                set_input_mapping(new_input_mapping);
        } else {
index 14cb4d29641de6a149bf5a89189ea979bde67dc8..ff9d919c5133f8f8171c46728dbab114a75c3d28 100644 (file)
@@ -140,7 +140,7 @@ ChromaSubsampler::ChromaSubsampler(ResourcePool *resource_pool)
                        GLchar error_log[1024] = {0};
                        glGetProgramInfoLog(v210_program_num, 1024, nullptr, error_log);
                        fprintf(stderr, "Error linking program: %s\n", error_log);
-                       exit(1);
+                       abort();
                }
 
                v210_in_y_pos = glGetUniformLocation(v210_program_num, "in_y");
index f7016dce7c07f607455481c9d00a34e2d379ac99..ab5e1ec818f720c6fba4dc35935c1986df1aaaba 100644 (file)
@@ -63,20 +63,20 @@ DeckLinkCapture::DeckLinkCapture(IDeckLink *card, int card_index)
 
        if (card->QueryInterface(IID_IDeckLinkInput, (void**)&input) != S_OK) {
                fprintf(stderr, "Card %d has no inputs\n", card_index);
-               exit(1);
+               abort();
        }
 
        IDeckLinkAttributes *attr;
        if (card->QueryInterface(IID_IDeckLinkAttributes, (void**)&attr) != S_OK) {
                fprintf(stderr, "Card %d has no attributes\n", card_index);
-               exit(1);
+               abort();
        }
 
        // Get the list of available video inputs.
        int64_t video_input_mask;
        if (attr->GetInt(BMDDeckLinkVideoInputConnections, &video_input_mask) != S_OK) {
                fprintf(stderr, "Failed to enumerate video inputs for card %d\n", card_index);
-               exit(1);
+               abort();
        }
        const vector<pair<BMDVideoConnection, string>> video_input_types = {
                { bmdVideoConnectionSDI, "SDI" },
@@ -96,7 +96,7 @@ DeckLinkCapture::DeckLinkCapture(IDeckLink *card, int card_index)
        int64_t audio_input_mask;
        if (attr->GetInt(BMDDeckLinkAudioInputConnections, &audio_input_mask) != S_OK) {
                fprintf(stderr, "Failed to enumerate audio inputs for card %d\n", card_index);
-               exit(1);
+               abort();
        }
        const vector<pair<BMDAudioConnection, string>> audio_input_types = {
                { bmdAudioConnectionEmbedded, "Embedded" },
@@ -134,7 +134,7 @@ DeckLinkCapture::DeckLinkCapture(IDeckLink *card, int card_index)
        /* Set up the video and audio sources. */
        if (card->QueryInterface(IID_IDeckLinkConfiguration, (void**)&config) != S_OK) {
                fprintf(stderr, "Failed to get configuration interface for card %d\n", card_index);
-               exit(1);
+               abort();
        }
 
        BMDVideoConnection connection = pick_default_video_connection(card, BMDDeckLinkVideoInputConnections, card_index);
@@ -145,7 +145,7 @@ DeckLinkCapture::DeckLinkCapture(IDeckLink *card, int card_index)
        IDeckLinkDisplayModeIterator *mode_it;
        if (input->GetDisplayModeIterator(&mode_it) != S_OK) {
                fprintf(stderr, "Failed to enumerate display modes for card %d\n", card_index);
-               exit(1);
+               abort();
        }
 
        video_modes = summarize_video_modes(mode_it, card_index);
@@ -198,7 +198,7 @@ HRESULT STDMETHODCALLTYPE DeckLinkCapture::VideoInputFormatChanged(
        }
        if (display_mode->GetFrameRate(&frame_duration, &time_scale) != S_OK) {
                fprintf(stderr, "Could not get new frame rate\n");
-               exit(1);
+               abort();
        }
        field_dominance = display_mode->GetFieldDominance();
        return S_OK;
@@ -326,16 +326,16 @@ void DeckLinkCapture::start_bm_capture()
        }
        if (input->EnableVideoInput(current_video_mode, pixel_format_to_bmd(current_pixel_format), supports_autodetect ? bmdVideoInputEnableFormatDetection : 0) != S_OK) {
                fprintf(stderr, "Failed to set video mode 0x%04x for card %d\n", current_video_mode, card_index);
-               exit(1);
+               abort();
        }
        if (input->EnableAudioInput(48000, bmdAudioSampleType32bitInteger, 2) != S_OK) {
                fprintf(stderr, "Failed to enable audio input for card %d\n", card_index);
-               exit(1);
+               abort();
        }
 
        if (input->StartStreams() != S_OK) {
                fprintf(stderr, "StartStreams failed\n");
-               exit(1);
+               abort();
        }
        running = true;
 }
@@ -348,7 +348,7 @@ void DeckLinkCapture::stop_dequeue_thread()
        HRESULT result = input->StopStreams();
        if (result != S_OK) {
                fprintf(stderr, "StopStreams failed with error 0x%x\n", result);
-               exit(1);
+               abort();
        }
 
        // We could call DisableVideoInput() and DisableAudioInput() here,
@@ -363,11 +363,11 @@ void DeckLinkCapture::set_video_mode(uint32_t video_mode_id)
        if (running) {
                if (input->PauseStreams() != S_OK) {
                        fprintf(stderr, "PauseStreams failed\n");
-                       exit(1);
+                       abort();
                }
                if (input->FlushStreams() != S_OK) {
                        fprintf(stderr, "FlushStreams failed\n");
-                       exit(1);
+                       abort();
                }
        }
 
@@ -376,7 +376,7 @@ void DeckLinkCapture::set_video_mode(uint32_t video_mode_id)
        if (running) {
                if (input->StartStreams() != S_OK) {
                        fprintf(stderr, "StartStreams failed\n");
-                       exit(1);
+                       abort();
                }
        }
 }
@@ -393,17 +393,17 @@ void DeckLinkCapture::set_video_mode_no_restart(uint32_t video_mode_id)
        IDeckLinkDisplayMode *display_mode;
        if (input->DoesSupportVideoMode(video_mode_id, pixel_format_to_bmd(current_pixel_format), /*flags=*/0, &support, &display_mode)) {
                fprintf(stderr, "Failed to query display mode for card %d\n", card_index);
-               exit(1);
+               abort();
        }
 
        if (support == bmdDisplayModeNotSupported) {
                fprintf(stderr, "Card %d does not support display mode\n", card_index);
-               exit(1);
+               abort();
        }
 
        if (display_mode->GetFrameRate(&frame_duration, &time_scale) != S_OK) {
                fprintf(stderr, "Could not get frame rate for card %d\n", card_index);
-               exit(1);
+               abort();
        }
 
        field_dominance = display_mode->GetFieldDominance();
@@ -411,7 +411,7 @@ void DeckLinkCapture::set_video_mode_no_restart(uint32_t video_mode_id)
        if (running) {
                if (input->EnableVideoInput(video_mode_id, pixel_format_to_bmd(current_pixel_format), supports_autodetect ? bmdVideoInputEnableFormatDetection : 0) != S_OK) {
                        fprintf(stderr, "Failed to set video mode 0x%04x for card %d\n", video_mode_id, card_index);
-                       exit(1);
+                       abort();
                }
        }
 
@@ -422,7 +422,7 @@ void DeckLinkCapture::set_video_input(uint32_t video_input_id)
 {
        if (config->SetInt(bmdDeckLinkConfigVideoInputConnection, video_input_id) != S_OK) {
                fprintf(stderr, "Failed to set video input connection for card %d\n", card_index);
-               exit(1);
+               abort();
        }
 
        current_video_input = video_input_id;
@@ -432,7 +432,7 @@ void DeckLinkCapture::set_audio_input(uint32_t audio_input_id)
 {
        if (config->SetInt(bmdDeckLinkConfigAudioInputConnection, audio_input_id) != S_OK) {
                fprintf(stderr, "Failed to set audio input connection for card %d\n", card_index);
-               exit(1);
+               abort();
        }
 
        current_audio_input = audio_input_id;
index e37002918cb4891f645827dcef74dc7115429031..f6826b51366e4a73afcfdcf0edac39179601a5ad 100644 (file)
@@ -130,7 +130,7 @@ void DeckLinkOutput::start_output(uint32_t mode, int64_t base_pts)
 
        if (video_modes.empty()) {
                fprintf(stderr, "ERROR: No matching output modes for %dx%d found\n", width, height);
-               exit(1);
+               abort();
        }
 
        should_quit.unquit();
@@ -141,19 +141,19 @@ void DeckLinkOutput::start_output(uint32_t mode, int64_t base_pts)
        IDeckLinkConfiguration *config = nullptr;
        if (output->QueryInterface(IID_IDeckLinkConfiguration, (void**)&config) != S_OK) {
                fprintf(stderr, "Failed to get configuration interface for output card\n");
-               exit(1);
+               abort();
        }
        if (config->SetFlag(bmdDeckLinkConfigLowLatencyVideoOutput, true) != S_OK) {
                fprintf(stderr, "Failed to set low latency output\n");
-               exit(1);
+               abort();
        }
        if (config->SetInt(bmdDeckLinkConfigVideoOutputConnection, video_connection) != S_OK) {
                fprintf(stderr, "Failed to set video output connection for card %u\n", card_index);
-               exit(1);
+               abort();
        }
        if (config->SetFlag(bmdDeckLinkConfigUse1080pNotPsF, true) != S_OK) {
                fprintf(stderr, "Failed to set PsF flag for card\n");
-               exit(1);
+               abort();
        }
        if (config->SetFlag(bmdDeckLinkConfigSMPTELevelAOutput, true) != S_OK) {
                // This affects at least some no-name SDI->HDMI converters.
@@ -167,12 +167,12 @@ void DeckLinkOutput::start_output(uint32_t mode, int64_t base_pts)
        if (output->DoesSupportVideoMode(mode, pixel_format, bmdVideoOutputFlagDefault,
                                         &support, &display_mode) != S_OK) {
                fprintf(stderr, "Couldn't ask for format support\n");
-               exit(1);
+               abort();
        }
 
        if (support == bmdDisplayModeNotSupported) {
                fprintf(stderr, "Requested display mode not supported\n");
-               exit(1);
+               abort();
        }
 
        current_mode_flags = display_mode->GetFlags();
@@ -181,7 +181,7 @@ void DeckLinkOutput::start_output(uint32_t mode, int64_t base_pts)
        BMDTimeScale time_scale;
        if (display_mode->GetFrameRate(&time_value, &time_scale) != S_OK) {
                fprintf(stderr, "Couldn't get frame rate\n");
-               exit(1);
+               abort();
        }
 
        metric_decklink_output_width_pixels = width;
@@ -196,20 +196,20 @@ void DeckLinkOutput::start_output(uint32_t mode, int64_t base_pts)
        HRESULT result = output->EnableVideoOutput(mode, bmdVideoOutputFlagDefault);
        if (result != S_OK) {
                fprintf(stderr, "Couldn't enable output with error 0x%x\n", result);
-               exit(1);
+               abort();
        }
        if (output->SetScheduledFrameCompletionCallback(this) != S_OK) {
                fprintf(stderr, "Couldn't set callback\n");
-               exit(1);
+               abort();
        }
        assert(OUTPUT_FREQUENCY == 48000);
        if (output->EnableAudioOutput(bmdAudioSampleRate48kHz, bmdAudioSampleType32bitInteger, 2, bmdAudioOutputStreamTimestamped) != S_OK) {
                fprintf(stderr, "Couldn't enable audio output\n");
-               exit(1);
+               abort();
        }
        if (output->BeginAudioPreroll() != S_OK) {
                fprintf(stderr, "Couldn't begin audio preroll\n");
-               exit(1);
+               abort();
        }
 
        present_thread = thread([this]{
@@ -218,7 +218,7 @@ void DeckLinkOutput::start_output(uint32_t mode, int64_t base_pts)
                if (!make_current(context, this->surface)) {
                        printf("display=%p surface=%p context=%p curr=%p err=%d\n", eglGetCurrentDisplay(), this->surface, context, eglGetCurrentContext(),
                                eglGetError());
-                       exit(1);
+                       abort();
                }
                present_thread_func();
                delete_context(context);
@@ -366,11 +366,11 @@ void DeckLinkOutput::wait_for_frame(int64_t pts, int *dropped_frames, int64_t *f
        if (!playback_started) {
                if (output->EndAudioPreroll() != S_OK) {
                        fprintf(stderr, "Could not end audio preroll\n");
-                       exit(1);  // TODO
+                       abort();  // TODO
                }
                if (output->StartScheduledPlayback(base_pts, TIMEBASE, 1.0) != S_OK) {
                        fprintf(stderr, "Could not start playback\n");
-                       exit(1);  // TODO
+                       abort();  // TODO
                }
                playback_started = true;
        }
index 4b701abed3799448d2d6755652190a1c57769b77..33a7933a033e26c08d91d59e1f4919a0717d55b6 100644 (file)
@@ -33,7 +33,7 @@ map<uint32_t, VideoMode> summarize_video_modes(IDeckLinkDisplayModeIterator *mod
                BMDTimeValue frame_rate_den;
                if (mode_ptr->GetFrameRate(&frame_rate_den, &frame_rate_num) != S_OK) {
                        fprintf(stderr, "Could not get frame rate for mode '%s' on card %d\n", mode.name.c_str(), card_index);
-                       exit(1);
+                       abort();
                }
                mode.frame_rate_num = frame_rate_num;
                mode.frame_rate_den = frame_rate_den;
@@ -56,7 +56,7 @@ BMDVideoConnection pick_default_video_connection(IDeckLink *card, BMDDeckLinkAtt
        IDeckLinkAttributes *attr;
        if (card->QueryInterface(IID_IDeckLinkAttributes, (void**)&attr) != S_OK) {
                fprintf(stderr, "Card %u has no attributes\n", card_index);
-               exit(1);
+               abort();
        }
 
        int64_t connection_mask;
@@ -66,7 +66,7 @@ BMDVideoConnection pick_default_video_connection(IDeckLink *card, BMDDeckLinkAtt
                } else {
                        fprintf(stderr, "Failed to enumerate video outputs for card %u\n", card_index);
                }
-               exit(1);
+               abort();
        }
        attr->Release();
        if (connection_mask == 0) {
@@ -75,7 +75,7 @@ BMDVideoConnection pick_default_video_connection(IDeckLink *card, BMDDeckLinkAtt
                } else {
                        fprintf(stderr, "Card %u has no output connections\n", card_index);
                }
-               exit(1);
+               abort();
        }
 
        if ((connection_mask & bmdVideoConnectionHDMI) &&
index b4fec063ce702a01dde9d2f7655a553fc471336c..17448c4714fbde80e33f1a4420b36bc7304791ac 100644 (file)
@@ -793,12 +793,12 @@ void FFmpegCapture::convert_audio(const AVFrame *audio_avframe, FrameAllocator::
 
                if (resampler == nullptr) {
                        fprintf(stderr, "Allocating resampler failed.\n");
-                       exit(1);
+                       abort();
                }
 
                if (swr_init(resampler) < 0) {
                        fprintf(stderr, "Could not open resample context.\n");
-                       exit(1);
+                       abort();
                }
 
                last_src_format = AVSampleFormat(audio_avframe->format);
@@ -815,7 +815,7 @@ void FFmpegCapture::convert_audio(const AVFrame *audio_avframe, FrameAllocator::
                const_cast<const uint8_t **>(audio_avframe->data), audio_avframe->nb_samples);
        if (out_samples < 0) {
                 fprintf(stderr, "Audio conversion failed.\n");
-                exit(1);
+                abort();
         }
 
        audio_frame->len += out_samples * bytes_per_sample;
index e348d0a21c27e95fb799a786c7861f1063552127..9a74ca1f4e7f0c207970671a9805ce8d9fde6c74 100644 (file)
@@ -58,7 +58,7 @@ string search_for_file_or_die(const string &filename)
        if (pathname.empty()) {
                fprintf(stderr, "Couldn't find %s in any directory in --theme-dirs, exiting.\n",
                        filename.c_str());
-               exit(1);
+               abort();
        }
        return pathname;
 }
index bdb9821d5aafed89dbe453be4865600f888beb68..b025076c0639361fd74307a99af986582e089999 100644 (file)
@@ -87,7 +87,7 @@ map<unsigned, unsigned> parse_mjpeg_export_cards(char *optarg)
                }
                if (range_end < range_begin) {
                        fprintf(stderr, "ERROR: Invalid range %u-%u in --mjpeg-export-cards=\n", range_begin, range_end);
-                       exit(1);
+                       abort();
                }
                if (range_end >= unsigned(global_flags.num_cards)) {
                        // There are situations where we could possibly want to
@@ -96,12 +96,12 @@ map<unsigned, unsigned> parse_mjpeg_export_cards(char *optarg)
                        // require more functionality the the JPEG encoder.
                        fprintf(stderr, "ERROR: Asked for (zero-indexed) card %u in --mjpeg-export-cards=, but there are only %u cards\n",
                                range_end, global_flags.num_cards);
-                       exit(1);
+                       abort();
                }
                for (unsigned card_idx = range_begin; card_idx <= range_end; ++card_idx) {
                        if (ret.count(card_idx)) {
                                fprintf(stderr, "ERROR: Card %u was given twice in --mjpeg-export-cards=\n", card_idx);
-                               exit(1);
+                               abort();
                        }
                        ret[card_idx] = stream_idx++;
                }
@@ -317,7 +317,7 @@ void parse_flags(Program program, int argc, char * const argv[])
                        char *ptr = strchr(optarg, ',');
                        if (ptr == nullptr) {
                                fprintf(stderr, "ERROR: Invalid argument '%s' to --map-signal (needs a signal and a card number, separated by comma)\n", optarg);
-                               exit(1);
+                               abort();
                        }
                        *ptr = '\0';
                        const int signal_num = atoi(optarg);
@@ -325,7 +325,7 @@ void parse_flags(Program program, int argc, char * const argv[])
                        if (global_flags.default_stream_mapping.count(signal_num)) {
                                fprintf(stderr, "ERROR: Signal %d already mapped to card %d\n",
                                        signal_num, global_flags.default_stream_mapping[signal_num]);
-                               exit(1);
+                               abort();
                        }
                        global_flags.default_stream_mapping[signal_num] = card_num;
                        break;
@@ -489,13 +489,13 @@ void parse_flags(Program program, int argc, char * const argv[])
                        char *ptr = strchr(optarg, ',');
                        if (ptr == nullptr) {
                                fprintf(stderr, "ERROR: Invalid argument '%s' to --input-ycbcr-interpretation (needs a card and an interpretation, separated by comma)\n", optarg);
-                               exit(1);
+                               abort();
                        }
                        *ptr = '\0';
                        const int card_num = atoi(optarg);
                        if (card_num < 0 || card_num >= MAX_VIDEO_CARDS) {
                                fprintf(stderr, "ERROR: Invalid card number %d\n", card_num);
-                               exit(1);
+                               abort();
                        }
 
                        YCbCrInterpretation interpretation;
@@ -510,7 +510,7 @@ void parse_flags(Program program, int argc, char * const argv[])
                                        interpretation.full_range = false;
                                } else {
                                        fprintf(stderr, "ERROR: Invalid Y'CbCr range '%s' (must be “full” or “limited”)\n", range);
-                                       exit(1);
+                                       abort();
                                }
                        }
 
@@ -524,11 +524,11 @@ void parse_flags(Program program, int argc, char * const argv[])
                                interpretation.ycbcr_coefficients_auto = true;
                                if (interpretation.full_range) {
                                        fprintf(stderr, "ERROR: Cannot use “auto” Y'CbCr coefficients with full range\n");
-                                       exit(1);
+                                       abort();
                                }
                        } else {
                                fprintf(stderr, "ERROR: Invalid Y'CbCr coefficients '%s' (must be “rec601”, “rec709” or “auto”)\n", interpretation_str);
-                               exit(1);
+                               abort();
                        }
                        global_flags.ycbcr_interpretation[card_num] = interpretation;
                        break;
@@ -539,7 +539,7 @@ void parse_flags(Program program, int argc, char * const argv[])
                case OPTION_MJPEG_EXPORT_CARDS: {
                        if (card_to_mjpeg_stream_export_set) {
                                fprintf(stderr, "ERROR: --mjpeg-export-cards given twice\n");
-                               exit(1);
+                               abort();
                        }
                        global_flags.card_to_mjpeg_stream_export = parse_mjpeg_export_cards(optarg);    
                        card_to_mjpeg_stream_export_set = true;
@@ -552,28 +552,28 @@ void parse_flags(Program program, int argc, char * const argv[])
                        fprintf(stderr, "Unknown option '%s'\n", argv[option_index]);
                        fprintf(stderr, "\n");
                        usage(program);
-                       exit(1);
+                       abort();
                }
        }
 
        if (global_flags.uncompressed_video_to_http &&
            global_flags.x264_video_to_http) {
                fprintf(stderr, "ERROR: --http-uncompressed-video and --http-x264-video are mutually incompatible\n");
-               exit(1);
+               abort();
        }
        if (global_flags.num_cards <= 0) {
                fprintf(stderr, "ERROR: --num-cards must be at least 1\n");
-               exit(1);
+               abort();
        }
        if (global_flags.output_card < -1 ||
            global_flags.output_card >= global_flags.num_cards) {
                fprintf(stderr, "ERROR: --output-card points to a nonexistant card\n");
-               exit(1);
+               abort();
        }
        if (!global_flags.transcode_audio && global_flags.stream_audio_codec_name.empty()) {
                fprintf(stderr, "ERROR: If not transcoding audio, you must specify ahead-of-time what audio codec is in use\n");
                fprintf(stderr, "       (using --http-audio-codec).\n");
-               exit(1);
+               abort();
        }
        if (global_flags.x264_speedcontrol) {
                if (!global_flags.x264_preset.empty() && global_flags.x264_preset != "faster") {
@@ -594,14 +594,14 @@ void parse_flags(Program program, int argc, char * const argv[])
        if (global_flags.width <= 0 || (global_flags.width % 8) != 0 ||
            global_flags.height <= 0 || (global_flags.height % 8) != 0) {
                fprintf(stderr, "ERROR: --width and --height must be positive integers divisible by 8\n");
-               exit(1);
+               abort();
        }
 
        for (pair<int, int> mapping : global_flags.default_stream_mapping) {
                if (mapping.second >= global_flags.num_cards) {
                        fprintf(stderr, "ERROR: Signal %d mapped to card %d, which doesn't exist (try adjusting --num-cards)\n",
                                mapping.first, mapping.second);
-                       exit(1);
+                       abort();
                }
        }
 
@@ -633,22 +633,22 @@ void parse_flags(Program program, int argc, char * const argv[])
                global_flags.ycbcr_auto_coefficients = false;
        } else {
                fprintf(stderr, "ERROR: --output-ycbcr-coefficients must be “rec601”, “rec709” or “auto”\n");
-               exit(1);
+               abort();
        }
 
        if (global_flags.output_buffer_frames < 0.0f) {
                // Actually, even zero probably won't make sense; there is some internal
                // delay to the card.
                fprintf(stderr, "ERROR: --output-buffer-frames can't be negative.\n");
-               exit(1);
+               abort();
        }
        if (global_flags.output_slop_frames < 0.0f) {
                fprintf(stderr, "ERROR: --output-slop-frames can't be negative.\n");
-               exit(1);
+               abort();
        }
        if (global_flags.max_input_queue_frames < 1) {
                fprintf(stderr, "ERROR: --max-input-queue-frames must be at least 1.\n");
-               exit(1);
+               abort();
        }
        if (global_flags.max_input_queue_frames > 10) {
                fprintf(stderr, "WARNING: --max-input-queue-frames has little effect over 10.\n");
@@ -657,7 +657,7 @@ void parse_flags(Program program, int argc, char * const argv[])
        if (!isinf(global_flags.x264_crf)) {  // CRF mode is selected.
                if (global_flags.x264_bitrate != -1) {
                        fprintf(stderr, "ERROR: --x264-bitrate and --x264-crf are mutually incompatible.\n");
-                       exit(1);
+                       abort();
                }
                if (global_flags.x264_vbv_max_bitrate != -1 && global_flags.x264_vbv_buffer_size != -1) {
                        fprintf(stderr, "WARNING: VBV settings are ignored with --x264-crf.\n");
index 4b6840b1327508a2027364fcd196a6924a1a8252..08ef3b9468bf20582d6b5cbc744dfbc5216dbb09 100644 (file)
@@ -47,7 +47,7 @@ ImageInput::ImageInput(const string &filename)
 {
        if (current_image == nullptr) {  // Could happen even though search_for_file() returned.
                fprintf(stderr, "Couldn't load image, exiting.\n");
-               exit(1);
+               abort();
        }
        set_width(current_image->width);
        set_height(current_image->height);
index 7a058e47e5e0d4c1733953acf077d9d37c485186..32b497d200f924c7289c146759094e75bd9c199e 100644 (file)
@@ -173,7 +173,7 @@ int main(int argc, char *argv[])
        parse_flags(PROGRAM_KAERU, argc, argv);
        if (optind + 1 != argc) {
                usage(PROGRAM_KAERU);
-               exit(1);
+               abort();
        }
        global_flags.num_cards = 1;  // For latency metrics.
 
index 410a6c42d7fcaa7e78b3b31d58b98b0c935d4beb..b5463754a463bdc60f0be758a18be3add0e8ee71 100644 (file)
@@ -95,7 +95,7 @@ int main(int argc, char *argv[])
        global_share_widget = new QGLWidget();
        if (!global_share_widget->isValid()) {
                fprintf(stderr, "Failed to initialize OpenGL. Nageru needs at least OpenGL 3.1 to function properly.\n");
-               exit(1);
+               abort();
        }
 
        MainWindow mainWindow;
index 96552a542d35d0dc0c65883903f270982b6b6ae9..91234ceb23ff301b6194d9bda9b1f81fd0f7e34b 100644 (file)
@@ -281,7 +281,7 @@ MainWindow::MainWindow()
                if (!load_midi_mapping_from_file(global_flags.midi_mapping_filename, &midi_mapping)) {
                        fprintf(stderr, "Couldn't load MIDI mapping '%s'; exiting.\n",
                                global_flags.midi_mapping_filename.c_str());
-                       ::exit(1);
+                       ::abort();
                }
                midi_mapper.set_midi_mapping(midi_mapping);
        }
index 32c1984fa4c3ee89dd214695a26113c5729f554d..c91857e62fbab09b3677fcebba41402235feabc6 100644 (file)
@@ -432,7 +432,7 @@ Mixer::Mixer(const QSurfaceFormat &format, unsigned num_cards)
        for (unsigned video_card_index = 0; video_card_index < video_inputs.size(); ++card_index, ++video_card_index) {
                if (card_index >= MAX_VIDEO_CARDS) {
                        fprintf(stderr, "ERROR: Not enough card slots available for the videos the theme requested.\n");
-                       exit(1);
+                       abort();
                }
                configure_card(card_index, video_inputs[video_card_index], CardType::FFMPEG_INPUT, /*output=*/nullptr);
                video_inputs[video_card_index]->set_card_index(card_index);
@@ -445,7 +445,7 @@ Mixer::Mixer(const QSurfaceFormat &format, unsigned num_cards)
        for (unsigned html_card_index = 0; html_card_index < html_inputs.size(); ++card_index, ++html_card_index) {
                if (card_index >= MAX_VIDEO_CARDS) {
                        fprintf(stderr, "ERROR: Not enough card slots available for the HTML inputs the theme requested.\n");
-                       exit(1);
+                       abort();
                }
                configure_card(card_index, html_inputs[html_card_index], CardType::CEF_INPUT, /*output=*/nullptr);
                html_inputs[html_card_index]->set_card_index(card_index);
@@ -466,7 +466,7 @@ Mixer::Mixer(const QSurfaceFormat &format, unsigned num_cards)
                if (!v210Converter::has_hardware_support()) {
                        fprintf(stderr, "ERROR: --ten-bit-input requires support for OpenGL compute shaders\n");
                        fprintf(stderr, "       (OpenGL 4.3, or GL_ARB_compute_shader + GL_ARB_shader_image_load_store).\n");
-                       exit(1);
+                       abort();
                }
                v210_converter.reset(new v210Converter());
 
@@ -483,7 +483,7 @@ Mixer::Mixer(const QSurfaceFormat &format, unsigned num_cards)
                if (!v210Converter::has_hardware_support()) {
                        fprintf(stderr, "ERROR: --ten-bit-output requires support for OpenGL compute shaders\n");
                        fprintf(stderr, "       (OpenGL 4.3, or GL_ARB_compute_shader + GL_ARB_shader_image_load_store).\n");
-                       exit(1);
+                       abort();
                }
        }
 
@@ -998,7 +998,7 @@ void Mixer::thread_func()
        QOpenGLContext *context = create_context(mixer_surface);
        if (!make_current(context, mixer_surface)) {
                printf("oops\n");
-               exit(1);
+               abort();
        }
 
        // Start the actual capture. (We don't want to do it before we're actually ready
index 24aa0ebabbdb3d04dbed9ce8542d059c62d96881..46bb94c7639112f76b031c96c63acab9560b99ce 100644 (file)
@@ -131,7 +131,7 @@ MJPEGEncoder::MJPEGEncoder(HTTPD *httpd, const string &va_display)
                AVStream *stream = avformat_new_stream(avctx.get(), nullptr);
                if (stream == nullptr) {
                        fprintf(stderr, "avformat_new_stream() failed\n");
-                       exit(1);
+                       abort();
                }
                stream->time_base = AVRational{ 1, TIMEBASE };
                stream->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
@@ -159,7 +159,7 @@ MJPEGEncoder::MJPEGEncoder(HTTPD *httpd, const string &va_display)
        }
        if (avformat_write_header(avctx.get(), &options) < 0) {
                fprintf(stderr, "avformat_write_header() failed\n");
-               exit(1);
+               abort();
        }
 
        // Initialize VA-API.
@@ -367,7 +367,7 @@ void MJPEGEncoder::write_mjpeg_packet(int64_t pts, unsigned card_index, const ui
 
        if (av_write_frame(avctx.get(), &pkt) < 0) {
                fprintf(stderr, "av_write_frame() failed\n");
-               exit(1);
+               abort();
        }
 }
 
index 4883554c5b5d1b52e5146b666528dcee956fcf38..9dc603b5ede7a0c1c2f6bbefcf59db713bd92408 100644 (file)
@@ -80,7 +80,7 @@ std::atomic<int64_t> metric_quick_sync_stalled_frames{0};
 #define CHECK_VASTATUS(va_status, func)                                 \
     if (va_status != VA_STATUS_SUCCESS) {                               \
         fprintf(stderr, "%s:%d (%s) failed with %d\n", __func__, __LINE__, func, va_status); \
-        exit(1);                                                        \
+        abort();                                                        \
     }
 
 #undef BUFFER_OFFSET
@@ -822,7 +822,7 @@ int QuickSyncEncoderImpl::init_va(const string &va_display)
     va_dpy = try_open_va(va_display, &h264_profile, &error);
     if (va_dpy == nullptr) {
        fprintf(stderr, "error: %s\n", error.c_str());
-        exit(1);
+        abort();
     }
     if (!va_dpy->can_use_zerocopy) {
         use_zerocopy = false;
@@ -860,7 +860,7 @@ int QuickSyncEncoderImpl::init_va(const string &va_display)
     /* check the interested configattrib */
     if ((attrib[VAConfigAttribRTFormat].value & VA_RT_FORMAT_YUV420) == 0) {
         printf("Not find desired YUV420 RT format\n");
-        exit(1);
+        abort();
     } else {
         config_attrib[config_attrib_num].type = VAConfigAttribRTFormat;
         config_attrib[config_attrib_num].value = VA_RT_FORMAT_YUV420;
@@ -870,7 +870,7 @@ int QuickSyncEncoderImpl::init_va(const string &va_display)
     if (attrib[VAConfigAttribRateControl].value != VA_ATTRIB_NOT_SUPPORTED) {
         if (!(attrib[VAConfigAttribRateControl].value & VA_RC_CQP)) {
             fprintf(stderr, "ERROR: VA-API encoder does not support CQP mode.\n");
-            exit(1);
+            abort();
         }
 
         config_attrib[config_attrib_num].type = VAConfigAttribRateControl;
@@ -1564,7 +1564,7 @@ QuickSyncEncoderImpl::QuickSyncEncoderImpl(const std::string &filename, Resource
                if (!make_current(context, this->surface)) {
                        printf("display=%p surface=%p context=%p curr=%p err=%d\n", eglGetCurrentDisplay(), this->surface, context, eglGetCurrentContext(),
                                eglGetError());
-                       exit(1);
+                       abort();
                }
                encode_thread_func();
                delete_context(context);
@@ -1804,7 +1804,7 @@ void QuickSyncEncoderImpl::open_output_file(const std::string &filename)
        if (ret < 0) {
                char tmp[AV_ERROR_MAX_STRING_SIZE];
                fprintf(stderr, "%s: avio_open2() failed: %s\n", filename.c_str(), av_make_error_string(tmp, sizeof(tmp), ret));
-               exit(1);
+               abort();
        }
 
        string video_extradata;  // FIXME: See other comment about global headers.
@@ -2179,5 +2179,5 @@ string QuickSyncEncoder::get_usable_va_display()
        fprintf(stderr, "to expose Quick Sync. Alternatively, you can use --record-x264-video\n");
        fprintf(stderr, "to use software instead of hardware H.264 encoding, at the expense\n");
        fprintf(stderr, "of increased CPU usage and possibly bit rate.\n");
-       exit(1);
+       abort();
 }
index ead38fa819e877fceee43ec32cf4aa52a183dc92..ed99e5f346e9c8eb54b1c9670f4709f0c0dbe093 100644 (file)
@@ -455,7 +455,7 @@ int HTMLInput_new(lua_State* L)
 #else
        fprintf(stderr, "This version of Nageru has been compiled without CEF support.\n");
        fprintf(stderr, "HTMLInput is not available.\n");
-       exit(1);
+       abort();
 #endif
 }
 
@@ -1079,7 +1079,7 @@ int call_num_channels(lua_State *L)
 
        if (lua_pcall(L, 0, 1, 0) != 0) {
                fprintf(stderr, "error running function `num_channels': %s\n", lua_tostring(L, -1));
-               exit(1);
+               abort();
        }
 
        int num_channels = luaL_checknumber(L, 1);
@@ -1142,7 +1142,7 @@ Theme::Theme(const string &filename, const vector<string> &search_dirs, Resource
                for (const string &error : errors) {
                        fprintf(stderr, "%s\n", error.c_str());
                }
-               exit(1);
+               abort();
        }
        assert(lua_gettop(L) == 0);
 
@@ -1183,7 +1183,7 @@ Theme::Theme(const string &filename, const vector<string> &search_dirs, Resource
        luaL_unref(L, LUA_REGISTRYINDEX, theme_code_ref);
        if (lua_pcall(L, 0, 0, 0)) {
                fprintf(stderr, "Error when running %s: %s\n", path.c_str(), lua_tostring(L, -1));
-               exit(1);
+               abort();
        }
        assert(lua_gettop(L) == 0);
 
@@ -1251,19 +1251,19 @@ Theme::Chain Theme::get_chain(unsigned num, float t, unsigned width, unsigned he
 
        if (lua_pcall(L, 5, 2, 0) != 0) {
                fprintf(stderr, "error running function `get_chain': %s\n", lua_tostring(L, -1));
-               exit(1);
+               abort();
        }
 
        EffectChain *effect_chain = (EffectChain *)luaL_testudata(L, -2, "EffectChain");
        if (effect_chain == nullptr) {
                fprintf(stderr, "get_chain() for chain number %d did not return an EffectChain\n",
                        num);
-               exit(1);
+               abort();
        }
        chain.chain = effect_chain;
        if (!lua_isfunction(L, -1)) {
                fprintf(stderr, "Argument #-1 should be a function\n");
-               exit(1);
+               abort();
        }
        lua_pushvalue(L, -1);
        shared_ptr<LuaRefWithDeleter> funcref(new LuaRefWithDeleter(&m, L, luaL_ref(L, LUA_REGISTRYINDEX)));
@@ -1280,7 +1280,7 @@ Theme::Chain Theme::get_chain(unsigned num, float t, unsigned width, unsigned he
                lua_rawgeti(L, LUA_REGISTRYINDEX, funcref->get());
                if (lua_pcall(L, 0, 0, 0) != 0) {
                        fprintf(stderr, "error running chain setup callback: %s\n", lua_tostring(L, -1));
-                       exit(1);
+                       abort();
        }
                assert(lua_gettop(L) == 0);
 
@@ -1321,12 +1321,12 @@ string Theme::get_channel_name(unsigned channel)
        lua_pushnumber(L, channel);
        if (lua_pcall(L, 1, 1, 0) != 0) {
                fprintf(stderr, "error running function `channel_name': %s\n", lua_tostring(L, -1));
-               exit(1);
+               abort();
        }
        const char *ret = lua_tostring(L, -1);
        if (ret == nullptr) {
                fprintf(stderr, "function `channel_name' returned nil for channel %d\n", channel);
-               exit(1);
+               abort();
        }
 
        string retstr = ret;
@@ -1342,7 +1342,7 @@ int Theme::get_channel_signal(unsigned channel)
        lua_pushnumber(L, channel);
        if (lua_pcall(L, 1, 1, 0) != 0) {
                fprintf(stderr, "error running function `channel_signal': %s\n", lua_tostring(L, -1));
-               exit(1);
+               abort();
        }
 
        int ret = luaL_checknumber(L, 1);
@@ -1358,13 +1358,13 @@ std::string Theme::get_channel_color(unsigned channel)
        lua_pushnumber(L, channel);
        if (lua_pcall(L, 1, 1, 0) != 0) {
                fprintf(stderr, "error running function `channel_color': %s\n", lua_tostring(L, -1));
-               exit(1);
+               abort();
        }
 
        const char *ret = lua_tostring(L, -1);
        if (ret == nullptr) {
                fprintf(stderr, "function `channel_color' returned nil for channel %d\n", channel);
-               exit(1);
+               abort();
        }
 
        string retstr = ret;
@@ -1380,7 +1380,7 @@ bool Theme::get_supports_set_wb(unsigned channel)
        lua_pushnumber(L, channel);
        if (lua_pcall(L, 1, 1, 0) != 0) {
                fprintf(stderr, "error running function `supports_set_wb': %s\n", lua_tostring(L, -1));
-               exit(1);
+               abort();
        }
 
        bool ret = checkbool(L, -1);
@@ -1399,7 +1399,7 @@ void Theme::set_wb(unsigned channel, double r, double g, double b)
        lua_pushnumber(L, b);
        if (lua_pcall(L, 4, 0, 0) != 0) {
                fprintf(stderr, "error running function `set_wb': %s\n", lua_tostring(L, -1));
-               exit(1);
+               abort();
        }
 
        assert(lua_gettop(L) == 0);
@@ -1412,7 +1412,7 @@ vector<string> Theme::get_transition_names(float t)
        lua_pushnumber(L, t);
        if (lua_pcall(L, 1, 1, 0) != 0) {
                fprintf(stderr, "error running function `get_transitions': %s\n", lua_tostring(L, -1));
-               exit(1);
+               abort();
        }
 
        vector<string> ret;
@@ -1477,7 +1477,7 @@ void Theme::transition_clicked(int transition_num, float t)
 
        if (lua_pcall(L, 2, 0, 0) != 0) {
                fprintf(stderr, "error running function `transition_clicked': %s\n", lua_tostring(L, -1));
-               exit(1);
+               abort();
        }
        assert(lua_gettop(L) == 0);
 }
@@ -1490,7 +1490,7 @@ void Theme::channel_clicked(int preview_num)
 
        if (lua_pcall(L, 1, 0, 0) != 0) {
                fprintf(stderr, "error running function `channel_clicked': %s\n", lua_tostring(L, -1));
-               exit(1);
+               abort();
        }
        assert(lua_gettop(L) == 0);
 }
@@ -1530,6 +1530,6 @@ void Theme::theme_menu_entry_clicked(int lua_ref)
        lua_rawgeti(L, LUA_REGISTRYINDEX, lua_ref);
        if (lua_pcall(L, 0, 0, 0) != 0) {
                fprintf(stderr, "error running menu callback: %s\n", lua_tostring(L, -1));
-               exit(1);
+               abort();
        }
 }
index d10920b2c6d73c5b0e29acb4e04b2a03909d70bf..269126b2cbea9a900b915ab43a0ba0e3e3e83af6 100644 (file)
@@ -113,7 +113,7 @@ void main()
                GLchar error_log[1024] = {0};
                glGetProgramInfoLog(shader.glsl_program_num, 1024, nullptr, error_log);
                fprintf(stderr, "Error linking program: %s\n", error_log);
-               exit(1);
+               abort();
        }
 
        shader.max_cbcr_x_pos = glGetUniformLocation(shader.glsl_program_num, "max_cbcr_x");
index f8b63cea69769d76480300dee7d50d63e6d4a0d0..3ed1811c6b2091471c5f63915a7cf1c508591314 100644 (file)
@@ -63,7 +63,7 @@ X264Dynamic load_x264_for_bit_depth(unsigned depth)
        if (x264_dir.empty()) {
                fprintf(stderr, "ERROR: Requested %d-bit x264, but is not linked to such an x264, and could not find one.\n",
                        depth);
-               exit(1);
+               abort();
        }
 
        string x264_10b_string = x264_dir + "/x264-10bit" + x264_suffix;
@@ -71,7 +71,7 @@ X264Dynamic load_x264_for_bit_depth(unsigned depth)
        if (x264_dlhandle == nullptr) {
                fprintf(stderr, "ERROR: Requested %d-bit x264, but is not linked to such an x264, and %s would not load.\n",
                        depth, x264_10b_string.c_str());
-               exit(1);
+               abort();
        }
 
        dyn.handle = x264_dlhandle;
index b98d6fdac4de8749ebc65c5b57b35ced79980856..d938393598d637365ba4d1e8e843c8878cdf311c 100644 (file)
@@ -232,7 +232,7 @@ void X264Encoder::init_x264()
        x264 = dyn.x264_encoder_open(&param);
        if (x264 == nullptr) {
                fprintf(stderr, "ERROR: x264 initialization failed.\n");
-               exit(1);
+               abort();
        }
 
        if (global_flags.x264_speedcontrol) {
index a396afe92a5f390a700b200fa821fcc23b725d89..80c26518a42b6696383c02818d8b4c9358eda905 100644 (file)
@@ -20,13 +20,13 @@ int main(int argc, char **argv)
        FILE *infp = fopen(argv[1], "rb");
        if (infp == nullptr) {
                perror(argv[1]);
-               exit(1);
+               abort();
        }
 
        FILE *outfp = fopen(argv[3], "w");
        if (outfp == nullptr) {
                perror(argv[3]);
-               exit(1);
+               abort();
        }
 
        fprintf(outfp, "// Generated by bin2h.cpp from %s. Do not edit by hand.\n", argv[1]);
index 0b17bfa56893ec065b5f96efbe1a95a1a6a687c7..678457101ac39ffdd1056dcdc54f6dce874f4e67 100644 (file)
@@ -24,7 +24,7 @@ QSurface *create_surface()
        surface->create();
        if (!surface->isValid()) {
                fprintf(stderr, "ERROR: surface not valid!\n");
-               exit(1);
+               abort();
        }
        return surface;
 }
@@ -36,7 +36,7 @@ QSurface *create_surface(const QSurfaceFormat &format)
        surface->create();
        if (!surface->isValid()) {
                fprintf(stderr, "ERROR: surface not valid!\n");
-               exit(1);
+               abort();
        }
        return surface;
 }
index 9d77e218f5078f37b5aa3eeba8c9bb87d84a8226..ab84fda6db51099e3ecf03013bc08a7b0a60947a 100644 (file)
@@ -21,7 +21,7 @@ MIDIDevice::~MIDIDevice()
        const uint64_t one = 1;
        if (write(should_quit_fd, &one, sizeof(one)) != sizeof(one)) {
                perror("write(should_quit_fd)");
-               exit(1);
+               abort();
        }
        midi_thread.join();
        close(should_quit_fd);
index e122e2bb32c998556c377291c1d1d513badd9e98..adec53de7923171842d90822a7ec8600b9e78fd0 100644 (file)
@@ -53,7 +53,7 @@ Mux::Mux(AVFormatContext *avctx, int width, int height, Codec video_codec, const
        AVStream *avstream_video = avformat_new_stream(avctx, nullptr);
        if (avstream_video == nullptr) {
                fprintf(stderr, "avformat_new_stream() failed\n");
-               exit(1);
+               abort();
        }
        avstream_video->time_base = AVRational{1, time_base};
        avstream_video->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
@@ -94,12 +94,12 @@ Mux::Mux(AVFormatContext *avctx, int width, int height, Codec video_codec, const
                AVStream *avstream_audio = avformat_new_stream(avctx, nullptr);
                if (avstream_audio == nullptr) {
                        fprintf(stderr, "avformat_new_stream() failed\n");
-                       exit(1);
+                       abort();
                }
                avstream_audio->time_base = AVRational{1, time_base};
                if (avcodec_parameters_copy(avstream_audio->codecpar, audio_codecpar) < 0) {
                        fprintf(stderr, "avcodec_parameters_copy() failed\n");
-                       exit(1);
+                       abort();
                }
                streams.push_back(avstream_audio);
        }
@@ -108,7 +108,7 @@ Mux::Mux(AVFormatContext *avctx, int width, int height, Codec video_codec, const
                AVStream *avstream_subtitles = avformat_new_stream(avctx, nullptr);
                if (avstream_subtitles == nullptr) {
                        fprintf(stderr, "avformat_new_stream() failed\n");
-                       exit(1);
+                       abort();
                }
                avstream_subtitles->time_base = AVRational{1, time_base};
                avstream_subtitles->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
@@ -125,7 +125,7 @@ Mux::Mux(AVFormatContext *avctx, int width, int height, Codec video_codec, const
        }
        if (avformat_write_header(avctx, &options) < 0) {
                fprintf(stderr, "avformat_write_header() failed\n");
-               exit(1);
+               abort();
        }
        for (MuxMetrics *metric : metrics) {
                metric->metric_written_bytes += avctx->pb->pos;
@@ -166,7 +166,7 @@ void Mux::add_packet(const AVPacket &pkt, int64_t pts, int64_t dts, AVRational t
        av_init_packet(&pkt_copy);
        if (av_packet_ref(&pkt_copy, &pkt) < 0) {
                fprintf(stderr, "av_copy_packet() failed\n");
-               exit(1);
+               abort();
        }
        if (stream_index_override != -1) {
                pkt_copy.stream_index = stream_index_override;
index 40846546b42ed4f11ca055ad9faafcbcaecc418e..77a23fdff0b07e181e506c9aa4b6d04357b4d297 100644 (file)
@@ -17,25 +17,25 @@ string read_file(const string &filename, const unsigned char *start, const size_
                }
 
                perror(filename.c_str());
-               exit(1);
+               abort();
        }
 
        int ret = fseek(fp, 0, SEEK_END);
        if (ret == -1) {
                perror("fseek(SEEK_END)");
-               exit(1);
+               abort();
        }
 
        int disk_size = ftell(fp);
        if (disk_size == -1) {
                perror("ftell");
-               exit(1);
+               abort();
        }
 
        ret = fseek(fp, 0, SEEK_SET);
        if (ret == -1) {
                perror("fseek(SEEK_SET)");
-               exit(1);
+               abort();
        }
 
        string str;
@@ -43,12 +43,12 @@ string read_file(const string &filename, const unsigned char *start, const size_
        ret = fread(&str[0], disk_size, 1, fp);
        if (ret == -1) {
                perror("fread");
-               exit(1);
+               abort();
        }
        if (ret == 0) {
                fprintf(stderr, "Short read when trying to read %d bytes from %s\n",
                        disk_size, filename.c_str());
-               exit(1);
+               abort();
        }
        fclose(fp);