示例#1
0
static void
vlc_event_callback(const libvlc_event_t *event, void *userdata)
{
	XmrPlayer *player = (XmrPlayer *)userdata;
	PlayerEvent *player_event = g_new0(PlayerEvent, 1);
	
	switch(event->type)
	{
	case libvlc_MediaPlayerBuffering:
		player_event->buffering = event->u.media_player_buffering.new_cache;
		break;

	case libvlc_MediaPlayerTimeChanged:
		player_event->position = event->u.media_player_time_changed.new_time;
		break;

	default:
		break;
	}
	
	player_event->type = event->type;
	
	g_async_queue_push(player->priv->event_queue, player_event);
	g_main_context_wakeup(g_main_context_default());
}
示例#2
0
static gboolean
aggregate_func (GstAggregator * self)
{
  GstAggregatorPrivate *priv = self->priv;
  GstAggregatorClass *klass = GST_AGGREGATOR_GET_CLASS (self);

  GST_LOG_OBJECT (self, "Checking aggregate");
  while (priv->send_eos && gst_aggregator_iterate_sinkpads (self,
          (GstAggregatorPadForeachFunc) _check_all_pads_with_data_or_eos,
          NULL) && priv->running) {
    GST_TRACE_OBJECT (self, "Actually aggregating!");

    priv->flow_return = klass->aggregate (self);

    if (priv->flow_return == GST_FLOW_EOS) {
      g_main_context_wakeup (self->priv->mcontext);
      _remove_all_sources (self);
      _push_eos (self);
    }

    if (priv->flow_return == GST_FLOW_FLUSHING &&
        g_atomic_int_get (&priv->flush_seeking))
      priv->flow_return = GST_FLOW_OK;

    GST_LOG_OBJECT (self, "flow return is %s",
        gst_flow_get_name (priv->flow_return));

    if (priv->flow_return != GST_FLOW_OK)
      break;
  }

  return G_SOURCE_REMOVE;
}
示例#3
0
文件: gasynchelper.c 项目: GNOME/gnio
/* Might be called on another thread */
static void
fd_source_cancelled_cb (GCancellable *cancellable,
			gpointer      data)
{
  /* Wake up the mainloop in case we're waiting on async calls with FDSource */
  g_main_context_wakeup (NULL);
}
示例#4
0
CURLMcode glibcurl_add(CURL *easy_handle) {
  assert(curlSrc->multiHandle != 0);
  curlSrc->callPerform = -1;
  CURLMcode ret = curl_multi_add_handle(curlSrc->multiHandle, easy_handle);
  g_main_context_wakeup(g_main_context_default());
  return ret;
}
示例#5
0
CURLMcode glibcurl_remove(CURL *easy_handle) {
  assert(curlSrc != 0);
  assert(curlSrc->multiHandle != 0);
  CURLMcode ret = curl_multi_remove_handle(curlSrc->multiHandle, easy_handle);
  g_main_context_wakeup(g_main_context_default());
  return ret;
}
示例#6
0
/**
 * Put a message in the queue awaiting to be sent to the client.
 * Should hold client->lock.
 */
