gpointer gst_gl_context_default_get_proc_address (GstGLContext * context, const gchar * name) { gpointer ret = NULL; GstGLAPI gl_api = gst_gl_context_get_gl_api (context); /* First try to load symbol from the selected GL API for this context */ #if GST_GL_HAVE_GLES2 if (!ret && (gl_api & GST_GL_API_GLES2)) { g_once (&module_gles2_gonce, load_gles2_module, NULL); if (module_gles2) g_module_symbol (module_gles2, name, &ret); } #endif #if GST_GL_HAVE_OPENGL if (!ret && (gl_api & (GST_GL_API_OPENGL | GST_GL_API_OPENGL3))) { g_once (&module_opengl_gonce, load_opengl_module, NULL); if (module_opengl) g_module_symbol (module_opengl, name, &ret); } #endif /* Otherwise fall back to the current module */ if (!ret) g_module_symbol (module_self, name, &ret); return ret; }
static gpointer test_g_once_thread (gpointer ignore) { guint i; G_LOCK (test_g_once); /* Don't start before all threads are created */ G_UNLOCK (test_g_once); for (i = 0; i < 1000; i++) { guint pos = g_random_int_range (0, G_ONCE_SIZE); gpointer ret = g_once (test_g_once_array + pos, test_g_once_init_func, test_g_once_guint_array + pos); g_assert (ret == test_g_once_guint_array + pos); } /* Make sure, that all counters are touched at least once */ for (i = 0; i < G_ONCE_SIZE; i++) { gpointer ret = g_once (test_g_once_array + i, test_g_once_init_func, test_g_once_guint_array + i); g_assert (ret == test_g_once_guint_array + i); } return NULL; }
static void fs_rtp_special_sources_init (void) { static GOnce my_once = G_ONCE_INIT; classes = g_once (&my_once, register_classes, NULL); }
/** * camel_provider_register: * @provider: provider object * * Registers a provider. **/ void camel_provider_register (CamelProvider *provider) { g_once (&setup_once, provider_setup, NULL); provider_register_internal (provider); }
static MsgState * MsgGetState(void) { static GOnce msgStateInit = G_ONCE_INIT; g_once(&msgStateInit, MsgInitState, NULL); return msgState; }
GType tny_gnome_keyring_password_getter_get_type (void) { static GOnce once = G_ONCE_INIT; g_once (&once, tny_gnome_keyring_password_getter_register_type, NULL); return GPOINTER_TO_SIZE (once.retval); }
GType tny_list_get_type (void) { static GOnce once = G_ONCE_INIT; g_once (&once, tny_list_register_type, NULL); return GPOINTER_TO_SIZE (once.retval); }
static inline void gst_vaapi_decoder_ffmpeg_init_once(void) { static GOnce once = G_ONCE_INIT; g_once(&once, gst_vaapi_decoder_ffmpeg_init_once_cb, NULL); }
GstDecklinkInput * gst_decklink_acquire_nth_input (gint n, GstElement * src, gboolean is_audio) { GstDecklinkInput *input; g_once (&devices_once, init_devices, NULL); if (n >= n_devices) return NULL; input = &devices[n].input; if (!input->input) { GST_ERROR ("Device %d has no input", n); return NULL; } g_mutex_lock (&input->lock); if (is_audio && !input->audiosrc) { input->audiosrc = GST_ELEMENT_CAST (gst_object_ref (src)); g_mutex_unlock (&input->lock); return input; } else if (!input->videosrc) { input->videosrc = GST_ELEMENT_CAST (gst_object_ref (src)); g_mutex_unlock (&input->lock); return input; } g_mutex_unlock (&input->lock); GST_ERROR ("Input device %d (audio: %d) in use already", n, is_audio); return NULL; }
GstDecklinkOutput * gst_decklink_acquire_nth_output (gint n, GstElement * sink, gboolean is_audio) { GstDecklinkOutput *output; g_once (&devices_once, init_devices, NULL); if (n >= n_devices) return NULL; output = &devices[n].output; if (!output->output) { GST_ERROR ("Device %d has no output", n); return NULL; } g_mutex_lock (&output->lock); if (is_audio && !output->audiosink) { output->audiosink = GST_ELEMENT_CAST (gst_object_ref (sink)); g_mutex_unlock (&output->lock); return output; } else if (!output->videosink) { output->videosink = GST_ELEMENT_CAST (gst_object_ref (sink)); g_mutex_unlock (&output->lock); return output; } g_mutex_unlock (&output->lock); GST_ERROR ("Output device %d (audio: %d) in use already", n, is_audio); return NULL; }
void gnc_gconf_general_register_cb (const gchar *key, GncGconfGeneralCb func, gpointer user_data) { GHookList *hook_list; GHook *hook; g_once(&gcb_init_once, gcb_init, NULL); hook_list = g_hash_table_lookup(gcb_callback_hash, key); if (hook_list == NULL) { hook_list = g_malloc(sizeof(GHookList)); g_hook_list_init(hook_list, sizeof(GHook)); g_hash_table_insert(gcb_callback_hash, (gpointer)key, hook_list); } hook = g_hook_find_func_data(hook_list, TRUE, func, user_data); if (hook != NULL) { return; } hook = g_hook_alloc(hook_list); hook->func = func; hook->data = user_data; g_hook_append(hook_list, hook); }
static void gnc_gconf_general_changed (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer data) { const gchar *key, *key_tail; GHookList *hook_list; g_once(&gcb_init_once, gcb_init, NULL); key = gconf_entry_get_key(entry); key_tail = strrchr(key, '/'); if (key_tail != NULL) { key_tail++; } if (key_tail == NULL) { /* Should never happen. */ g_warning("Malformed key %s:", key); return; } hook_list = g_hash_table_lookup(gcb_callback_hash, key_tail); if (hook_list != NULL) g_hook_list_marshal(hook_list, TRUE, gcb_call_hook, entry); g_hook_list_invoke(gcb_final_hook_list, TRUE); }
/** * zif_init: * * This is called automatically to initialize libzif. * You normally don't have to call this function manually. * * Return value: %TRUE if we initialised correctly * * Since: 0.1.0 **/ gboolean zif_init (void) { static GOnce init_once = G_ONCE_INIT; g_once (&init_once, zif_init_once_cb, NULL); return GPOINTER_TO_INT (init_once.retval); }
/** * iris_thread_new: * @exclusive: the thread is exclusive * * Createa a new #IrisThread instance that can be used to queue work items * to be processed on the thread. * * If @exclusive, then the thread will not yield to the scheduler and * therefore will not participate in scheduler thread balancing. * * Return value: the newly created #IrisThread instance */ IrisThread* iris_thread_new (gboolean exclusive) { IrisThread *thread; iris_debug (IRIS_DEBUG_THREAD); #if LINUX #elif defined(WIN32) g_once (&my_thread_once, (GThreadFunc)_winthreads_init, NULL); #else pthread_once (&my_thread_once, _pthread_init); #endif thread = g_slice_new0 (IrisThread); thread->exclusive = exclusive; thread->queue = g_async_queue_new (); thread->mutex = g_mutex_new (); thread->thread = g_thread_create_full ((GThreadFunc)iris_thread_worker, thread, 0, /* stack size */ FALSE, /* joinable */ FALSE, /* system thread */ G_THREAD_PRIORITY_NORMAL, NULL); thread->scheduler = NULL; return thread; }
/* * _kh_startup: * Kqueue backend initialization. * * Returns: %TRUE on success, %FALSE otherwise. **/ gboolean _kh_startup (void) { static GOnce init_once = G_ONCE_INIT; g_once (&init_once, _kh_startup_impl, NULL); return GPOINTER_TO_INT (init_once.retval); }
/** * g_proxy_resolver_get_default: * * Gets the default #GProxyResolver for the system. * * Return value: (transfer none): the default #GProxyResolver. * * Since: 2.26 */ GProxyResolver * g_proxy_resolver_get_default (void) { static GOnce once_init = G_ONCE_INIT; return g_once (&once_init, get_default_proxy_resolver, NULL); }
GType tny_camel_default_connection_policy_get_type (void) { static GOnce once = G_ONCE_INIT; g_once (&once, tny_camel_default_connection_policy_register_type, NULL); return GPOINTER_TO_SIZE (once.retval); }
GType tny_camel_partial_msg_receive_strategy_get_type (void) { static GOnce once = G_ONCE_INIT; g_once (&once, tny_camel_partial_msg_receive_strategy_register_type, NULL); return GPOINTER_TO_SIZE (once.retval); }
GType _tny_gtk_attach_list_model_iterator_get_type (void) { static GOnce once = G_ONCE_INIT; g_once (&once, _tny_gtk_attach_list_model_iterator_register_type, NULL); return GPOINTER_TO_SIZE (once.retval); }
WebKitSettings * ephy_embed_prefs_get_settings (void) { static GOnce once_init = G_ONCE_INIT; return g_once (&once_init, ephy_embed_prefs_init, NULL); }
static gchar * eog_exif_util_format_date_with_strptime (const gchar *date) { static GOnce strptime_updates_wday = G_ONCE_INIT; gchar *new_date = NULL; gchar tmp_date[DATE_BUF_SIZE]; gchar *p; gsize dlen; struct tm tm; memset (&tm, '\0', sizeof (tm)); p = strptime (date, "%Y:%m:%d %T", &tm); if (p == date + strlen (date)) { g_once (&strptime_updates_wday, _check_strptime_updates_wday, NULL); // Ensure tm.tm_wday and tm.tm_yday are set if (!GPOINTER_TO_BOOLEAN (strptime_updates_wday.retval)) _calculate_wday_yday (&tm); /* A strftime-formatted string, to display the date the image was taken. */ dlen = strftime (tmp_date, DATE_BUF_SIZE * sizeof(gchar), _("%a, %d %B %Y %X"), &tm); new_date = g_strndup (tmp_date, dlen); } return new_date; }
/** * _g_local_directory_monitor_new: * @dirname: filename of the directory to monitor. * @flags: #GFileMonitorFlags. * * Returns: new #GFileMonitor for the given @dirname. **/ GFileMonitor* _g_local_directory_monitor_new (const char *dirname, GFileMonitorFlags flags, GError **error) { static GOnce once_init = G_ONCE_INIT; GTypeClass *type_class; GFileMonitor *monitor; GType type; type_class = NULL; g_once (&once_init, get_default_local_directory_monitor, &type_class); type = (GType)once_init.retval; monitor = NULL; if (type != G_TYPE_INVALID) monitor = G_FILE_MONITOR (g_object_new (type, "dirname", dirname, "flags", flags, NULL)); else g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, _("Unable to find default local directory monitor type")); /* This is non-null on first pass here. Unref the class now. * This is to avoid unloading the module and then loading it * again which would happen if we unrefed the class * before creating the monitor. */ if (type_class) g_type_class_unref (type_class); return monitor; }
static void gdk_ensure_resources (void) { static GOnce register_resources_once = G_ONCE_INIT; g_once (®ister_resources_once, register_resources, NULL); }
/** * Returns the list of paths to find desktop files. * * * @return A GList of gchar*. Should NOT be freed. */ static GList * _get_desktop_file_path_list () { GOnce once = G_ONCE_INIT; g_once (&once, _get_desktop_file_path_list_once, NULL); return (GList*) once.retval; }
/** * gst_tag_register_musicbrainz_tags: * * Registers additional musicbrainz-specific tags with the GStreamer tag * system. Plugins and applications that use these tags should call this * function before using them. Can be called multiple times. */ void gst_tag_register_musicbrainz_tags (void) { static GOnce mb_once = G_ONCE_INIT; g_once (&mb_once, gst_tag_register_tags_internal, NULL); }
static const gchar * get_mock_external_monitor_file (void) { static GOnce mocked_once = G_ONCE_INIT; g_once (&mocked_once, parse_mock_mock_external_monitor, NULL); return mocked_once.retval; }
static void vips_tracked_init( void ) { static GOnce vips_tracked_once = G_ONCE_INIT; vips_tracked_mutex = g_once( &vips_tracked_once, (GThreadFunc) vips_g_mutex_new, NULL ); }
/** * spice_smartcard_manager_get: * * #SpiceSmartcardManager is a singleton, use this function to get a pointer * to it. A new SpiceSmartcardManager instance will be created the first * time this function is called * * Returns: (transfer none): a weak reference to the #SpiceSmartcardManager */ SpiceSmartcardManager *spice_smartcard_manager_get(void) { static GOnce manager_singleton_once = G_ONCE_INIT; return g_once(&manager_singleton_once, (GThreadFunc)spice_smartcard_manager_new, NULL); }
FlowSshMasterRegistry * flow_ssh_master_registry_get_default (void) { static GOnce my_once = G_ONCE_INIT; g_once (&my_once, (GThreadFunc) instantiate_singleton, NULL); return my_once.retval; }
gboolean gnome_settings_is_wayland (void) { static GOnce wayland_once = G_ONCE_INIT; g_once (&wayland_once, is_wayland_session, NULL); return GPOINTER_TO_UINT(wayland_once.retval); }