X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=decklink_output.cpp;h=a19d0a5e2e44440c9f79ad07f860ec629e194c37;hb=afe163c940b7239cab0577fa390796175cdc94a6;hp=17cc520d25964fca766d511fd653ef8c2e68b2d1;hpb=dccb8335c91044493b7d6b236892feef655abf1e;p=nageru diff --git a/decklink_output.cpp b/decklink_output.cpp index 17cc520..a19d0a5 100644 --- a/decklink_output.cpp +++ b/decklink_output.cpp @@ -3,6 +3,8 @@ #include // Must be above the Xlib includes. #include +#include + #include #include "chroma_subsampler.h" @@ -20,7 +22,7 @@ using namespace std::chrono; namespace { // This class can be deleted during regular use, so make all the metrics static. -bool metrics_inited = false; +once_flag decklink_metrics_inited; LatencyHistogram latency_histogram; atomic metric_decklink_output_width_pixels{-1}; atomic metric_decklink_output_height_pixels{-1}; @@ -49,7 +51,7 @@ DeckLinkOutput::DeckLinkOutput(ResourcePool *resource_pool, QSurface *surface, u { chroma_subsampler.reset(new ChromaSubsampler(resource_pool)); - if (!metrics_inited) { + call_once(decklink_metrics_inited, [](){ latency_histogram.init("decklink_output"); global_metrics.add("decklink_output_width_pixels", &metric_decklink_output_width_pixels, Metrics::TYPE_GAUGE); global_metrics.add("decklink_output_height_pixels", &metric_decklink_output_height_pixels, Metrics::TYPE_GAUGE); @@ -70,9 +72,7 @@ DeckLinkOutput::DeckLinkOutput(ResourcePool *resource_pool, QSurface *surface, u global_metrics.add("decklink_output_completed_frames", {{ "status", "unknown" }}, &metric_decklink_output_completed_frames_unknown); global_metrics.add("decklink_output_scheduled_samples", &metric_decklink_output_scheduled_samples); - - metrics_inited = true; - } + }); } void DeckLinkOutput::set_device(IDeckLink *decklink) @@ -262,7 +262,7 @@ void DeckLinkOutput::send_frame(GLuint y_tex, GLuint cbcr_tex, YCbCrLumaCoeffici last_frame_had_mode_mismatch = false; } - unique_ptr frame = move(get_frame()); + unique_ptr frame = get_frame(); if (global_flags.ten_bit_output) { chroma_subsampler->create_v210(y_tex, cbcr_tex, width, height, frame->uyvy_tex); } else {