int oh_start_event_thread() { struct oh_global_param threaded_param = { .type = OPENHPI_THREADED }; oh_get_global_param(&threaded_param); if (threaded_param.u.threaded) { trace("Starting event thread"); oh_is_threaded = TRUE; oh_thread_wait = g_cond_new(); oh_thread_mutex = g_mutex_new(); oh_event_thread = g_thread_create(oh_event_thread_loop, NULL, FALSE, &oh_event_thread_error); } return 1; }
static lcm_provider_t *lcm_memq_create(lcm_t *parent, const char *target, const GHashTable *args) { lcm_memq_t *self = (lcm_memq_t *) calloc(1, sizeof(lcm_memq_t)); self->lcm = parent; self->queue = g_queue_new(); self->mutex = g_mutex_new(); dbg(DBG_LCM, "Initializing LCM memq provider context...\n"); if (lcm_internal_pipe_create(self->notify_pipe) != 0) { perror(__FILE__ " - pipe (notify)"); lcm_memq_destroy(self); return NULL; } return self; }
LcmTunnel::LcmTunnel(bool verbose, const char *lcm_channel) : verbose(verbose), regex(NULL), buf_sz(65536), buf((char*) calloc(65536, sizeof(char))), channel_sz(65536), channel( (char*) calloc(65536, sizeof(char))), recFlags_sz(1024), recFlags((char*) calloc(1024, sizeof(char))), ldpc_dec( NULL), udp_fd(-1), server_udp_port(-1), udp_send_seqno(0), stopSendThread(false), bytesInQueue(0), cur_seqno(0), errorStartTime(-1), numSuccessful(0), lastErrorPrintTime(-1) { //allocate and initialize things init_regex(lcm_channel); //sendThread stuff sendQueueLock = g_mutex_new(); sendQueueCond = g_cond_new(); sendThread = g_thread_create(sendThreadFunc, (void *) this, 1, NULL); }
static void gst_data_queue_init (GstDataQueue * queue) { queue->cur_level.visible = 0; /* no content */ queue->cur_level.bytes = 0; /* no content */ queue->cur_level.time = 0; /* no content */ queue->checkfull = NULL; queue->qlock = g_mutex_new (); queue->item_add = g_cond_new (); queue->item_del = g_cond_new (); queue->queue = g_queue_new (); GST_DEBUG ("initialized queue's not_empty & not_full conditions"); }
/** * gst_goo_sem_new: * @counter: the semaphore's counter initial value * * Creates a new semaphore for threading syncronization * * Returns: a new #GstGooSem structure */ GstGooSem* gst_goo_sem_new (gint counter) { g_assert (counter <= 0); GstGooSem *self; self = g_new (GstGooSem, 1); g_assert (self != NULL); self->counter = counter; self->condition = g_cond_new (); self->mutex = g_mutex_new (); return self; }
static CajaFileChangesQueue * caja_file_changes_queue_new (void) { CajaFileChangesQueue *result; result = g_new0 (CajaFileChangesQueue, 1); #ifdef G_THREADS_ENABLED # if GLIB_CHECK_VERSION(2, 32, 0) g_mutex_init (&result->mutex); # else result->mutex = g_mutex_new (); # endif #endif return result; }
static void log4g_appender_init(Log4gAppender *self) { self->priv = ASSIGN_PRIVATE(self); struct Private *priv = GET_PRIVATE(self); priv->layout = NULL; priv->name = NULL; priv->threshold = NULL; priv->error = log4g_only_once_error_handler_new(); priv->head = priv->tail = NULL; priv->closed = FALSE; priv->lock = NULL; if (g_thread_supported()) { priv->lock = g_mutex_new(); } }
static void bus_registry_init (BusRegistry *registry) { GList *p; registry->observed_paths = NULL; registry->components = NULL; registry->engine_table = g_hash_table_new (g_str_hash, g_str_equal); #ifdef G_THREADS_ENABLED registry->thread = NULL; registry->thread_running = TRUE; registry->mutex = g_mutex_new (); registry->cond = g_cond_new (); registry->changed = FALSE; #endif if (g_strcmp0 (g_cache, "none") == 0) { /* only load registry, but not read and write cache */ bus_registry_load (registry); } else if (g_strcmp0 (g_cache, "refresh") == 0) { /* load registry and overwrite the cache */ bus_registry_load (registry); bus_registry_save_cache (registry); } else { /* load registry from cache. * If the cache does not exist or it is outdated, then rebuild it */ if (bus_registry_load_cache (registry) == FALSE || bus_registry_check_modification (registry)) { bus_registry_remove_all (registry); bus_registry_load (registry); bus_registry_save_cache (registry); } } for (p = registry->components; p != NULL; p = p->next) { IBusComponent *comp = (IBusComponent *)p->data; GList *p1; for (p1 = comp->engines; p1 != NULL; p1 = p1->next) { IBusEngineDesc *desc = (IBusEngineDesc *)p1->data; g_hash_table_insert (registry->engine_table, desc->name, desc); g_object_set_data ((GObject *)desc, "component", comp); } } }
static void clutter_gst_video_sink_init (ClutterGstVideoSink *sink, ClutterGstVideoSinkClass *klass) { ClutterGstVideoSinkPrivate *priv; sink->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE (sink, CLUTTER_GST_TYPE_VIDEO_SINK, ClutterGstVideoSinkPrivate); priv->buffer_lock = g_mutex_new (); priv->renderers = clutter_gst_build_renderers_list (&priv->syms); priv->caps = clutter_gst_build_caps (priv->renderers); priv->renderer_state = CLUTTER_GST_RENDERER_STOPPED; priv->signal_handler_ids = g_array_new (FALSE, FALSE, sizeof (gulong)); }
static void xmr_downloader_init(XmrDownloader *downloader) { XmrDownloaderPrivate *priv; downloader->priv = G_TYPE_INSTANCE_GET_PRIVATE(downloader, XMR_TYPE_DOWNLOADER, XmrDownloaderPrivate); priv = downloader->priv; #if GLIB_CHECK_VERSION(2, 32, 0) priv->mutex = g_malloc(sizeof(GMutex)); g_mutex_init(priv->mutex); #else priv->mutex = g_mutex_new(); #endif priv->tasks = NULL; }
/***************************************************************************************** * ... * * ****************************************************************************************/ static void fm_dir_tree_model_init (FmDirTreeModel *dir_tree_model) { dir_tree_model->stamp = g_random_int (); // Set default values... dir_tree_model->icon_size = 16; dir_tree_model->show_hidden = FALSE; dir_tree_model->show_symlinks = FALSE; dir_tree_model->check_subdir = TRUE; // Check Subdirectories job... g_queue_init (&dir_tree_model->subdir_checks); dir_tree_model->subdir_checks_mutex = g_mutex_new (); dir_tree_model->subdir_cancellable = g_cancellable_new (); g_signal_connect (gtk_icon_theme_get_default (), "changed", G_CALLBACK (on_theme_changed), dir_tree_model); }
static void gst_alsasink_init (GstAlsaSink * alsasink, GstAlsaSinkClass * g_class) { GST_DEBUG_OBJECT (alsasink, "initializing alsasink"); alsasink->device = g_strdup (DEFAULT_DEVICE); alsasink->handle = NULL; alsasink->cached_caps = NULL; alsasink->alsa_lock = g_mutex_new (); g_static_mutex_lock (&output_mutex); if (output_ref == 0) { snd_output_stdio_attach (&output, stdout, 0); ++output_ref; } g_static_mutex_unlock (&output_mutex); }
/** * goo_semaphore_new: * @counter: the semaphore's counter initial value * * Creates a new semaphore for threading syncronization * * Returns: a new #GooSemaphore structure */ GooSemaphore* goo_semaphore_new (gint counter) { g_assert (counter <= 0); GooSemaphore *self; self = g_new (GooSemaphore, 1); g_assert (self != NULL); self->counter = counter; self->waiting = FALSE; self->condition = g_cond_new (); self->mutex = g_mutex_new (); return self; }
void cdda_scanner_start(void) { if (cdda_scanner_working) { return; } cdda_notify_rb = rb_create(CDDA_NOTIFY_RB_SIZE); #ifdef _WIN32 cdda_mutex = g_mutex_new(); #endif /* _WIN32 */ cdda_timeout_start(); cdda_scanner_working = 1; AQUALUNG_THREAD_CREATE(cdda_scanner_id, NULL, cdda_scanner, NULL) }
static void instance_init(GTypeInstance *instance, gpointer g_class) { GstDspBase *base = GST_DSP_BASE(instance); GstDspVEnc *self = GST_DSP_VENC(instance); gst_pad_set_setcaps_function(base->sinkpad, sink_setcaps); base->reset = reset; self->bitrate = DEFAULT_BITRATE; self->mode = DEFAULT_MODE; self->keyframe_interval = DEFAULT_KEYFRAME_INTERVAL; self->intra_refresh = DEFAULT_INTRA_REFRESH; self->keyframe_mutex = g_mutex_new(); }
GVfsFtpDirCache * g_vfs_ftp_dir_cache_new (const GVfsFtpDirFuncs *funcs) { GVfsFtpDirCache *cache; g_return_val_if_fail (funcs != NULL, NULL); cache = g_slice_new0 (GVfsFtpDirCache); cache->directories = g_hash_table_new_full (g_vfs_ftp_file_hash, g_vfs_ftp_file_equal, (GDestroyNotify) g_vfs_ftp_file_free, (GDestroyNotify) g_vfs_ftp_dir_cache_entry_unref); cache->lock = g_mutex_new(); cache->funcs = funcs; return cache; }
static void gst_object_init (GTypeInstance * instance, gpointer g_class) { GstObject *object = GST_OBJECT (instance); object->lock = g_mutex_new (); object->parent = NULL; object->name = NULL; GST_CAT_LOG_OBJECT (GST_CAT_REFCOUNTING, object, "%p new", object); #ifndef GST_DISABLE_TRACE gst_alloc_trace_new (_gst_object_trace, object); #endif object->flags = 0; GST_OBJECT_FLAG_SET (object, GST_OBJECT_FLOATING); }
static xr_servlet* xr_servlet_new(xr_servlet_def* def, xr_server_conn* conn) { xr_servlet* s = g_new0(xr_servlet, 1); if (def->size > 0) s->priv = g_malloc0(def->size); s->def = def; s->conn = conn; s->call_mutex = g_mutex_new(); if (s->def->init && !s->def->init(s)) { xr_servlet_free(s); return NULL; } return s; }
GOmxPort * g_omx_port_new (GOmxCore *core) { GOmxPort *port; port = g_new0 (GOmxPort, 1); port->core = core; port->num_buffers = 0; port->buffer_size = 0; port->buffers = NULL; port->enabled = TRUE; port->queue = async_queue_new (); port->mutex = g_mutex_new (); return port; }
static void gst_app_sink_init (GstAppSink * appsink) { GstAppSinkPrivate *priv; priv = appsink->priv = G_TYPE_INSTANCE_GET_PRIVATE (appsink, GST_TYPE_APP_SINK, GstAppSinkPrivate); priv->mutex = g_mutex_new (); priv->cond = g_cond_new (); priv->queue = g_queue_new (); priv->emit_signals = DEFAULT_PROP_EMIT_SIGNALS; priv->max_buffers = DEFAULT_PROP_MAX_BUFFERS; priv->drop = DEFAULT_PROP_DROP; }
static void gst_pvrvideosink_init (GstPVRVideoSink * pvrvideosink) { pvrvideosink->running = FALSE; pvrvideosink->flow_lock = g_mutex_new (); pvrvideosink->pool = NULL; pvrvideosink->keep_aspect = FALSE; pvrvideosink->current_caps = NULL; pvrvideosink->dcontext = NULL; pvrvideosink->xwindow = NULL; pvrvideosink->redraw_borders = TRUE; pvrvideosink->current_buffer = NULL; pvrvideosink->event_thread = NULL; memset (&pvrvideosink->render_params, 0, sizeof (WSEGLDrawableParams)); }
static void * osx_output_init(G_GNUC_UNUSED const struct audio_format *audio_format, G_GNUC_UNUSED const struct config_param *param, G_GNUC_UNUSED GError **error) { struct osx_output *oo = g_new(struct osx_output, 1); oo->mutex = g_mutex_new(); oo->condition = g_cond_new(); oo->pos = 0; oo->len = 0; oo->buffer = NULL; oo->buffer_size = 0; return oo; }
static void p_initGapTimmData() { if (timmData.tab == NULL) { /* check and init thread system */ timmData.isMultiThreadSupport = gap_base_thread_init(); if(timmData.isMultiThreadSupport == TRUE) { timmData.mutex = g_mutex_new(); } timmData.maxFuncId = -1; timmData.tabSizeInElements = GAP_TIMM_MAX_ELEMENTS; timmData.tab = g_malloc0(timmData.tabSizeInElements * sizeof(GapTimmElement)); } }
GstM3U8Client * gst_m3u8_client_new (const gchar * uri) { GstM3U8Client *client; g_return_val_if_fail (uri != NULL, NULL); client = g_new0 (GstM3U8Client, 1); client->main = gst_m3u8_new (); client->current = NULL; client->sequence = -1; client->update_failed_count = 0; client->lock = g_mutex_new (); gst_m3u8_set_uri (client->main, g_strdup (uri)); return client; }
/** * gst_buffer_straw_start_pipeline: * @bin: the pipeline to run * @pad: a pad on an element in @bin * * Sets up a pipeline for buffer sucking. This will allow you to call * gst_buffer_straw_get_buffer() to access buffers as they pass over @pad. * * This function is normally used in unit tests that want to verify that a * particular element is outputting correct buffers. For example, you would make * a pipeline via gst_parse_launch(), pull out the pad you want to monitor, then * call gst_buffer_straw_get_buffer() to get the buffers that pass through @pad. * The pipeline will block until you have sucked off the buffers. * * This function will set the state of @bin to PLAYING; to clean up, be sure to * call gst_buffer_straw_stop_pipeline(). * * Note that you may not start two buffer straws at the same time. This function * is intended for unit tests, not general API use. In fact it calls fail_if * from libcheck, so you cannot use it outside unit tests. */ void gst_buffer_straw_start_pipeline (GstElement * bin, GstPad * pad) { GstStateChangeReturn ret; id = gst_pad_add_buffer_probe (pad, G_CALLBACK (buffer_probe), NULL); cond = g_cond_new (); lock = g_mutex_new (); ret = gst_element_set_state (bin, GST_STATE_PLAYING); fail_if (ret == GST_STATE_CHANGE_FAILURE, "Could not start test pipeline"); if (ret == GST_STATE_CHANGE_ASYNC) { ret = gst_element_get_state (bin, NULL, NULL, GST_CLOCK_TIME_NONE); fail_if (ret != GST_STATE_CHANGE_SUCCESS, "Could not start test pipeline"); } }
static void gst_rtp_jitter_buffer_init (GstRtpJitterBuffer * jitterbuffer, GstRtpJitterBufferClass * klass) { GstRtpJitterBufferPrivate *priv; priv = GST_RTP_JITTER_BUFFER_GET_PRIVATE (jitterbuffer); jitterbuffer->priv = priv; priv->latency_ms = DEFAULT_LATENCY_MS; priv->drop_on_latency = DEFAULT_DROP_ON_LATENCY; priv->do_lost = DEFAULT_DO_LOST; priv->jbuf = rtp_jitter_buffer_new (); priv->jbuf_lock = g_mutex_new (); priv->jbuf_cond = g_cond_new (); priv->srcpad = gst_pad_new_from_static_template (&gst_rtp_jitter_buffer_src_template, "src"); gst_pad_set_activatepush_function (priv->srcpad, GST_DEBUG_FUNCPTR (gst_rtp_jitter_buffer_src_activate_push)); gst_pad_set_query_function (priv->srcpad, GST_DEBUG_FUNCPTR (gst_rtp_jitter_buffer_query)); gst_pad_set_getcaps_function (priv->srcpad, GST_DEBUG_FUNCPTR (gst_rtp_jitter_buffer_getcaps)); gst_pad_set_event_function (priv->srcpad, GST_DEBUG_FUNCPTR (gst_rtp_jitter_buffer_src_event)); priv->sinkpad = gst_pad_new_from_static_template (&gst_rtp_jitter_buffer_sink_template, "sink"); gst_pad_set_chain_function (priv->sinkpad, GST_DEBUG_FUNCPTR (gst_rtp_jitter_buffer_chain)); gst_pad_set_event_function (priv->sinkpad, GST_DEBUG_FUNCPTR (gst_rtp_jitter_buffer_sink_event)); gst_pad_set_setcaps_function (priv->sinkpad, GST_DEBUG_FUNCPTR (gst_jitter_buffer_sink_setcaps)); gst_pad_set_getcaps_function (priv->sinkpad, GST_DEBUG_FUNCPTR (gst_rtp_jitter_buffer_getcaps)); gst_element_add_pad (GST_ELEMENT (jitterbuffer), priv->srcpad); gst_element_add_pad (GST_ELEMENT (jitterbuffer), priv->sinkpad); }
static void gst_ss_demux_stream_init (GstSSDemux *demux, GstSSDemuxStream *stream, SS_STREAM_TYPE stream_type) { stream->cond = g_cond_new (); stream->lock = g_mutex_new (); stream->queue = g_queue_new (); stream->parent = demux; stream->pipe = NULL; stream->urisrc = NULL; stream->parser = NULL; stream->sink = NULL; stream->frag_cnt = 0; stream->type = stream_type ; stream->uri = NULL; stream->start_ts = -1; stream->sent_ns = FALSE; stream->switch_ts = GST_CLOCK_TIME_NONE; stream->avg_dur = GST_CLOCK_TIME_NONE; if (stream->type == SS_STREAM_VIDEO) { stream->pad = gst_pad_new_from_static_template (&ssdemux_videosrc_template, "video"); stream->name = g_strdup("video"); } else if (stream->type == SS_STREAM_AUDIO) { stream->pad = gst_pad_new_from_static_template (&ssdemux_audiosrc_template, "audio"); stream->name = g_strdup("audio"); } else if (stream->type == SS_STREAM_TEXT) { stream->pad = gst_pad_new_from_static_template (&ssdemux_subsrc_template, "subtitle"); stream->name = g_strdup("text"); } GST_PAD_ELEMENT_PRIVATE (stream->pad) = stream; gst_pad_use_fixed_caps (stream->pad); gst_pad_set_event_function (stream->pad, gst_ss_demux_handle_src_event); gst_pad_set_query_function (stream->pad, gst_ss_demux_handle_src_query); stream->caps = ssm_parse_get_stream_caps (demux->parser, stream->type); g_print ("prepare video caps = %s", gst_caps_to_string(stream->caps)); GST_DEBUG_OBJECT (demux, "setting caps %" GST_PTR_FORMAT, stream->caps); gst_pad_set_caps (stream->pad, stream->caps); GST_DEBUG_OBJECT (demux, "adding pad %s %p to demux %p", GST_OBJECT_NAME (stream->pad), stream->pad, demux); gst_pad_set_active (stream->pad, TRUE); gst_element_add_pad (GST_ELEMENT_CAST (demux), stream->pad); }
static void webkit_video_sink_init(WebKitVideoSink* sink) { sink->priv = G_TYPE_INSTANCE_GET_PRIVATE(sink, WEBKIT_TYPE_VIDEO_SINK, WebKitVideoSinkPrivate); #if GLIB_CHECK_VERSION(2, 31, 0) sink->priv->dataCondition = new GCond; g_cond_init(sink->priv->dataCondition); sink->priv->bufferMutex = new GMutex; g_mutex_init(sink->priv->bufferMutex); #else sink->priv->dataCondition = g_cond_new(); sink->priv->bufferMutex = g_mutex_new(); #endif #ifdef GST_API_VERSION_1 gst_video_info_init(&sink->priv->info); #endif }
void yelp_transform_start (YelpTransform *transform, xmlDocPtr document, gchar **params) { transform->inputDoc = document; transform->context = xsltNewTransformContext (transform->stylesheet, transform->inputDoc); if (!transform->context) { YelpError *error = yelp_error_new (_("Broken Transformation"), _("An unknown error occurred while attempting to " "transform the document.")); transform_set_error (transform, error); return; } transform->params = g_strdupv (params); transform->context->_private = transform; if (!exslt_registered) { exsltRegisterAll (); exslt_registered = TRUE; } xsltRegisterExtElement (transform->context, BAD_CAST "document", BAD_CAST YELP_NAMESPACE, (xsltTransformFunction) xslt_yelp_document); xsltRegisterExtElement (transform->context, BAD_CAST "cache", BAD_CAST YELP_NAMESPACE, (xsltTransformFunction) xslt_yelp_cache); xsltRegisterExtFunction (transform->context, BAD_CAST "input", BAD_CAST YELP_NAMESPACE, (xmlXPathFunction) xslt_yelp_input); transform->mutex = g_mutex_new (); g_mutex_lock (transform->mutex); transform->running = TRUE; transform->thread = g_thread_create ((GThreadFunc) transform_run, transform, FALSE, NULL); g_mutex_unlock (transform->mutex); }
/* initialize the new element * initialize instance structure */ static void gst_teletextdec_init (GstTeletextDec * teletext, GstTeletextDecClass * klass) { /* Create sink pad */ teletext->sinkpad = gst_pad_new_from_static_template (&sink_template, "sink"); gst_pad_set_setcaps_function (teletext->sinkpad, GST_DEBUG_FUNCPTR (gst_teletextdec_sink_setcaps)); gst_pad_set_chain_function (teletext->sinkpad, GST_DEBUG_FUNCPTR (gst_teletextdec_chain)); gst_pad_set_event_function (teletext->sinkpad, GST_DEBUG_FUNCPTR (gst_teletextdec_sink_event)); gst_element_add_pad (GST_ELEMENT (teletext), teletext->sinkpad); /* Create src pad */ teletext->srcpad = gst_pad_new_from_static_template (&src_template, "src"); gst_pad_set_setcaps_function (teletext->srcpad, GST_DEBUG_FUNCPTR (gst_teletextdec_src_set_caps)); gst_element_add_pad (GST_ELEMENT (teletext), teletext->srcpad); teletext->demux = NULL; teletext->decoder = NULL; teletext->pageno = 0x100; teletext->subno = -1; teletext->subtitles_mode = FALSE; teletext->subtitles_template = g_strescape ("%s\n", NULL); teletext->font_description = g_strdup (DEFAULT_FONT_DESCRIPTION); teletext->in_timestamp = GST_CLOCK_TIME_NONE; teletext->in_duration = GST_CLOCK_TIME_NONE; teletext->rate_numerator = 0; teletext->rate_denominator = 1; teletext->queue = NULL; teletext->queue_lock = g_mutex_new (); teletext->frame = g_new0 (GstTeletextFrame, 1); teletext->frame->sliced_begin = g_new (vbi_sliced, MAX_SLICES); teletext->frame->current_slice = teletext->frame->sliced_begin; teletext->frame->sliced_end = teletext->frame->sliced_begin + MAX_SLICES; teletext->last_ts = 0; teletext->process_buf_func = NULL; }