X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=nageru%2Fimage_input.cpp;h=0abefe30f7d8acb5467f9e46e72d3c3f56a61f2e;hb=f677a047d02e4d21491f2905bd220557472e1960;hp=2bf4a237bb86758f92cbdcfba808c514c7c19b82;hpb=9b7d691b4cc5db7dbfc18c82e86c1207fcac4722;p=nageru diff --git a/nageru/image_input.cpp b/nageru/image_input.cpp index 2bf4a23..0abefe3 100644 --- a/nageru/image_input.cpp +++ b/nageru/image_input.cpp @@ -30,7 +30,7 @@ extern "C" { #include #include -#include "ffmpeg_raii.h" +#include "shared/ffmpeg_raii.h" #include "ffmpeg_util.h" #include "flags.h" @@ -41,13 +41,12 @@ using namespace std; ImageInput::ImageInput(const string &filename) : movit::FlatInput({movit::COLORSPACE_sRGB, movit::GAMMA_sRGB}, movit::FORMAT_RGBA_POSTMULTIPLIED_ALPHA, GL_UNSIGNED_BYTE, 1280, 720), // Resolution will be overwritten. - filename(filename), pathname(search_for_file_or_die(filename)), current_image(load_image(filename, pathname)) { 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); @@ -63,7 +62,7 @@ void ImageInput::set_gl_state(GLuint glsl_program_num, const string& prefix, uns // so there's a fair amount of OpenGL memory waste anyway (the cache // is mostly there to save startup time, not RAM). { - unique_lock lock(all_images_lock); + lock_guard lock(all_images_lock); if (all_images[pathname] != current_image) { current_image = all_images[pathname]; set_pixel_data(current_image->pixels.get()); @@ -74,7 +73,7 @@ void ImageInput::set_gl_state(GLuint glsl_program_num, const string& prefix, uns shared_ptr ImageInput::load_image(const string &filename, const string &pathname) { - unique_lock lock(all_images_lock); // Held also during loading. + lock_guard lock(all_images_lock); // Held also during loading. if (all_images.count(pathname)) { return all_images[pathname]; } @@ -234,7 +233,7 @@ void ImageInput::update_thread_func(const std::string &filename, const std::stri continue; } fprintf(stderr, "Loaded new version of %s from disk.\n", pathname.c_str()); - unique_lock lock(all_images_lock); + lock_guard lock(all_images_lock); all_images[pathname] = image; last_modified = image->last_modified; } @@ -243,7 +242,7 @@ void ImageInput::update_thread_func(const std::string &filename, const std::stri void ImageInput::shutdown_updaters() { { - unique_lock lock(threads_should_quit_mu); + lock_guard lock(threads_should_quit_mu); threads_should_quit = true; threads_should_quit_modified.notify_all(); }