static gboolean
xmms_ipc_client_msg_write (xmms_ipc_client_t *client, xmms_ipc_msg_t *msg)
{
	gboolean queue_empty;

	g_return_val_if_fail (client, FALSE);
	g_return_val_if_fail (msg, FALSE);

	queue_empty = g_queue_is_empty (client->out_msg);
	g_queue_push_tail (client->out_msg, msg);

	/* If there's no write in progress, add a new callback */
	if (queue_empty) {
		GMainContext *context = g_main_loop_get_context (client->ml);
		GSource *source = g_io_create_watch (client->iochan, G_IO_OUT);

		g_source_set_callback (source,
		                       (GSourceFunc) xmms_ipc_client_write_cb,
		                       (gpointer) client,
		                       NULL);
		g_source_attach (source, context);
		g_source_unref (source);

		g_main_context_wakeup (context);
	}

	return TRUE;
}
示例#7
0
static void
wakeup_main (void *data)
{
    ConnectionSetup *cs = data;

    g_main_context_wakeup (cs->context);
}
void janus_source_setup_media(janus_plugin_session *handle) {
	JANUS_LOG(LOG_INFO, "WebRTC media is now available\n");
	if (g_atomic_int_get(&stopping) || !g_atomic_int_get(&initialized))
		return;
	janus_source_session *session = (janus_source_session *)handle->plugin_handle;
	if (!session) {
		JANUS_LOG(LOG_ERR, "No session associated with this handle...\n");
		return;
	}
	if (session->destroyed)
		return;
	g_atomic_int_set(&session->hangingup, 0);
	
	/* We really don't care, as we only send RTP/RTCP we get in the first place back anyway */
	
	JANUS_LOG(LOG_VERB, "video_active: %d, audio_active: %d\n", 
		session->video_active, session->audio_active);
	
	QueueEventData *queue_event_data;
	queue_event_data = g_malloc0(sizeof(QueueEventData));
	queue_event_data->callback = janus_rtsp_handle_client_callback;
	queue_event_data->session = session;

	g_async_queue_push(rtsp_server_data->rtsp_async_queue, queue_event_data) ;
	g_main_context_wakeup(NULL) ;
}
示例#9
0
static GstFlowReturn
_cogl_gst_video_sink_render (GstBaseSink *bsink,
                             GstBuffer *buffer)
{
  CoglGstVideoSink *sink = COGL_GST_VIDEO_SINK (bsink);
  CoglGstVideoSinkPrivate *priv = sink->priv;
  CoglGstSource *gst_source = priv->source;

  g_mutex_lock (&gst_source->buffer_lock);

  if (G_UNLIKELY (priv->flow_return != GST_FLOW_OK))
    goto dispatch_flow_ret;

  if (gst_source->buffer)
    gst_buffer_unref (gst_source->buffer);

  gst_source->buffer = gst_buffer_ref (buffer);
  g_mutex_unlock (&gst_source->buffer_lock);

  g_main_context_wakeup (NULL);

  return GST_FLOW_OK;

  dispatch_flow_ret:
  {
    g_mutex_unlock (&gst_source->buffer_lock);
    return priv->flow_return;
  }
}
示例#10
0
webpopup_result_t *
webpopup_create(const char *url, const char *title, const char *trap)
{
  webpopup_t *wp = calloc(1, sizeof(webpopup_t));
  webpopup_result_t *wr = &wp->wp_wr;
  hts_cond_init(&wp->wp_cond, &gdk_mutex);
  wp->wp_wr.wr_resultcode = -1;
  wp->wp_url   = strdup(url);
  wp->wp_title = strdup(title);
  wp->wp_trap  = strdup(trap);

  hts_mutex_lock(&gdk_mutex);
  LIST_INSERT_HEAD(&pending_open, wp, wp_link);
  g_main_context_wakeup(g_main_context_default());

  while(wp->wp_wr.wr_resultcode == -1)
    hts_cond_wait(&wp->wp_cond, &gdk_mutex);

  gdk_threads_leave();

  webpopup_finalize_result(wr);

  free(wp->wp_url);
  free(wp->wp_title);
  free(wp->wp_trap);

  return wr;
}
示例#11
0
文件: call.c 项目: PkmX/darktable
void dt_lua_async_call_alien_internal(const char * call_function, int line,lua_CFunction pusher,int nresults,dt_lua_finish_callback cb, void*cb_data, dt_lua_async_call_arg_type arg_type,...)
{
#ifdef _DEBUG
  dt_print(DT_DEBUG_LUA,"LUA DEBUG : %s called from %s %d\n",__FUNCTION__,call_function,line);
#endif
  async_call_data*data = malloc(sizeof(async_call_data));
  data->pusher = pusher;
  data->extra=NULL;
  data->cb = cb;
  data->cb_data = cb_data;
  data->nresults = nresults;
  va_list ap;
  va_start(ap,arg_type);
  dt_lua_async_call_arg_type cur_type = arg_type;
  while(cur_type != LUA_ASYNC_DONE){
    data->extra=g_list_append(data->extra,GINT_TO_POINTER(cur_type));
    switch(cur_type) {
      case LUA_ASYNC_TYPEID:
        data->extra=g_list_append(data->extra,GINT_TO_POINTER(va_arg(ap,luaA_Type)));
        data->extra=g_list_append(data->extra,va_arg(ap,gpointer));
        break;
      case LUA_ASYNC_TYPEID_WITH_FREE:
        {
          data->extra=g_list_append(data->extra,GINT_TO_POINTER(va_arg(ap,luaA_Type)));
          data->extra=g_list_append(data->extra,va_arg(ap,gpointer));
          GClosure* closure = va_arg(ap,GClosure*);
          g_closure_ref (closure);
          g_closure_sink (closure);
          g_closure_set_marshal(closure, g_cclosure_marshal_generic);
          data->extra=g_list_append(data->extra,closure);
        }
        break;
      case LUA_ASYNC_TYPENAME:
        data->extra=g_list_append(data->extra,va_arg(ap,char *));
        data->extra=g_list_append(data->extra,va_arg(ap,gpointer));
        break;
      case LUA_ASYNC_TYPENAME_WITH_FREE:
        {
          data->extra=g_list_append(data->extra,va_arg(ap,char *));
          data->extra=g_list_append(data->extra,va_arg(ap,gpointer));
          GClosure* closure = va_arg(ap,GClosure*);
          g_closure_ref (closure);
          g_closure_sink (closure);
          g_closure_set_marshal(closure, g_cclosure_marshal_generic);
          data->extra=g_list_append(data->extra,closure);
        }
        break;
      default:
        // should never happen
        g_assert(false);
        break;
    }
    cur_type = va_arg(ap,dt_lua_async_call_arg_type);
  }

  va_end(ap);

  g_async_queue_push(darktable.lua_state.alien_job_queue,(gpointer)data);
  g_main_context_wakeup(darktable.lua_state.context);
}
示例#12
0
int
arch_stop_req(void)
{
    running = 0;
    g_main_context_wakeup(g_main_context_default());
    return 0;
}
示例#13
0
/*
 * _clutter_master_clock_start_running:
 * @master_clock: a #ClutterMasterClock
 *
 * Called when we have events or redraws to process; if the clock
 * is stopped, does the processing necessary to wake it up again.
 */
