#include "gstformat.h"
#include "gstenumtypes.h"
-static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
+static GMutex mutex;
static GList *_gst_formats = NULL;
static GHashTable *_nick_to_format = NULL;
static GHashTable *_format_to_nick = NULL;
{
GstFormatDefinition *standards = standard_definitions;
- g_static_mutex_lock (&mutex);
+ g_mutex_lock (&mutex);
if (_nick_to_format == NULL) {
_nick_to_format = g_hash_table_new (g_str_hash, g_str_equal);
_format_to_nick = g_hash_table_new (NULL, NULL);
}
/* getting the type registers the enum */
g_type_class_ref (gst_format_get_type ());
- g_static_mutex_unlock (&mutex);
+ g_mutex_unlock (&mutex);
}
/**
if (query != GST_FORMAT_UNDEFINED)
return query;
- g_static_mutex_lock (&mutex);
+ g_mutex_lock (&mutex);
format = g_slice_new (GstFormatDefinition);
format->value = (GstFormat) _n_values;
format->nick = g_strdup (nick);
format);
_gst_formats = g_list_append (_gst_formats, format);
_n_values++;
- g_static_mutex_unlock (&mutex);
+ g_mutex_unlock (&mutex);
return format->value;
}
g_return_val_if_fail (nick != NULL, GST_FORMAT_UNDEFINED);
- g_static_mutex_lock (&mutex);
+ g_mutex_lock (&mutex);
format = g_hash_table_lookup (_nick_to_format, nick);
- g_static_mutex_unlock (&mutex);
+ g_mutex_unlock (&mutex);
if (format != NULL)
return format->value;
{
const GstFormatDefinition *result;
- g_static_mutex_lock (&mutex);
+ g_mutex_lock (&mutex);
result = g_hash_table_lookup (_format_to_nick, GINT_TO_POINTER (format));
- g_static_mutex_unlock (&mutex);
+ g_mutex_unlock (&mutex);
return result;
}
{
GstIterator *result;
- g_static_mutex_lock (&mutex);
+ g_mutex_lock (&mutex);
/* FIXME: register a boxed type for GstFormatDefinition */
result = gst_iterator_new_list (G_TYPE_POINTER,
- g_static_mutex_get_mutex (&mutex), &_n_values, &_gst_formats, NULL, NULL);
- g_static_mutex_unlock (&mutex);
+ &mutex, &_n_values, &_gst_formats, NULL, NULL);
+ g_mutex_unlock (&mutex);
return result;
}
};
/* list of all name/level pairs from --gst-debug and GST_DEBUG */
-static GStaticMutex __level_name_mutex = G_STATIC_MUTEX_INIT;
+static GMutex __level_name_mutex;
static GSList *__level_name = NULL;
typedef struct
{
LevelNameEntry;
/* list of all categories */
-static GStaticMutex __cat_mutex = G_STATIC_MUTEX_INIT;
+static GMutex __cat_mutex;
static GSList *__categories = NULL;
/* all registered debug handlers */
gpointer user_data;
}
LogFuncEntry;
-static GStaticMutex __log_func_mutex = G_STATIC_MUTEX_INIT;
+static GMutex __log_func_mutex;
static GSList *__log_functions = NULL;
#define PRETTY_TAGS_DEFAULT TRUE
/* colors, windows. We take a lock to keep colors and content together.
* Maybe there is a better way but for now this will do the right
* thing. */
- static GStaticMutex win_print_mutex = G_STATIC_MUTEX_INIT;
+ static GMutex win_print_mutex;
const gint clear = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
#define SET_COLOR(c) G_STMT_START { \
if (log_file == stderr) \
SetConsoleTextAttribute (GetStdHandle (STD_ERROR_HANDLE), (c)); \
} G_STMT_END
- g_static_mutex_lock (&win_print_mutex);
+ g_mutex_lock (&win_print_mutex);
/* timestamp */
fprintf (log_file, "%" GST_TIME_FORMAT " ", GST_TIME_ARGS (elapsed));
fflush (log_file);
SET_COLOR (clear);
fprintf (log_file, " %s\n", gst_debug_message_get (message));
fflush (log_file);
- g_static_mutex_unlock (&win_print_mutex);
+ g_mutex_unlock (&win_print_mutex);
#endif
} else {
/* no color, all platforms */
* It'd probably be clever to use some kind of RCU here, but I don't know
* anything about that.
*/
- g_static_mutex_lock (&__log_func_mutex);
+ g_mutex_lock (&__log_func_mutex);
list = g_slist_copy (__log_functions);
__log_functions = g_slist_prepend (list, entry);
- g_static_mutex_unlock (&__log_func_mutex);
+ g_mutex_unlock (&__log_func_mutex);
GST_DEBUG ("prepended log function %p (user data %p) to log functions",
func, data);
GSList *new;
guint removals = 0;
- g_static_mutex_lock (&__log_func_mutex);
+ g_mutex_lock (&__log_func_mutex);
new = __log_functions;
while ((found = g_slist_find_custom (new, data, func))) {
if (new == __log_functions) {
}
/* FIXME: We leak the old list here. See _add_log_function for why. */
__log_functions = new;
- g_static_mutex_unlock (&__log_func_mutex);
+ g_mutex_unlock (&__log_func_mutex);
return removals;
}
GstDebugCategory *cat = (GstDebugCategory *) category;
GSList *walk;
- g_static_mutex_lock (&__level_name_mutex);
+ g_mutex_lock (&__level_name_mutex);
walk = __level_name;
while (walk) {
LevelNameEntry *entry = walk->data;
gst_debug_category_set_threshold (cat, gst_debug_get_default_threshold ());
exit:
- g_static_mutex_unlock (&__level_name_mutex);
+ g_mutex_unlock (&__level_name_mutex);
}
static void
gst_debug_reset_all_thresholds (void)
{
- g_static_mutex_lock (&__cat_mutex);
+ g_mutex_lock (&__cat_mutex);
g_slist_foreach (__categories, gst_debug_reset_threshold, NULL);
- g_static_mutex_unlock (&__cat_mutex);
+ g_mutex_unlock (&__cat_mutex);
}
static void
entry = g_slice_new (LevelNameEntry);
entry->pat = pat;
entry->level = level;
- g_static_mutex_lock (&__level_name_mutex);
+ g_mutex_lock (&__level_name_mutex);
__level_name = g_slist_prepend (__level_name, entry);
- g_static_mutex_unlock (&__level_name_mutex);
- g_static_mutex_lock (&__cat_mutex);
+ g_mutex_unlock (&__level_name_mutex);
+ g_mutex_lock (&__cat_mutex);
g_slist_foreach (__categories, for_each_threshold_by_entry, entry);
- g_static_mutex_unlock (&__cat_mutex);
+ g_mutex_unlock (&__cat_mutex);
}
/**
g_return_if_fail (name != NULL);
pat = g_pattern_spec_new (name);
- g_static_mutex_lock (&__level_name_mutex);
+ g_mutex_lock (&__level_name_mutex);
walk = __level_name;
/* improve this if you want, it's mighty slow */
while (walk) {
walk = __level_name;
}
}
- g_static_mutex_unlock (&__level_name_mutex);
+ g_mutex_unlock (&__level_name_mutex);
g_pattern_spec_free (pat);
gst_debug_reset_all_thresholds ();
}
gst_debug_reset_threshold (cat, NULL);
/* add to category list */
- g_static_mutex_lock (&__cat_mutex);
+ g_mutex_lock (&__cat_mutex);
__categories = g_slist_prepend (__categories, cat);
- g_static_mutex_unlock (&__cat_mutex);
+ g_mutex_unlock (&__cat_mutex);
return cat;
}
return;
/* remove from category list */
- g_static_mutex_lock (&__cat_mutex);
+ g_mutex_lock (&__cat_mutex);
__categories = g_slist_remove (__categories, category);
- g_static_mutex_unlock (&__cat_mutex);
+ g_mutex_unlock (&__cat_mutex);
g_free ((gpointer) category->name);
g_free ((gpointer) category->description);
{
GSList *ret;
- g_static_mutex_lock (&__cat_mutex);
+ g_mutex_lock (&__cat_mutex);
ret = g_slist_copy (__categories);
- g_static_mutex_unlock (&__cat_mutex);
+ g_mutex_unlock (&__cat_mutex);
return ret;
}
/*** FUNCTION POINTERS ********************************************************/
static GHashTable *__gst_function_pointers; /* NULL */
-static GStaticMutex __dbg_functions_mutex = G_STATIC_MUTEX_INIT;
+static GMutex __dbg_functions_mutex;
/* This function MUST NOT return NULL */
const gchar *
if (G_UNLIKELY (func == NULL))
return "(NULL)";
- g_static_mutex_lock (&__dbg_functions_mutex);
+ g_mutex_lock (&__dbg_functions_mutex);
if (G_LIKELY (__gst_function_pointers)) {
ptrname = g_hash_table_lookup (__gst_function_pointers, (gpointer) func);
- g_static_mutex_unlock (&__dbg_functions_mutex);
+ g_mutex_unlock (&__dbg_functions_mutex);
if (G_LIKELY (ptrname))
return ptrname;
} else {
- g_static_mutex_unlock (&__dbg_functions_mutex);
+ g_mutex_unlock (&__dbg_functions_mutex);
}
/* we need to create an entry in the hash table for this one so we don't leak
* the name */
{
gpointer ptr = (gpointer) func;
- g_static_mutex_lock (&__dbg_functions_mutex);
+ g_mutex_lock (&__dbg_functions_mutex);
if (!__gst_function_pointers)
__gst_function_pointers = g_hash_table_new (g_direct_hash, g_direct_equal);
if (!g_hash_table_lookup (__gst_function_pointers, ptr))
g_hash_table_insert (__gst_function_pointers, ptr, (gpointer) ptrname);
- g_static_mutex_unlock (&__dbg_functions_mutex);
+ g_mutex_unlock (&__dbg_functions_mutex);
}
/*** PRINTF EXTENSIONS ********************************************************/
return (*date_time == '\0');
}
-static GStaticMutex gst_plugin_loading_mutex = G_STATIC_MUTEX_INIT;
+static GMutex gst_plugin_loading_mutex;
#define CHECK_PLUGIN_DESC_FIELD(desc,field,fn) \
if (G_UNLIKELY ((desc)->field == NULL)) { \
g_return_val_if_fail (filename != NULL, NULL);
registry = gst_registry_get ();
- g_static_mutex_lock (&gst_plugin_loading_mutex);
+ g_mutex_lock (&gst_plugin_loading_mutex);
plugin = gst_registry_lookup (registry, filename);
if (plugin) {
if (plugin->module) {
/* already loaded */
- g_static_mutex_unlock (&gst_plugin_loading_mutex);
+ g_mutex_unlock (&gst_plugin_loading_mutex);
return plugin;
} else {
/* load plugin and update fields */
gst_registry_add_plugin (gst_registry_get (), plugin);
}
- g_static_mutex_unlock (&gst_plugin_loading_mutex);
+ g_mutex_unlock (&gst_plugin_loading_mutex);
return plugin;
return_error:
{
if (plugin)
gst_object_unref (plugin);
- g_static_mutex_unlock (&gst_plugin_loading_mutex);
+ g_mutex_unlock (&gst_plugin_loading_mutex);
return NULL;
}
}
#define GST_QUERY_STRUCTURE(q) (((GstQueryImpl *)(q))->structure)
-static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
+static GMutex mutex;
static GList *_gst_queries = NULL;
static GHashTable *_nick_to_query = NULL;
static GHashTable *_query_type_to_nick = NULL;
GST_DEBUG_CATEGORY_INIT (gst_query_debug, "query", 0, "query system");
- g_static_mutex_lock (&mutex);
+ g_mutex_lock (&mutex);
if (_nick_to_query == NULL) {
_nick_to_query = g_hash_table_new (g_str_hash, g_str_equal);
_query_type_to_nick = g_hash_table_new (NULL, NULL);
standards++;
_n_values++;
}
- g_static_mutex_unlock (&mutex);
+ g_mutex_unlock (&mutex);
_gst_query_type = gst_query_get_type ();
}
query->description = g_strdup (description);
query->quark = g_quark_from_static_string (query->nick);
- g_static_mutex_lock (&mutex);
+ g_mutex_lock (&mutex);
g_hash_table_insert (_nick_to_query, (gpointer) query->nick, query);
g_hash_table_insert (_query_type_to_nick, GINT_TO_POINTER (query->value),
query);
_gst_queries = g_list_append (_gst_queries, query);
_n_values++;
- g_static_mutex_unlock (&mutex);
+ g_mutex_unlock (&mutex);
return query->value;
}
g_return_val_if_fail (nick != NULL, GST_QUERY_NONE);
- g_static_mutex_lock (&mutex);
+ g_mutex_lock (&mutex);
query = g_hash_table_lookup (_nick_to_query, nick);
- g_static_mutex_unlock (&mutex);
+ g_mutex_unlock (&mutex);
if (query != NULL)
return query->value;
{
const GstQueryTypeDefinition *result;
- g_static_mutex_lock (&mutex);
+ g_mutex_lock (&mutex);
result = g_hash_table_lookup (_query_type_to_nick, GINT_TO_POINTER (type));
- g_static_mutex_unlock (&mutex);
+ g_mutex_unlock (&mutex);
return result;
}
{
GstIterator *result;
- g_static_mutex_lock (&mutex);
+ g_mutex_lock (&mutex);
/* FIXME: register a boxed type for GstQueryTypeDefinition */
result = gst_iterator_new_list (G_TYPE_POINTER,
- g_static_mutex_get_mutex (&mutex), &_n_values, &_gst_queries, NULL, NULL);
- g_static_mutex_unlock (&mutex);
+ &mutex, &_n_values, &_gst_queries, NULL, NULL);
+ g_mutex_unlock (&mutex);
return result;
}
/* the one instance of the default registry and the mutex protecting the
* variable. */
-static GStaticMutex _gst_registry_mutex = G_STATIC_MUTEX_INIT;
+static GMutex _gst_registry_mutex;
static GstRegistry *_gst_registry_default = NULL;
/* defaults */
{
GstRegistry *registry;
- g_static_mutex_lock (&_gst_registry_mutex);
+ g_mutex_lock (&_gst_registry_mutex);
if (G_UNLIKELY (!_gst_registry_default)) {
_gst_registry_default = g_object_newv (GST_TYPE_REGISTRY, 0, NULL);
gst_object_ref_sink (GST_OBJECT_CAST (_gst_registry_default));
}
registry = _gst_registry_default;
- g_static_mutex_unlock (&_gst_registry_mutex);
+ g_mutex_unlock (&_gst_registry_mutex);
return registry;
}
{
GstRegistry *registry;
- g_static_mutex_lock (&_gst_registry_mutex);
+ g_mutex_lock (&_gst_registry_mutex);
if ((registry = _gst_registry_default) != NULL) {
_gst_registry_default = NULL;
}
- g_static_mutex_unlock (&_gst_registry_mutex);
+ g_mutex_unlock (&_gst_registry_mutex);
/* unref outside of the lock because we can. */
if (registry)
static gboolean gst_system_clock_start_async (GstSystemClock * clock);
static void gst_system_clock_add_wakeup (GstSystemClock * sysclock);
-static GStaticMutex _gst_sysclock_mutex = G_STATIC_MUTEX_INIT;
+static GMutex _gst_sysclock_mutex;
/* static guint gst_system_clock_signals[LAST_SIGNAL] = { 0 }; */
{
GstClock *clock;
- g_static_mutex_lock (&_gst_sysclock_mutex);
+ g_mutex_lock (&_gst_sysclock_mutex);
clock = _the_system_clock;
if (clock == NULL) {
gst_object_ref_sink (clock);
_the_system_clock = clock;
- g_static_mutex_unlock (&_gst_sysclock_mutex);
+ g_mutex_unlock (&_gst_sysclock_mutex);
} else {
- g_static_mutex_unlock (&_gst_sysclock_mutex);
+ g_mutex_unlock (&_gst_sysclock_mutex);
GST_CAT_DEBUG (GST_CAT_CLOCK, "returning static system clock");
}
static void gst_task_func (GstTask * task);
-static GStaticMutex pool_lock = G_STATIC_MUTEX_INIT;
+static GMutex pool_lock;
#define _do_init \
{ \
static void
init_klass_pool (GstTaskClass * klass)
{
- g_static_mutex_lock (&pool_lock);
+ g_mutex_lock (&pool_lock);
if (klass->pool) {
gst_task_pool_cleanup (klass->pool);
gst_object_unref (klass->pool);
}
klass->pool = gst_task_pool_new ();
gst_task_pool_prepare (klass->pool, NULL);
- g_static_mutex_unlock (&pool_lock);
+ g_mutex_unlock (&pool_lock);
}
static void
/* use the default klass pool for this task, users can
* override this later */
- g_static_mutex_lock (&pool_lock);
+ g_mutex_lock (&pool_lock);
task->priv->pool = gst_object_ref (klass->pool);
- g_static_mutex_unlock (&pool_lock);
+ g_mutex_unlock (&pool_lock);
}
static void
#include <gst/check/gstcheck.h>
-static GStaticMutex _check_lock = G_STATIC_MUTEX_INIT;
+static GMutex _check_lock;
static GstElement *
setup_multiqueue (GstElement * pipe, GstElement * inputs[],
pad_data = gst_pad_get_element_private (sinkpad);
- g_static_mutex_lock (&_check_lock);
+ g_mutex_lock (&_check_lock);
fail_if (pad_data == NULL);
/* Read an ID from the first 4 bytes of the buffer data and check it's
* what we expect */
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
fail_unless (size >= 4);
- g_static_mutex_unlock (&_check_lock);
+ g_mutex_unlock (&_check_lock);
cur_id = GST_READ_UINT32_BE (data);
gst_buffer_unmap (buf, data, size);
if (!pad_data->is_linked) {
/* If there are no linked pads, we can't track a max_id for them :) */
if (pad_data->n_linked > 0 && !pad_data->first_buf) {
- g_static_mutex_lock (&_check_lock);
+ g_mutex_lock (&_check_lock);
fail_unless (cur_id <= *(pad_data->max_linked_id_ptr) + 1,
"Got buffer %u on pad %u before buffer %u was seen on a "
"linked pad (max: %u)", cur_id, pad_data->pad_num, cur_id - 1,
*(pad_data->max_linked_id_ptr));
- g_static_mutex_unlock (&_check_lock);
+ g_mutex_unlock (&_check_lock);
}
} else {
/* Update the max_id value */
struct PadData *pad_data;
pad_data = gst_pad_get_element_private (sinkpad);
- g_static_mutex_lock (&_check_lock);
+ g_mutex_lock (&_check_lock);
fail_if (pad_data == NULL);
- g_static_mutex_unlock (&_check_lock);
+ g_mutex_unlock (&_check_lock);
if (GST_EVENT_TYPE (event) == GST_EVENT_EOS) {
g_mutex_lock (pad_data->mutex);
cur_pad = pad_pattern[i % n];
buf = gst_buffer_new_and_alloc (4);
- g_static_mutex_lock (&_check_lock);
+ g_mutex_lock (&_check_lock);
fail_if (buf == NULL);
- g_static_mutex_unlock (&_check_lock);
+ g_mutex_unlock (&_check_lock);
data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
GST_WRITE_UINT32_BE (data, i + 1);
GST_BUFFER_TIMESTAMP (buf) = (i + 1) * GST_SECOND;
ret = gst_pad_push (inputpads[cur_pad], buf);
- g_static_mutex_lock (&_check_lock);
+ g_mutex_lock (&_check_lock);
if (pad_data[cur_pad].is_linked) {
fail_unless (ret == GST_FLOW_OK,
"Push on pad %d returned %d when FLOW_OK was expected", cur_pad, ret);
"Push on pad %d returned %d when FLOW_OK or NOT_LINKED was expected",
cur_pad, ret);
}
- g_static_mutex_unlock (&_check_lock);
+ g_mutex_unlock (&_check_lock);
}
for (i = 0; i < NPADS; i++) {
gst_pad_push_event (inputpads[i], gst_event_new_eos ());
ts = gst_util_uint64_scale_int (GST_SECOND, i, 10);
buf = gst_buffer_new_and_alloc (4);
- g_static_mutex_lock (&_check_lock);
+ g_mutex_lock (&_check_lock);
fail_if (buf == NULL);
- g_static_mutex_unlock (&_check_lock);
+ g_mutex_unlock (&_check_lock);
data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
GST_WRITE_UINT32_BE (data, i + 1);
ret = gst_pad_push (inputpads[1], gst_buffer_ref (buf));
ret = gst_pad_push (inputpads[0], buf);
- g_static_mutex_lock (&_check_lock);
+ g_mutex_lock (&_check_lock);
fail_unless (ret == GST_FLOW_OK,
"Push on pad %d returned %d when FLOW_OK was expected", 0, ret);
- g_static_mutex_unlock (&_check_lock);
+ g_mutex_unlock (&_check_lock);
/* Push a new segment update on the 2nd pad */
gst_segment_init (&segment, GST_FORMAT_TIME);