]> git.sesse.net Git - nageru/commitdiff
Move from unique_lock to lock_guard everywhere we can. Perhaps ever so slightly clear...
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Fri, 28 Dec 2018 09:48:14 +0000 (10:48 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Fri, 28 Dec 2018 09:59:11 +0000 (10:59 +0100)
21 files changed:
futatabi/jpeg_frame_view.cpp
futatabi/player.cpp
futatabi/video_stream.cpp
futatabi/video_stream.h
nageru/audio_mixer.h
nageru/compression_reduction_meter.cpp
nageru/compression_reduction_meter.h
nageru/correlation_meter.cpp
nageru/correlation_meter.h
nageru/decklink_output.cpp
nageru/image_input.cpp
nageru/lrameter.cpp
nageru/lrameter.h
nageru/mixer.cpp
nageru/nageru_cef_app.cpp
nageru/pbo_frame_allocator.cpp
nageru/quicksync_encoder.cpp
nageru/theme.cpp
nageru/vumeter.cpp
nageru/vumeter.h
shared/httpd.cpp

index 2f43517894a1fcedcf06faef6b1854797ddbdb51..1924a543ff017346930f0c2d8c605253555e5728 100644 (file)
@@ -236,7 +236,7 @@ shared_ptr<Frame> decode_jpeg_with_cache(FrameOnDisk frame_spec, CacheMissBehavi
 {
        *did_decode = false;
        {
-               unique_lock<mutex> lock(cache_mu);
+               lock_guard<mutex> lock(cache_mu);
                auto it = cache.find(frame_spec);
                if (it != cache.end()) {
                        ++metric_jpeg_cache_hit_frames;
@@ -255,7 +255,7 @@ shared_ptr<Frame> decode_jpeg_with_cache(FrameOnDisk frame_spec, CacheMissBehavi
        *did_decode = true;
        shared_ptr<Frame> frame = decode_jpeg(frame_reader->read_frame(frame_spec));
 
-       unique_lock<mutex> lock(cache_mu);
+       lock_guard<mutex> lock(cache_mu);
        cache_bytes_used += frame_size(*frame);
        metric_jpeg_cache_used_bytes = cache_bytes_used;
        cache[frame_spec] = LRUFrame{ frame, event_counter++ };
@@ -368,7 +368,7 @@ void JPEGFrameView::setFrame(unsigned stream_idx, FrameOnDisk frame, FrameOnDisk
 {
        current_stream_idx = stream_idx;  // TODO: Does this interact with fades?
 
-       unique_lock<mutex> lock(cache_mu);
+       lock_guard<mutex> lock(cache_mu);
        PendingDecode decode;
        decode.primary = frame;
        decode.secondary = secondary_frame;
@@ -380,7 +380,7 @@ void JPEGFrameView::setFrame(unsigned stream_idx, FrameOnDisk frame, FrameOnDisk
 
 void JPEGFrameView::setFrame(shared_ptr<Frame> frame)
 {
-       unique_lock<mutex> lock(cache_mu);
+       lock_guard<mutex> lock(cache_mu);
        PendingDecode decode;
        decode.frame = std::move(frame);
        decode.destination = this;
index b7ceb0359968567d9bdc36ef69966768281a5f27..b871fa1f3c62ac4176b2c0138c312749410fda7d 100644 (file)
@@ -440,7 +440,7 @@ void Player::override_angle(unsigned stream_idx)
 
        // Corner case: If a new clip is waiting to be played, change its stream and then we're done.
        {
-               unique_lock<mutex> lock(queue_state_mu);
+               lock_guard<mutex> lock(queue_state_mu);
                if (new_clip_ready) {
                        assert(queued_clip_list.size() == 1);
                        queued_clip_list[0].stream_idx = stream_idx;
@@ -474,13 +474,13 @@ void Player::override_angle(unsigned stream_idx)
 
 void Player::take_queue_spot()
 {
-       unique_lock<mutex> lock(queue_state_mu);
+       lock_guard<mutex> lock(queue_state_mu);
        ++num_queued_frames;
 }
 
 void Player::release_queue_spot()
 {
-       unique_lock<mutex> lock(queue_state_mu);
+       lock_guard<mutex> lock(queue_state_mu);
        assert(num_queued_frames > 0);
        --num_queued_frames;
        new_clip_changed.notify_all();
index dcf44f8e452fb9277e25bd08eafd681d0ed286b4..7c2f8f90464c3af487c119bf8962830ae299b831 100644 (file)
@@ -282,7 +282,7 @@ void VideoStream::clear_queue()
        deque<QueuedFrame> q;
 
        {
-               unique_lock<mutex> lock(queue_lock);
+               lock_guard<mutex> lock(queue_lock);
                q = move(frame_queue);
        }
 
@@ -323,7 +323,7 @@ void VideoStream::schedule_original_frame(steady_clock::time_point local_pts,
        qf.display_func = move(display_func);
        qf.queue_spot_holder = move(queue_spot_holder);
 
-       unique_lock<mutex> lock(queue_lock);
+       lock_guard<mutex> lock(queue_lock);
        frame_queue.push_back(move(qf));
        queue_changed.notify_all();
 }
@@ -342,7 +342,7 @@ void VideoStream::schedule_faded_frame(steady_clock::time_point local_pts, int64
        // separate pools around.)
        BorrowedInterpolatedFrameResources resources;
        {
-               unique_lock<mutex> lock(queue_lock);
+               lock_guard<mutex> lock(queue_lock);
                if (interpolate_resources.empty()) {
                        fprintf(stderr, "WARNING: Too many interpolated frames already in transit; dropping one.\n");
                        return;
@@ -391,7 +391,7 @@ void VideoStream::schedule_faded_frame(steady_clock::time_point local_pts, int64
        qf.resources = move(resources);
        qf.local_pts = local_pts;
 
-       unique_lock<mutex> lock(queue_lock);
+       lock_guard<mutex> lock(queue_lock);
        frame_queue.push_back(move(qf));
        queue_changed.notify_all();
 }
@@ -411,7 +411,7 @@ void VideoStream::schedule_interpolated_frame(steady_clock::time_point local_pts
        // Get the temporary OpenGL resources we need for doing the interpolation.
        BorrowedInterpolatedFrameResources resources;
        {
-               unique_lock<mutex> lock(queue_lock);
+               lock_guard<mutex> lock(queue_lock);
                if (interpolate_resources.empty()) {
                        fprintf(stderr, "WARNING: Too many interpolated frames already in transit; dropping one.\n");
                        return;
@@ -517,7 +517,7 @@ void VideoStream::schedule_interpolated_frame(steady_clock::time_point local_pts
        check_error();
        qf.resources = move(resources);
 
-       unique_lock<mutex> lock(queue_lock);
+       lock_guard<mutex> lock(queue_lock);
        frame_queue.push_back(move(qf));
        queue_changed.notify_all();
 }
@@ -532,7 +532,7 @@ void VideoStream::schedule_refresh_frame(steady_clock::time_point local_pts,
        qf.display_func = move(display_func);
        qf.queue_spot_holder = move(queue_spot_holder);
 
-       unique_lock<mutex> lock(queue_lock);
+       lock_guard<mutex> lock(queue_lock);
        frame_queue.push_back(move(qf));
        queue_changed.notify_all();
 }
index 422b1522a28a993d056d5eea2344a05ce13243c6..05bd7a7b9453c46228ce66eb08362223ddeb40c3 100644 (file)
@@ -99,7 +99,7 @@ private:
                void operator() (InterpolatedFrameResources *ifr) const
                {
                        if (ifr != nullptr) {
-                               std::unique_lock<std::mutex> lock(ifr->owner->queue_lock);
+                               std::lock_guard<std::mutex> lock(ifr->owner->queue_lock);
                                ifr->owner->interpolate_resources.emplace_back(ifr);
                        }
                }
index a7ab9a5a0d60378e632fbd34a7105865c05b0ef0..e435b46280c0d28e549c2fb36ae3df40f810f640 100644 (file)
@@ -208,51 +208,51 @@ public:
 
        void set_gain_staging_db(unsigned bus_index, float gain_db)
        {
-               std::unique_lock<std::mutex> lock(compressor_mutex);
+               std::lock_guard<std::mutex> lock(compressor_mutex);
                level_compressor_enabled[bus_index] = false;
                gain_staging_db[bus_index] = gain_db;
        }
 
        float get_gain_staging_db(unsigned bus_index) const
        {
-               std::unique_lock<std::mutex> lock(compressor_mutex);
+               std::lock_guard<std::mutex> lock(compressor_mutex);
                return gain_staging_db[bus_index];
        }
 
        void set_gain_staging_auto(unsigned bus_index, bool enabled)
        {
-               std::unique_lock<std::mutex> lock(compressor_mutex);
+               std::lock_guard<std::mutex> lock(compressor_mutex);
                level_compressor_enabled[bus_index] = enabled;
        }
 
        bool get_gain_staging_auto(unsigned bus_index) const
        {
-               std::unique_lock<std::mutex> lock(compressor_mutex);
+               std::lock_guard<std::mutex> lock(compressor_mutex);
                return level_compressor_enabled[bus_index];
        }
 
        void set_final_makeup_gain_db(float gain_db)
        {
-               std::unique_lock<std::mutex> lock(compressor_mutex);
+               std::lock_guard<std::mutex> lock(compressor_mutex);
                final_makeup_gain_auto = false;
                final_makeup_gain = from_db(gain_db);
        }
 
        float get_final_makeup_gain_db()
        {
-               std::unique_lock<std::mutex> lock(compressor_mutex);
+               std::lock_guard<std::mutex> lock(compressor_mutex);
                return to_db(final_makeup_gain);
        }
 
        void set_final_makeup_gain_auto(bool enabled)
        {
-               std::unique_lock<std::mutex> lock(compressor_mutex);
+               std::lock_guard<std::mutex> lock(compressor_mutex);
                final_makeup_gain_auto = enabled;
        }
 
        bool get_final_makeup_gain_auto() const
        {
-               std::unique_lock<std::mutex> lock(compressor_mutex);
+               std::lock_guard<std::mutex> lock(compressor_mutex);
                return final_makeup_gain_auto;
        }
 
index a59a71e7eda992f1a8c0591f38896aa60ca65fe9..d123260eeaafd8f83e01013cf88886165388250b 100644 (file)
@@ -41,7 +41,7 @@ void CompressionReductionMeter::paintEvent(QPaintEvent *event)
 
        float level_db;
        {
-               unique_lock<mutex> lock(level_mutex);
+               lock_guard<mutex> lock(level_mutex);
                level_db = this->level_db;
        }
 
index 5890c1381db38b7fa45932813236c7913b97ac4b..ac5a840bb08476b77a393e6a8261cb2a51ced183 100644 (file)
@@ -23,7 +23,7 @@ public:
        CompressionReductionMeter(QWidget *parent);
 
        void set_reduction_db(float level_db) {
-               std::unique_lock<std::mutex> lock(level_mutex);
+               std::lock_guard<std::mutex> lock(level_mutex);
                this->level_db = level_db;
                QMetaObject::invokeMethod(this, "update", Qt::AutoConnection);
        }
index 7b7683a5a1fd4b1158a154c71ced66cbcbd50797..72467455143aa0c3bbf5464a5769cb08149bff34 100644 (file)
@@ -47,7 +47,7 @@ void CorrelationMeter::paintEvent(QPaintEvent *event)
 
        float correlation;
        {
-               unique_lock<mutex> lock(correlation_mutex);
+               lock_guard<mutex> lock(correlation_mutex);
                correlation = this->correlation;
        }
 
index ea01e04034ecc12196c6b3d13005eaca438bcb74..fa92aec6a20d6d44aa301dc8d6e2fafafed5cf7a 100644 (file)
@@ -19,7 +19,7 @@ public:
        CorrelationMeter(QWidget *parent);
 
        void set_correlation(float correlation) {
-               std::unique_lock<std::mutex> lock(correlation_mutex);
+               std::lock_guard<std::mutex> lock(correlation_mutex);
                this->correlation = correlation;
                QMetaObject::invokeMethod(this, "update", Qt::AutoConnection);
        }
index bd59b32a5a3abb0eb762c89ed49fcc8991bc75fc..ed66212a26bf0ddfa0ab0cfac4214f6b7430d7e8 100644 (file)
@@ -317,7 +317,7 @@ void DeckLinkOutput::send_frame(GLuint y_tex, GLuint cbcr_tex, YCbCrLumaCoeffici
        frame->duration = duration;
 
        {
-               unique_lock<mutex> lock(frame_queue_mutex);
+               lock_guard<mutex> lock(frame_queue_mutex);
                pending_video_frames.push(move(frame));
        }
        frame_queues_changed.notify_all();
index 5f695702e7ffcbc3adb63127298afffec7b93f92..4b6840b1327508a2027364fcd196a6924a1a8252 100644 (file)
@@ -63,7 +63,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<mutex> lock(all_images_lock);
+               lock_guard<mutex> lock(all_images_lock);
                if (all_images[pathname] != current_image) {
                        current_image = all_images[pathname];
                        set_pixel_data(current_image->pixels.get());
@@ -74,7 +74,7 @@ void ImageInput::set_gl_state(GLuint glsl_program_num, const string& prefix, uns
 
 shared_ptr<const ImageInput::Image> ImageInput::load_image(const string &filename, const string &pathname)
 {
-       unique_lock<mutex> lock(all_images_lock);  // Held also during loading.
+       lock_guard<mutex> lock(all_images_lock);  // Held also during loading.
        if (all_images.count(pathname)) {
                return all_images[pathname];
        }
@@ -234,7 +234,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<mutex> lock(all_images_lock);
+               lock_guard<mutex> lock(all_images_lock);
                all_images[pathname] = image;
                last_modified = image->last_modified;
        }
@@ -243,7 +243,7 @@ void ImageInput::update_thread_func(const std::string &filename, const std::stri
 void ImageInput::shutdown_updaters()
 {
        {
-               unique_lock<mutex> lock(threads_should_quit_mu);
+               lock_guard<mutex> lock(threads_should_quit_mu);
                threads_should_quit = true;
                threads_should_quit_modified.notify_all();
        }
index 62b4a9f923134b101f91254bdae5bff4398a88ed..087a40ec1f083bcb83e0c30394c9871d182ad323 100644 (file)
@@ -30,7 +30,7 @@ void LRAMeter::paintEvent(QPaintEvent *event)
        float range_low_lufs;
        float range_high_lufs;
        {
-               unique_lock<mutex> lock(level_mutex);
+               lock_guard<mutex> lock(level_mutex);
                level_lufs = this->level_lufs;
                range_low_lufs = this->range_low_lufs;
                range_high_lufs = this->range_high_lufs;
index 7a832dfcd2cc7d4336b239a5b6ffafa49c48b2e0..f4cca8276a67de62b017252808d4bac1e60c6575 100644 (file)
@@ -21,7 +21,7 @@ public:
        LRAMeter(QWidget *parent);
 
        void set_levels(float level_lufs, float range_low_lufs, float range_high_lufs) {
-               std::unique_lock<std::mutex> lock(level_mutex);
+               std::lock_guard<std::mutex> lock(level_mutex);
                this->level_lufs = level_lufs;
                this->range_low_lufs = range_low_lufs;
                this->range_high_lufs = range_high_lufs;
index c25b22dc711fa528c2720493504f9bebcfe12f3b..23ad51480e78be9cd4ab52b9d086305415e3b99e 100644 (file)
@@ -829,7 +829,7 @@ void Mixer::bm_frame(unsigned card_index, uint16_t timecode,
                // Still send on the information that we _had_ a frame, even though it's corrupted,
                // so that pts can go up accordingly.
                {
-                       unique_lock<mutex> lock(card_mutex);
+                       lock_guard<mutex> lock(card_mutex);
                        CaptureCard::NewFrame new_frame;
                        new_frame.frame = RefCountedFrame(FrameAllocator::Frame());
                        new_frame.length = frame_length;
@@ -953,7 +953,7 @@ void Mixer::bm_frame(unsigned card_index, uint16_t timecode,
                }
 
                {
-                       unique_lock<mutex> lock(card_mutex);
+                       lock_guard<mutex> lock(card_mutex);
                        CaptureCard::NewFrame new_frame;
                        new_frame.frame = frame;
                        new_frame.length = frame_length;
@@ -1348,7 +1348,7 @@ void Mixer::schedule_audio_resampling_tasks(unsigned dropped_frames, int num_sam
                        // non-dropped frame; perhaps we should just discard that as well,
                        // since dropped frames are expected to be rare, and it might be
                        // better to just wait until we have a slightly more normal situation).
-                       unique_lock<mutex> lock(audio_mutex);
+                       lock_guard<mutex> lock(audio_mutex);
                        bool adjust_rate = !dropped_frame && !is_preroll;
                        audio_task_queue.push(AudioTask{pts_int, num_samples_per_frame, adjust_rate, frame_timestamp});
                        audio_task_queue_changed.notify_one();
@@ -1372,7 +1372,7 @@ void Mixer::render_one_frame(int64_t duration)
 
        // Update Y'CbCr settings for all cards.
        {
-               unique_lock<mutex> lock(card_mutex);
+               lock_guard<mutex> lock(card_mutex);
                for (unsigned card_index = 0; card_index < num_cards; ++card_index) {
                        YCbCrInterpretation *interpretation = &ycbcr_interpretation[card_index];
                        input_state.ycbcr_coefficients_auto[card_index] = interpretation->ycbcr_coefficients_auto;
@@ -1578,13 +1578,13 @@ void Mixer::channel_clicked(int preview_num)
 
 YCbCrInterpretation Mixer::get_input_ycbcr_interpretation(unsigned card_index) const
 {
-       unique_lock<mutex> lock(card_mutex);
+       lock_guard<mutex> lock(card_mutex);
        return ycbcr_interpretation[card_index];
 }
 
 void Mixer::set_input_ycbcr_interpretation(unsigned card_index, const YCbCrInterpretation &interpretation)
 {
-       unique_lock<mutex> lock(card_mutex);
+       lock_guard<mutex> lock(card_mutex);
        ycbcr_interpretation[card_index] = interpretation;
 }
 
@@ -1608,7 +1608,7 @@ void Mixer::start_mode_scanning(unsigned card_index)
 map<uint32_t, VideoMode> Mixer::get_available_output_video_modes() const
 {
        assert(desired_output_card_index != -1);
-       unique_lock<mutex> lock(card_mutex);
+       lock_guard<mutex> lock(card_mutex);
        return cards[desired_output_card_index].output->get_available_video_modes();
 }
 
@@ -1646,7 +1646,7 @@ void Mixer::OutputChannel::output_frame(DisplayFrame &&frame)
        // Store this frame for display. Remove the ready frame if any
        // (it was seemingly never used).
        {
-               unique_lock<mutex> lock(frame_mutex);
+               lock_guard<mutex> lock(frame_mutex);
                if (has_ready_frame) {
                        parent->release_display_frame(&ready_frame);
                }
@@ -1701,7 +1701,7 @@ void Mixer::OutputChannel::output_frame(DisplayFrame &&frame)
 
 bool Mixer::OutputChannel::get_display_frame(DisplayFrame *frame)
 {
-       unique_lock<mutex> lock(frame_mutex);
+       lock_guard<mutex> lock(frame_mutex);
        if (!has_current_frame && !has_ready_frame) {
                return false;
        }
@@ -1726,13 +1726,13 @@ bool Mixer::OutputChannel::get_display_frame(DisplayFrame *frame)
 
 void Mixer::OutputChannel::add_frame_ready_callback(void *key, Mixer::new_frame_ready_callback_t callback)
 {
-       unique_lock<mutex> lock(frame_mutex);
+       lock_guard<mutex> lock(frame_mutex);
        new_frame_ready_callbacks[key] = callback;
 }
 
 void Mixer::OutputChannel::remove_frame_ready_callback(void *key)
 {
-       unique_lock<mutex> lock(frame_mutex);
+       lock_guard<mutex> lock(frame_mutex);
        new_frame_ready_callbacks.erase(key);
 }
 
index 2e64ceee9aa35b11b1016fa4674b56fdaa1f3859..edda9b20bd87f6cd2c74cea7eb86f3024d381e7f 100644 (file)
@@ -29,7 +29,7 @@ void NageruCefApp::initialize_cef()
 
 void NageruCefApp::close_browser(CefRefPtr<CefBrowser> browser)
 {
-       unique_lock<mutex> lock(cef_mutex);
+       lock_guard<mutex> lock(cef_mutex);
        browser->GetHost()->CloseBrowser(/*force_close=*/true);
 }
 
index c8687025e2f2f1d5dc0d193a07035b01e272f970..6211937b701f21dc2bdfbe916781f71f4629fb6b 100644 (file)
@@ -261,7 +261,7 @@ bmusb::FrameAllocator::Frame PBOFrameAllocator::alloc_frame()
 {
         Frame vf;
 
-       unique_lock<mutex> lock(freelist_mutex);  // Meh.
+       lock_guard<mutex> lock(freelist_mutex);  // Meh.
        if (freelist.empty()) {
                printf("Frame overrun (no more spare PBO frames), dropping frame!\n");
        } else {
@@ -309,7 +309,7 @@ void PBOFrameAllocator::release_frame(Frame frame)
        }
 #endif
 
-       unique_lock<mutex> lock(freelist_mutex);
+       lock_guard<mutex> lock(freelist_mutex);
        freelist.push(frame);
        //--sumsum;
 }
index 4d53b0b499bdd1c9032f824172bb434bd42b70bd..4883554c5b5d1b52e5146b666528dcee956fcf38 100644 (file)
@@ -1023,7 +1023,7 @@ void QuickSyncEncoderImpl::update_ReferenceFrames(int current_display_frame, int
     pic_param.CurrPic.frame_idx = current_ref_frame_num;
 
     CurrentCurrPic.flags = VA_PICTURE_H264_SHORT_TERM_REFERENCE;
-    unique_lock<mutex> lock(storage_task_queue_mutex);
+    lock_guard<mutex> lock(storage_task_queue_mutex);
 
     // Insert the new frame at the start of the reference queue.
     reference_frames.push_front(ReferenceFrame{ CurrentCurrPic, current_display_frame });
@@ -1434,7 +1434,7 @@ void QuickSyncEncoderImpl::save_codeddata(GLSurface *surf, storage_task task)
 // this is weird. but it seems to put a new frame onto the queue
 void QuickSyncEncoderImpl::storage_task_enqueue(storage_task task)
 {
-       unique_lock<mutex> lock(storage_task_queue_mutex);
+       lock_guard<mutex> lock(storage_task_queue_mutex);
        storage_task_queue.push(move(task));
        storage_task_queue_changed.notify_all();
 }
@@ -1468,7 +1468,7 @@ void QuickSyncEncoderImpl::storage_task_thread()
 
                // Unlock the frame, and all its references.
                {
-                       unique_lock<mutex> lock(storage_task_queue_mutex);
+                       lock_guard<mutex> lock(storage_task_queue_mutex);
                        release_gl_surface(display_order);
 
                        for (size_t frame_num : ref_display_frame_numbers) {
@@ -1706,7 +1706,7 @@ RefCountedGLsync QuickSyncEncoderImpl::end_frame()
                GLenum type = global_flags.x264_bit_depth > 8 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_BYTE;
                GLSurface *surf;
                {
-                       unique_lock<mutex> lock(storage_task_queue_mutex);
+                       lock_guard<mutex> lock(storage_task_queue_mutex);
                        surf = surface_for_frame[current_storage_frame];
                        assert(surf != nullptr);
                }
@@ -1745,7 +1745,7 @@ RefCountedGLsync QuickSyncEncoderImpl::end_frame()
        check_error();
 
        {
-               unique_lock<mutex> lock(frame_queue_mutex);
+               lock_guard<mutex> lock(frame_queue_mutex);
                current_video_frame.fence = fence;
                pending_video_frames.push(move(current_video_frame));
                ++current_storage_frame;
@@ -1761,13 +1761,13 @@ void QuickSyncEncoderImpl::shutdown()
        }
 
        {
-               unique_lock<mutex> lock(frame_queue_mutex);
+               lock_guard<mutex> lock(frame_queue_mutex);
                encode_thread_should_quit = true;
                frame_queue_nonempty.notify_all();
        }
        encode_thread.join();
        {
-               unique_lock<mutex> lock(storage_task_queue_mutex);
+               lock_guard<mutex> lock(storage_task_queue_mutex);
                storage_thread_should_quit = true;
                frame_queue_nonempty.notify_all();
                storage_task_queue_changed.notify_all();
@@ -1864,7 +1864,7 @@ void QuickSyncEncoderImpl::encode_thread_func()
                pass_frame(frame, display_frame_num, frame.pts, frame.duration);
 
                if (global_flags.x264_video_to_disk) {
-                       unique_lock<mutex> lock(storage_task_queue_mutex);
+                       lock_guard<mutex> lock(storage_task_queue_mutex);
                        release_gl_surface(display_frame_num);
                        continue;
                }
@@ -1887,7 +1887,7 @@ void QuickSyncEncoderImpl::encode_thread_func()
                        if (frame_type == FRAME_IDR) {
                                // Release any reference frames from the previous GOP.
                                {
-                                       unique_lock<mutex> lock(storage_task_queue_mutex);
+                                       lock_guard<mutex> lock(storage_task_queue_mutex);
                                        for (const ReferenceFrame &frame : reference_frames) {
                                                release_gl_surface(frame.display_number);
                                        }
@@ -1980,7 +1980,7 @@ void QuickSyncEncoderImpl::pass_frame(QuickSyncEncoderImpl::PendingFrame frame,
 
        GLSurface *surf;
        {
-               unique_lock<mutex> lock(storage_task_queue_mutex);
+               lock_guard<mutex> lock(storage_task_queue_mutex);
                surf = surface_for_frame[display_frame_num];
                assert(surf != nullptr);
        }
@@ -1999,7 +1999,7 @@ void QuickSyncEncoderImpl::encode_frame(QuickSyncEncoderImpl::PendingFrame frame
 
        GLSurface *surf;
        {
-               unique_lock<mutex> lock(storage_task_queue_mutex);
+               lock_guard<mutex> lock(storage_task_queue_mutex);
                surf = surface_for_frame[display_frame_num];
                assert(surf != nullptr);
        }
@@ -2063,7 +2063,7 @@ void QuickSyncEncoderImpl::encode_frame(QuickSyncEncoderImpl::PendingFrame frame
        // Lock the references for this frame; otherwise, they could be
        // rendered to before this frame is done encoding.
        {
-               unique_lock<mutex> lock(storage_task_queue_mutex);
+               lock_guard<mutex> lock(storage_task_queue_mutex);
                for (const ReferenceFrame &frame : reference_frames) {
                        assert(surface_for_frame.count(frame.display_number));
                        ++surface_for_frame[frame.display_number]->refcount;
index d28f5b2501030b0911b342a4124b95b1538e98c2..386a425fd024be011e1d4591f05b655db92007c8 100644 (file)
@@ -100,7 +100,7 @@ class LuaRefWithDeleter {
 public:
        LuaRefWithDeleter(mutex *m, lua_State *L, int ref) : m(m), L(L), ref(ref) {}
        ~LuaRefWithDeleter() {
-               unique_lock<mutex> lock(*m);
+               lock_guard<mutex> lock(*m);
                luaL_unref(L, LUA_REGISTRYINDEX, ref);
        }
        int get() const { return ref; }
@@ -1221,7 +1221,7 @@ Theme::Chain Theme::get_chain(unsigned num, float t, unsigned width, unsigned he
 {
        Chain chain;
 
-       unique_lock<mutex> lock(m);
+       lock_guard<mutex> lock(m);
        assert(lua_gettop(L) == 0);
        lua_getglobal(L, "get_chain");  /* function to be called */
        lua_pushnumber(L, num);
@@ -1252,7 +1252,7 @@ Theme::Chain Theme::get_chain(unsigned num, float t, unsigned width, unsigned he
        assert(lua_gettop(L) == 0);
 
        chain.setup_chain = [this, funcref, input_state, effect_chain]{
-               unique_lock<mutex> lock(m);
+               lock_guard<mutex> lock(m);
 
                assert(this->input_state == nullptr);
                this->input_state = &input_state;
@@ -1297,7 +1297,7 @@ Theme::Chain Theme::get_chain(unsigned num, float t, unsigned width, unsigned he
 
 string Theme::get_channel_name(unsigned channel)
 {
-       unique_lock<mutex> lock(m);
+       lock_guard<mutex> lock(m);
        lua_getglobal(L, "channel_name");
        lua_pushnumber(L, channel);
        if (lua_pcall(L, 1, 1, 0) != 0) {
@@ -1318,7 +1318,7 @@ string Theme::get_channel_name(unsigned channel)
 
 int Theme::get_channel_signal(unsigned channel)
 {
-       unique_lock<mutex> lock(m);
+       lock_guard<mutex> lock(m);
        lua_getglobal(L, "channel_signal");
        lua_pushnumber(L, channel);
        if (lua_pcall(L, 1, 1, 0) != 0) {
@@ -1334,7 +1334,7 @@ int Theme::get_channel_signal(unsigned channel)
 
 std::string Theme::get_channel_color(unsigned channel)
 {
-       unique_lock<mutex> lock(m);
+       lock_guard<mutex> lock(m);
        lua_getglobal(L, "channel_color");
        lua_pushnumber(L, channel);
        if (lua_pcall(L, 1, 1, 0) != 0) {
@@ -1356,7 +1356,7 @@ std::string Theme::get_channel_color(unsigned channel)
 
 bool Theme::get_supports_set_wb(unsigned channel)
 {
-       unique_lock<mutex> lock(m);
+       lock_guard<mutex> lock(m);
        lua_getglobal(L, "supports_set_wb");
        lua_pushnumber(L, channel);
        if (lua_pcall(L, 1, 1, 0) != 0) {
@@ -1372,7 +1372,7 @@ bool Theme::get_supports_set_wb(unsigned channel)
 
 void Theme::set_wb(unsigned channel, double r, double g, double b)
 {
-       unique_lock<mutex> lock(m);
+       lock_guard<mutex> lock(m);
        lua_getglobal(L, "set_wb");
        lua_pushnumber(L, channel);
        lua_pushnumber(L, r);
@@ -1388,7 +1388,7 @@ void Theme::set_wb(unsigned channel, double r, double g, double b)
 
 vector<string> Theme::get_transition_names(float t)
 {
-       unique_lock<mutex> lock(m);
+       lock_guard<mutex> lock(m);
        lua_getglobal(L, "get_transitions");
        lua_pushnumber(L, t);
        if (lua_pcall(L, 1, 1, 0) != 0) {
@@ -1414,7 +1414,7 @@ int Theme::map_signal(int signal_num)
                return -1 - signal_num;
        }
 
-       unique_lock<mutex> lock(map_m);
+       lock_guard<mutex> lock(map_m);
        if (signal_to_card_mapping.count(signal_num)) {
                return signal_to_card_mapping[signal_num];
        }
@@ -1444,14 +1444,14 @@ int Theme::map_signal(int signal_num)
 
 void Theme::set_signal_mapping(int signal_num, int card_num)
 {
-       unique_lock<mutex> lock(map_m);
+       lock_guard<mutex> lock(map_m);
        assert(card_num < int(num_cards));
        signal_to_card_mapping[signal_num] = card_num;
 }
 
 void Theme::transition_clicked(int transition_num, float t)
 {
-       unique_lock<mutex> lock(m);
+       lock_guard<mutex> lock(m);
        lua_getglobal(L, "transition_clicked");
        lua_pushnumber(L, transition_num);
        lua_pushnumber(L, t);
@@ -1465,7 +1465,7 @@ void Theme::transition_clicked(int transition_num, float t)
 
 void Theme::channel_clicked(int preview_num)
 {
-       unique_lock<mutex> lock(m);
+       lock_guard<mutex> lock(m);
        lua_getglobal(L, "channel_clicked");
        lua_pushnumber(L, preview_num);
 
@@ -1507,7 +1507,7 @@ int Theme::set_theme_menu(lua_State *L)
 
 void Theme::theme_menu_entry_clicked(int lua_ref)
 {
-       unique_lock<mutex> lock(m);
+       lock_guard<mutex> lock(m);
        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));
index b697a834da3876533c06db888c16a42e8f209067..228d2c277c57f2802c0fb574a3b8e34633e0af84 100644 (file)
@@ -25,7 +25,7 @@ void VUMeter::paintEvent(QPaintEvent *event)
 
        float level_lufs[2], peak_lufs[2];
        {
-               unique_lock<mutex> lock(level_mutex);
+               lock_guard<mutex> lock(level_mutex);
                level_lufs[0] = this->level_lufs[0];
                level_lufs[1] = this->level_lufs[1];
                peak_lufs[0] = this->peak_lufs[0];
index 7a9420058358f30047f8f2d3645eaa972ec51895..f58eeff9d67e1582ad6f85913599201204d34776 100644 (file)
@@ -25,7 +25,7 @@ public:
        }
 
        void set_level(float level_lufs_left, float level_lufs_right) {
-               std::unique_lock<std::mutex> lock(level_mutex);
+               std::lock_guard<std::mutex> lock(level_mutex);
                this->level_lufs[0] = level_lufs_left;
                this->level_lufs[1] = level_lufs_right;
                QMetaObject::invokeMethod(this, "update", Qt::AutoConnection);
@@ -36,7 +36,7 @@ public:
        }
 
        void set_peak(float peak_lufs_left, float peak_lufs_right) {
-               std::unique_lock<std::mutex> lock(level_mutex);
+               std::lock_guard<std::mutex> lock(level_mutex);
                this->peak_lufs[0] = peak_lufs_left;
                this->peak_lufs[1] = peak_lufs_right;
                QMetaObject::invokeMethod(this, "update", Qt::AutoConnection);
index 782d18b7e2f7b2924bbf4e23365494dcfe423be0..5442e7f123f7533b9740fc244241acd9123b1703 100644 (file)
@@ -61,7 +61,7 @@ void HTTPD::stop()
 
 void HTTPD::add_data(StreamType stream_type, const char *buf, size_t size, bool keyframe, int64_t time, AVRational timebase)
 {
-       unique_lock<mutex> lock(streams_mutex);
+       lock_guard<mutex> lock(streams_mutex);
        for (Stream *stream : streams) {
                if (stream->get_stream_type() == stream_type) {
                        stream->add_data(buf, size, keyframe ? Stream::DATA_TYPE_KEYFRAME : Stream::DATA_TYPE_OTHER, time, timebase);
@@ -133,7 +133,7 @@ int HTTPD::answer_to_connection(MHD_Connection *connection,
        HTTPD::Stream *stream = new HTTPD::Stream(this, framing, stream_type);
        stream->add_data(header[stream_type].data(), header[stream_type].size(), Stream::DATA_TYPE_HEADER, AV_NOPTS_VALUE, AVRational{ 1, 0 });
        {
-               unique_lock<mutex> lock(streams_mutex);
+               lock_guard<mutex> lock(streams_mutex);
                streams.insert(stream);
        }
        ++metric_num_connected_clients;
@@ -164,7 +164,7 @@ void HTTPD::free_stream(void *cls)
                --httpd->metric_num_connected_multicam_clients;
        }
        {
-               unique_lock<mutex> lock(httpd->streams_mutex);
+               lock_guard<mutex> lock(httpd->streams_mutex);
                delete stream;
                httpd->streams.erase(stream);
        }
@@ -223,7 +223,7 @@ void HTTPD::Stream::add_data(const char *buf, size_t buf_size, HTTPD::Stream::Da
                return;
        }
 
-       unique_lock<mutex> lock(buffer_mutex);
+       lock_guard<mutex> lock(buffer_mutex);
 
        if (framing == FRAMING_METACUBE) {
                int flags = 0;
@@ -284,7 +284,7 @@ void HTTPD::Stream::add_data(const char *buf, size_t buf_size, HTTPD::Stream::Da
 
 void HTTPD::Stream::stop()
 {
-       unique_lock<mutex> lock(buffer_mutex);
+       lock_guard<mutex> lock(buffer_mutex);
        should_quit = true;
        has_buffered_data.notify_all();
 }