mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-29 21:21:12 +00:00
qsv: Use std::once_flag
GLib's once implementation will take mutex every time in case of non-GCC build Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4005>
This commit is contained in:
parent
5eb4253547
commit
e48869e269
7 changed files with 37 additions and 37 deletions
|
@ -83,11 +83,10 @@ gst_qsv_av1_enc_rate_control_get_type (void)
|
||||||
{0, nullptr, nullptr}
|
{0, nullptr, nullptr}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (g_once_init_enter (&rate_control_type)) {
|
GST_QSV_CALL_ONCE_BEGIN {
|
||||||
GType type =
|
rate_control_type =
|
||||||
g_enum_register_static ("GstQsvAV1EncRateControl", rate_controls);
|
g_enum_register_static ("GstQsvAV1EncRateControl", rate_controls);
|
||||||
g_once_init_leave (&rate_control_type, type);
|
} GST_QSV_CALL_ONCE_END;
|
||||||
}
|
|
||||||
|
|
||||||
return rate_control_type;
|
return rate_control_type;
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,11 +74,10 @@ gst_qsv_coding_option_get_type (void)
|
||||||
{0, nullptr, nullptr}
|
{0, nullptr, nullptr}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (g_once_init_enter (&coding_opt_type)) {
|
GST_QSV_CALL_ONCE_BEGIN {
|
||||||
GType type = g_enum_register_static ("GstQsvCodingOption",
|
coding_opt_type = g_enum_register_static ("GstQsvCodingOption",
|
||||||
coding_opts);
|
coding_opts);
|
||||||
g_once_init_leave (&coding_opt_type, type);
|
} GST_QSV_CALL_ONCE_END;
|
||||||
}
|
|
||||||
|
|
||||||
return coding_opt_type;
|
return coding_opt_type;
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,11 +95,10 @@ gst_qsv_h264_enc_sei_insert_mode_get_type (void)
|
||||||
{0, nullptr, nullptr}
|
{0, nullptr, nullptr}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (g_once_init_enter (&sei_insert_mode_type)) {
|
GST_QSV_CALL_ONCE_BEGIN {
|
||||||
GType type =
|
sei_insert_mode_type =
|
||||||
g_enum_register_static ("GstQsvH264EncSeiInsertMode", insert_modes);
|
g_enum_register_static ("GstQsvH264EncSeiInsertMode", insert_modes);
|
||||||
g_once_init_leave (&sei_insert_mode_type, type);
|
} GST_QSV_CALL_ONCE_END;
|
||||||
}
|
|
||||||
|
|
||||||
return sei_insert_mode_type;
|
return sei_insert_mode_type;
|
||||||
}
|
}
|
||||||
|
@ -188,11 +187,10 @@ gst_qsv_h264_enc_rate_control_get_type (void)
|
||||||
{0, nullptr, nullptr}
|
{0, nullptr, nullptr}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (g_once_init_enter (&rate_control_type)) {
|
GST_QSV_CALL_ONCE_BEGIN {
|
||||||
GType type =
|
rate_control_type =
|
||||||
g_enum_register_static ("GstQsvH264EncRateControl", rate_controls);
|
g_enum_register_static ("GstQsvH264EncRateControl", rate_controls);
|
||||||
g_once_init_leave (&rate_control_type, type);
|
} GST_QSV_CALL_ONCE_END;
|
||||||
}
|
|
||||||
|
|
||||||
return rate_control_type;
|
return rate_control_type;
|
||||||
}
|
}
|
||||||
|
@ -240,11 +238,10 @@ gst_qsv_h264_enc_rc_lookahead_ds_get_type (void)
|
||||||
{0, nullptr, nullptr}
|
{0, nullptr, nullptr}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (g_once_init_enter (&rc_lookahead_ds_type)) {
|
GST_QSV_CALL_ONCE_BEGIN {
|
||||||
GType type =
|
rc_lookahead_ds_type =
|
||||||
g_enum_register_static ("GstQsvH264EncRCLookAheadDS", rc_lookahead_ds);
|
g_enum_register_static ("GstQsvH264EncRCLookAheadDS", rc_lookahead_ds);
|
||||||
g_once_init_leave (&rc_lookahead_ds_type, type);
|
} GST_QSV_CALL_ONCE_END;
|
||||||
}
|
|
||||||
|
|
||||||
return rc_lookahead_ds_type;
|
return rc_lookahead_ds_type;
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,11 +94,10 @@ gst_qsv_h265_enc_sei_insert_mode_get_type (void)
|
||||||
{0, nullptr, nullptr}
|
{0, nullptr, nullptr}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (g_once_init_enter (&sei_insert_mode_type)) {
|
GST_QSV_CALL_ONCE_BEGIN {
|
||||||
GType type =
|
sei_insert_mode_type =
|
||||||
g_enum_register_static ("GstQsvH265EncSeiInsertMode", insert_modes);
|
g_enum_register_static ("GstQsvH265EncSeiInsertMode", insert_modes);
|
||||||
g_once_init_leave (&sei_insert_mode_type, type);
|
} GST_QSV_CALL_ONCE_END;
|
||||||
}
|
|
||||||
|
|
||||||
return sei_insert_mode_type;
|
return sei_insert_mode_type;
|
||||||
}
|
}
|
||||||
|
@ -158,11 +157,10 @@ gst_qsv_h265_enc_rate_control_get_type (void)
|
||||||
{0, nullptr, nullptr}
|
{0, nullptr, nullptr}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (g_once_init_enter (&rate_control_type)) {
|
GST_QSV_CALL_ONCE_BEGIN {
|
||||||
GType type =
|
rate_control_type =
|
||||||
g_enum_register_static ("GstQsvH265EncRateControl", rate_controls);
|
g_enum_register_static ("GstQsvH265EncRateControl", rate_controls);
|
||||||
g_once_init_leave (&rate_control_type, type);
|
} GST_QSV_CALL_ONCE_END;
|
||||||
}
|
|
||||||
|
|
||||||
return rate_control_type;
|
return rate_control_type;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,12 +39,9 @@ static mfxLoader _loader = nullptr;
|
||||||
mfxLoader
|
mfxLoader
|
||||||
gst_qsv_get_loader (void)
|
gst_qsv_get_loader (void)
|
||||||
{
|
{
|
||||||
static gsize load_once = 0;
|
GST_QSV_CALL_ONCE_BEGIN {
|
||||||
|
|
||||||
if (g_once_init_enter (&load_once)) {
|
|
||||||
_loader = MFXLoad ();
|
_loader = MFXLoad ();
|
||||||
g_once_init_leave (&load_once, 1);
|
} GST_QSV_CALL_ONCE_END;
|
||||||
}
|
|
||||||
|
|
||||||
return _loader;
|
return _loader;
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,3 +76,14 @@ static const GstQsvResolution gst_qsv_resolutions[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
|
#define GST_QSV_CALL_ONCE_BEGIN \
|
||||||
|
static std::once_flag __once_flag; \
|
||||||
|
std::call_once (__once_flag, [&]()
|
||||||
|
|
||||||
|
#define GST_QSV_CALL_ONCE_END )
|
||||||
|
|
||||||
|
#endif /* __cplusplus */
|
|
@ -91,11 +91,10 @@ gst_qsv_vp9_enc_rate_control_get_type (void)
|
||||||
{0, nullptr, nullptr}
|
{0, nullptr, nullptr}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (g_once_init_enter (&rate_control_type)) {
|
GST_QSV_CALL_ONCE_BEGIN {
|
||||||
GType type =
|
rate_control_type =
|
||||||
g_enum_register_static ("GstQsvVP9EncRateControl", rate_controls);
|
g_enum_register_static ("GstQsvVP9EncRateControl", rate_controls);
|
||||||
g_once_init_leave (&rate_control_type, type);
|
} GST_QSV_CALL_ONCE_END;
|
||||||
}
|
|
||||||
|
|
||||||
return rate_control_type;
|
return rate_control_type;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue