#include <movit/resource_pool.h> // Must be above the Xlib includes.
#include <pthread.h>
+#include <mutex>
+
#include <epoxy/egl.h>
#include "chroma_subsampler.h"
#include "decklink_util.h"
#include "flags.h"
#include "print_latency.h"
-#include "resource_pool.h"
#include "timebase.h"
#include "v210_converter.h"
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<int64_t> metric_decklink_output_width_pixels{-1};
atomic<int64_t> metric_decklink_output_height_pixels{-1};
{
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);
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)
last_frame_had_mode_mismatch = false;
}
- unique_ptr<Frame> frame = move(get_frame());
+ unique_ptr<Frame> frame = get_frame();
if (global_flags.ten_bit_output) {
chroma_subsampler->create_v210(y_tex, cbcr_tex, width, height, frame->uyvy_tex);
} else {