void
_clutter_master_clock_start_running (ClutterMasterClock *master_clock)
{
  /* If called from a different thread, we need to wake up the
   * main loop to start running the timelines
   */
  g_main_context_wakeup (NULL);
}
示例#14
0
void RunLoop::wakeUp()
{
    RefPtr<RunLoop> runLoop(this);
    GMainLoopSource::scheduleAndDeleteOnDestroy("[WebKit] RunLoop work", std::function<void()>([runLoop] {
        runLoop->performWork();
    }), G_PRIORITY_DEFAULT, nullptr, m_mainContext.get());
    g_main_context_wakeup(m_mainContext.get());
}
示例#15
0
文件: init.c 项目: AlicVB/darktable
void dt_lua_finalize_early()
{
  darktable.lua_state.ending = true;
  dt_lua_lock();
  dt_lua_event_trigger(darktable.lua_state.state,"exit",0);
  dt_lua_unlock();
  g_main_context_wakeup(darktable.lua_state.context);
}
示例#16
0
static void
cancellable_source_cancelled (GCancellable *cancellable,
			      gpointer      user_data)
{
  GSource *source = user_data;

  g_main_context_wakeup (g_source_get_context (source));
}
示例#17
0
static void
on_sysroot_lock_acquired (OstreeSysroot       *sysroot,
                          GAsyncResult        *result,
                          struct ContextState *state)
{
  state->running = FALSE;
  g_main_context_wakeup (state->mainctx);
}
示例#18
0
void RunLoop::wakeUp()
{
    GRefPtr<GSource> source = adoptGRef(g_idle_source_new());
    g_source_set_priority(source.get(), G_PRIORITY_DEFAULT);
    g_source_set_callback(source.get(), reinterpret_cast<GSourceFunc>(&RunLoop::queueWork), this, 0);
    g_source_attach(source.get(), m_runLoopContext.get());

    g_main_context_wakeup(m_runLoopContext.get());
}
示例#19
0
/** 
* @brief Wake up the user's custom mainloop.  Only works if you've
*        implented a custom mainloop via LSCustomGetFds()
* 
* @param  sh 
* @param  lserror 
* 
* @retval
*/
bool
LSCustomWakeUp(LSHandle *sh, LSError *lserror)
{
    LSHANDLE_VALIDATE(sh);

    g_main_context_wakeup(sh->transport->mainloop_context);

    return true;
}
示例#20
0
static gpointer
cockpit_ssh_connect_thread (gpointer user_data)
{
  CockpitSshData *data = user_data;
  data->problem = cockpit_ssh_connect (data);
  g_atomic_int_set (data->connecting, 0);
  g_main_context_wakeup (data->context);
  return data; /* give the data back */
}
示例#21
0
void mir::GLibMainLoop::stop()
{
    detail::add_idle_gsource(main_context, G_PRIORITY_HIGH,
                             [this]
    {
        running = false;
        g_main_context_wakeup(main_context);
    });
}
示例#22
0
/** @internal Send a message to the port. */
int su_source_wakeup(su_port_t *self)
{
  GMainContext *gmc = g_source_get_context(self->sup_source);

  if (gmc)
    g_main_context_wakeup(gmc);

  return 0;
}
示例#23
0
void mir::GLibMainLoop::resume_processing_for(void const* owner)
{
    std::lock_guard<std::mutex> lock{do_not_process_mutex};

    auto const new_end = std::remove(do_not_process.begin(), do_not_process.end(), owner);
    do_not_process.erase(new_end, do_not_process.end());

    // Wake up the context to reprocess all sources
    g_main_context_wakeup(main_context);
}
示例#24
0
static void
post_event(XmrSearchBox *box, guint type, gpointer event)
{
	SearchEvent *e = g_new(SearchEvent, 1);
	e->type = type;
	e->event = event;

	g_async_queue_push(box->priv->event_queue, e);
	g_main_context_wakeup(g_main_context_default());
}
osync_bool osync_queue_send_message_with_timeout(OSyncQueue *queue, OSyncQueue *replyqueue, OSyncMessage *message, unsigned int timeout, OSyncError **error)
{
  osync_trace(TRACE_ENTRY, "%s(%p, %p, %p, %u, %p)", __func__, queue, replyqueue, message, timeout, error);

  if (osync_message_get_handler(message)) {
    OSyncPendingMessage *pending = NULL;
    GTimeVal current_time;
    long long int id = 0;
    osync_assert(replyqueue);
    pending = osync_try_malloc0(sizeof(OSyncPendingMessage), error);
    if (!pending)
      goto error;

    /* g_sourcet_get_current_time used cached time ... hopefully faster then g_get_.._time() */
    g_source_get_current_time(queue->timeout_source, &current_time);

    id = gen_id(&current_time);
    osync_message_set_id(message, id);
    pending->id = id;
    osync_trace(TRACE_INTERNAL, "Setting id %lli for pending reply", id);

    if (timeout) {
      OSyncTimeoutInfo *toinfo = osync_try_malloc0(sizeof(OSyncTimeoutInfo), error);
      if (!toinfo)
        goto error;

      toinfo->expiration = current_time;
      toinfo->expiration.tv_sec += timeout;

      pending->timeout_info = toinfo;
    } else {
      osync_trace(TRACE_INTERNAL, "handler message got sent without timeout!: %s", osync_message_get_commandstr(message));
    }
		
    pending->callback = osync_message_get_handler(message);
    pending->user_data = osync_message_get_handler_data(message);
		
    g_mutex_lock(replyqueue->pendingLock);
    replyqueue->pendingReplies = g_list_append(replyqueue->pendingReplies, pending);
    g_mutex_unlock(replyqueue->pendingLock);
  }
	
  osync_message_ref(message);
  g_async_queue_push(queue->outgoing, message);

  g_main_context_wakeup(queue->context);

  osync_trace(TRACE_EXIT, "%s", __func__);
  return TRUE;

 error:
  osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error));
  return FALSE;
}
示例#26
0
static __inline__ void
hm_net_scheduler_wakup(HmNetSched *sched)
{
	gint index;

	for (index = 0; index < sched->nr_loops; ++index)
	{
		HmSchedLoop *l = &sched->loops[index];
		g_main_context_wakeup(l->context);
	}
}
示例#27
0
void
_gck_call_async_short (GckCall *call, CK_RV rv)
{
	g_assert (GCK_IS_CALL (call));

	call->rv = rv;

	/* Already complete, so just push it for processing in main loop */
	g_assert (GCK_CALL_GET_CLASS (call)->completed_queue);
	g_async_queue_push (GCK_CALL_GET_CLASS (call)->completed_queue, call);
	g_main_context_wakeup (NULL);
}
示例#28
0
/** send msg to a queue */
gboolean MsgSend(LOOP_STR* ps, char* msg) {
    gboolean res = FALSE;
    if (ps == NULL) {
	twmsg(__func__, "ERROR pv=NULL");
    } else {
	/* create new copy of msg and send, then wakeup context */
	char* msg_data = g_strdup(msg);
	g_async_queue_push(ps->Q, msg_data);
	g_main_context_wakeup(ps->main_context);
	res = TRUE;
    }
    return(res);
}
示例#29
0
CAResult_t CAStopLEGattServer()
{
    OIC_LOG(DEBUG, TAG, "IN");

    ca_mutex_lock(g_leServerStateMutex);

    if (false == g_isLEGattServerStarted)
    {
        OIC_LOG(ERROR, TAG, "Gatt Server is not running to stop");
        ca_mutex_unlock(g_leServerStateMutex);
        return CA_STATUS_OK;
    }

    g_isLEGattServerStarted = false;

    CAResult_t res = CALEStopAdvertise();
    {
        OIC_LOG_V(ERROR, TAG, "CALEStopAdvertise failed with ret[%d]", res);
    }

    res = CADeInitLEGattServer();
    if (CA_STATUS_OK != res)
    {
        OIC_LOG_V(ERROR, TAG, "CADeInitLEGattService failed with ret[%d]", res);
    }

    GMainContext  *context_event_loop = NULL;
    // Required for waking up the thread which is running in gmain loop
    if (NULL != g_eventLoop)
    {
        context_event_loop = g_main_loop_get_context(g_eventLoop);

        if (context_event_loop)
        {
            OIC_LOG_V(DEBUG,  TAG, "g_eventLoop context %x", context_event_loop);
            g_main_context_wakeup(context_event_loop);

            // Kill g main loops and kill threads
            g_main_loop_quit(g_eventLoop);
        }
    }
    else
    {
        OIC_LOG(ERROR, TAG, "g_eventLoop context is NULL");
    }

    ca_mutex_unlock(g_leServerStateMutex);

    OIC_LOG(DEBUG, TAG, "OUT");
    return CA_STATUS_OK;
}
示例#30
0
static void
process_async_call (gpointer data, GckCallClass *klass)
{
	GckCall *call = GCK_CALL (data);

	g_assert (GCK_IS_CALL (call));

	call->rv = perform_call (call->perform, call->cancellable, call->args);

	g_async_queue_push (klass->completed_queue, call);

	/* Wakeup main thread if on a separate thread */
	g_main_context_wakeup (NULL);
}