static void
yelp_transform_dispose (GObject *object)
{
    YelpTransformPrivate *priv = GET_PRIV (object);

    debug_print (DB_FUNCTION, "entering\n");

    if (priv->queue) {
        gchar *chunk_id;
        while ((chunk_id = (gchar *) g_async_queue_try_pop (priv->queue)))
            g_free (chunk_id);
        g_async_queue_unref (priv->queue);
        priv->queue = NULL;
    }

    /* We do not free input or aux.  They belong to the caller, which
       must ensure they exist for the lifetime of the transform.  We
       have to set priv->aux_xslt->doc (which is priv->aux) to NULL
       before xsltFreeTransformContext.  Otherwise it will be freed,
       which we don't want.
     */
    if (priv->aux_xslt)
        priv->aux_xslt->doc = NULL;

    /* We free these in dispose to make absolutely certain that they're
       freed by the time any weak notify callbacks are called.  These
       may be used elsewhere to free resources like the input document.
     */
    if (priv->context) {
        xsltFreeTransformContext (priv->context);
        priv->context = NULL;
    }
    if (priv->stylesheet) {
        xsltFreeStylesheet (priv->stylesheet);
        priv->stylesheet = NULL;
    }
    if (priv->output) {
        xmlFreeDoc (priv->output);
        priv->output = NULL;
    }

    G_OBJECT_CLASS (yelp_transform_parent_class)->dispose (object);
}
Exemple #2
0
gboolean myMainLoop(gpointer app)
{
	if (shouldRead)
	{
		read_data(app);
	}

	send_arg* cmd;
 
	if (cmd = g_async_queue_try_pop(sendqueue))
	{
		hu_aap_enc_send(cmd->retry, cmd->chan, cmd->cmd_buf, cmd->cmd_len);
		if(cmd->shouldFree)
			free(cmd->cmd_buf);
		free(cmd);
	}

	return TRUE; 
}
Exemple #3
0
SaErrorT oh_process_events()
{
        struct oh_event *e;

        while((e = g_async_queue_try_pop(oh_process_q)) != NULL) {

                /* FIXME: add real check if handler is allowed to push event
                   to the domain id in the event */
                if(e->did != oh_get_default_domain_id()) {
                        dbg("Domain Id %d not valid for event", e->did);
                        g_free(e);
                        return SA_ERR_HPI_INVALID_DATA;
                }

                switch(e->type) {
                case OH_ET_RESOURCE:
                        trace("Event Type = Resource");
                        process_resource_event(e);
                        break;
                case OH_ET_RESOURCE_DEL:
                        trace("Event Type = Resource Delete");
                        process_resource_event(e);
                        break;
                case OH_ET_RDR:
                        trace("Event Type = RDR");
                        process_rdr_event(e);
                        break;
                case OH_ET_RDR_DEL:
                        trace("Event Type = RDR Delete");
                        process_rdr_event(e);
                        break;
                case OH_ET_HPI:
                        trace("Event Type = HPI Event");
                        process_hpi_event(e);
                        break;
                default:
                        trace("Event Type = Unknown Event");
                }
        }
        g_free(e);
        return SA_OK;
}
Exemple #4
0
static GstFlowReturn
gst_vtdec_push_frames_if_needed (GstVtdec * vtdec, gboolean drain,
    gboolean flush)
{
  GstVideoCodecFrame *frame;
  GstFlowReturn ret = GST_FLOW_OK;
  GstVideoDecoder *decoder = GST_VIDEO_DECODER (vtdec);

  /* negotiate now so that we know whether we need to use the GL upload meta or
   * not */
  if (gst_pad_check_reconfigure (decoder->srcpad)) {
    gst_video_decoder_negotiate (decoder);
  }

  if (drain)
    VTDecompressionSessionWaitForAsynchronousFrames (vtdec->session);

  /* push a buffer if there are enough frames to guarantee that we push in PTS
   * order
   */
  while ((g_async_queue_length (vtdec->reorder_queue) >=
          vtdec->reorder_queue_length) || drain || flush) {
    frame = (GstVideoCodecFrame *) g_async_queue_try_pop (vtdec->reorder_queue);

    /* we need to check this in case reorder_queue_length=0 (jpeg for
     * example) or we're draining/flushing
     */
    if (frame) {
      if (flush || frame->flags & VTDEC_FRAME_FLAG_SKIP)
        gst_video_decoder_release_frame (decoder, frame);
      else if (frame->flags & VTDEC_FRAME_FLAG_DROP)
        gst_video_decoder_drop_frame (decoder, frame);
      else
        ret = gst_video_decoder_finish_frame (decoder, frame);
    }

    if (!frame || ret != GST_FLOW_OK)
      break;
  }

  return ret;
}
gint queue_timer_event(gpointer data)
{
	struct OsecpuWindow* window = data;
	struct WindowQueue* qdata = g_async_queue_try_pop(window->queue);
	if (qdata) {
		switch (qdata->type) {
			case QUEUE_DESTROY:
				g_signal_emit_by_name(window->window, "destroy");
				break;
			case QUEUE_REDRAW:
				gdk_window_invalidate_rect(gtk_widget_get_window(GTK_WIDGET(window->window)), NULL, 1);
				break;
			case QUEUE_RESIZE:
				gtk_window_resize(window->window, qdata->arg.resize.width, qdata->arg.resize.height);
				break;
		}
		free(qdata);
	}
	return TRUE;
}
static gpointer
_gq2zmq_worker (struct _gq2zmq_ctx_s *ctx)
{
	while (ctx->running (_gq2zmq_has_pending (ctx))) {
		gchar *tmp =
			(gchar*) g_async_queue_timeout_pop (ctx->queue, G_TIME_SPAN_SECOND);
		if (tmp && !_forward_event (ctx->zpush, tmp))
			break;
	}

	for (;;) { /* manage what remains in the GQueue */
		gchar *tmp = g_async_queue_try_pop (ctx->queue);
		if (!tmp || !_forward_event (ctx->zpush, tmp))
			break;
	}

	zmq_send (ctx->zpush, "EOF", 0, 0);
	GRID_INFO ("Thread stopping [NOTIFY-GQ2ZMQ]");
	return ctx;
}
static inline GstVideoCodecFrame *
pop_frame (GstVaapiDecoder * decoder, guint64 timeout)
{
  GstVideoCodecFrame *frame;
  GstVaapiSurfaceProxy *proxy;

  if (G_LIKELY (timeout > 0))
    frame = g_async_queue_timeout_pop (decoder->frames, timeout);
  else
    frame = g_async_queue_try_pop (decoder->frames);
  if (!frame)
    return NULL;

  proxy = frame->user_data;
  GST_DEBUG ("pop frame %d (surface 0x%08x)", frame->system_frame_number,
      (proxy ? (guint32) GST_VAAPI_SURFACE_PROXY_SURFACE_ID (proxy) :
          VA_INVALID_ID));

  return frame;
}
Exemple #8
0
void li_collect_watcher_cb(liEventBase *watcher, int events) {
	liWorker *wrk = LI_CONTAINER_OF(li_event_async_from(watcher), liWorker, collect_watcher);
	collect_job *j;
	UNUSED(events);

	while (NULL != (j = (collect_job*) g_async_queue_try_pop(wrk->collect_queue))) {
		liCollectInfo *ci = j->ci;
		switch (j->type) {
		case COLLECT_FUNC:
			g_ptr_array_index(ci->results, wrk->ndx) = ci->func(wrk, ci->fdata);
			collect_send_result(wrk, ci);
			break;
		case COLLECT_CB:
			ci->cb(ci->cbdata, ci->fdata, ci->results, !ci->stopped);
			collect_info_free(ci);
			break;
		}
		g_slice_free(collect_job, j);
	}
}
Exemple #9
0
static void
_manage_events(struct network_server_s *srv)
{
	struct network_client_s *clt;
	struct epoll_event allev[MAXEV], *pev;
	struct timespec now;
	int rc, erc;

	(void) rc;
	erc = epoll_wait(srv->epollfd, allev, MAXEV, 500);
	if (erc > 0) {
		network_server_now(&now);
		while (erc-- > 0) {
			pev = allev+erc;

			if (pev->data.ptr == srv->wakeup)
				continue;
			if (MAGIC_ENDPOINT == *((unsigned int*)(pev->data.ptr))) {
				struct endpoint_s *e = pev->data.ptr;
				while (NULL != (clt = _endpoint_manage_event(srv, e))) {
					if (clt->current_error) {
						_client_clean(srv, clt);
					} else {
						ARM_CLIENT(srv, clt, EPOLL_CTL_ADD);
					}
				}
				ARM_ENDPOINT(srv, e, EPOLL_CTL_MOD);
			}
			else {
				_manage_client_event(srv, pev->data.ptr, pev->events, &now);
			}
		}
	}

	_drain(srv->wakeup[0]);
	ARM_WAKER(srv, EPOLL_CTL_MOD);
	while (NULL != (clt = g_async_queue_try_pop(srv->queue_monitor))) {
		EXTRA_ASSERT(clt->events != 0 && !(clt->events & CLT_ERROR));
		ARM_CLIENT(srv, clt, EPOLL_CTL_MOD);
	}
}
Exemple #10
0
/**
 * oh_dequeue_session_event
 * @sid:
 * @event:
 *
 *
 *
 * Returns:
 **/
SaErrorT oh_dequeue_session_event(SaHpiSessionIdT sid,
                                  SaHpiTimeoutT timeout,
                                  struct oh_event *event)
{
       struct oh_session *session = NULL;
       struct oh_event *devent = NULL;
       GTimeVal gfinaltime;
       GAsyncQueue *eventq = NULL;

       if (sid < 1 || (event == NULL)) return SA_ERR_HPI_INVALID_PARAMS;

       g_static_rec_mutex_lock(&oh_sessions.lock); /* Locked session table */
       session = g_hash_table_lookup(oh_sessions.table, &sid);
       if (!session) {
               g_static_rec_mutex_unlock(&oh_sessions.lock);
               return SA_ERR_HPI_INVALID_SESSION;
       }
       eventq = session->eventq;
       g_async_queue_ref(eventq);
       g_static_rec_mutex_unlock(&oh_sessions.lock);

       if (timeout == SAHPI_TIMEOUT_IMMEDIATE) {
               devent = g_async_queue_try_pop(eventq);
       } else if (timeout == SAHPI_TIMEOUT_BLOCK) {
               devent = g_async_queue_pop(eventq); /* FIXME: Need to time this. */
       } else {
               g_get_current_time(&gfinaltime);
               g_time_val_add(&gfinaltime, (glong) (timeout / 1000));
               devent = g_async_queue_timed_pop(eventq, &gfinaltime);
       }
       g_async_queue_unref(eventq);

       if (devent) {
               memcpy(event, devent, sizeof(struct oh_event));
               g_free(devent);
               return SA_OK;
       } else {
               memset(event, 0, sizeof(struct oh_event));
               return SA_ERR_HPI_TIMEOUT;
       }
}
static gboolean
transform_chunk (YelpTransform *transform)
{
    YelpTransformPrivate *priv = GET_PRIV (transform);
    gchar *chunk_id;

    debug_print (DB_FUNCTION, "entering\n");

    if (priv->cancelled)
        goto done;

    chunk_id = (gchar *) g_async_queue_try_pop (priv->queue);

    g_signal_emit (transform, signals[CHUNK_READY], 0, chunk_id);

    g_free (chunk_id);

 done:
    g_object_unref (transform);
    return FALSE;
}
Exemple #12
0
void li_job_queue_clear(liJobQueue *jq) {
	if (NULL == jq->async_queue) return;

	while (jq->queue.length > 0 || g_async_queue_length(jq->async_queue) > 0) {
		liJobRef *jobref;

		while (NULL != (jobref = g_async_queue_try_pop(jq->async_queue))) {
			li_job_now_ref(jobref);
			li_job_ref_release(jobref);
		}

		job_queue_run(jq, 1);
	}

	g_async_queue_unref(jq->async_queue);
	jq->async_queue = NULL;

	li_event_clear(&jq->async_queue_watcher);
	li_event_clear(&jq->prepare_watcher);
	li_event_clear(&jq->queue_watcher);
}
Exemple #13
0
void li_collect_watcher_cb(struct ev_loop *loop, ev_async *w, int revents) {
	liWorker *wrk = (liWorker*) w->data;
	collect_job *j;
	UNUSED(loop);
	UNUSED(revents);

	while (NULL != (j = (collect_job*) g_async_queue_try_pop(wrk->collect_queue))) {
		liCollectInfo *ci = j->ci;
		switch (j->type) {
		case COLLECT_FUNC:
			g_ptr_array_index(ci->results, wrk->ndx) = ci->func(wrk, ci->fdata);
			collect_send_result(wrk, ci);
			break;
		case COLLECT_CB:
			ci->cb(ci->cbdata, ci->fdata, ci->results, !ci->stopped);
			collect_info_free(ci);
			break;
		}
		g_slice_free(collect_job, j);
	}
}
Exemple #14
0
static void finished_watcher_cb(struct ev_loop *loop, ev_async *w, int revents) {
	liTaskletPool *pool = w->data;
	liTasklet *t;
	UNUSED(loop);
	UNUSED(revents);

	pool->delete_later = -1;

	while (NULL != (t = g_async_queue_try_pop(pool->finished))) {
		t->finished_cb(t->data);

		g_slice_free(liTasklet, t);

		if (1 == pool->delete_later) {
			g_slice_free(liTaskletPool, pool);
			return;
		}
	}

	pool->delete_later = 0;
}
Exemple #15
0
int Action::run_all( GAsyncQueue * queue )
{
    g_assert( queue );

    int result = 0;

    g_async_queue_ref( queue );

    while ( Action * action = ( Action * ) g_async_queue_try_pop( queue ) )
    {
        run_internal( action );

        delete action;

        ++result;
    }

    g_async_queue_unref( queue );

    return result;
}
/* This function runs on the main thread. It will be called each second.
 * It's purpose it's to check for the presence of a new FacqPipelineMessage
 * coming from the Producer/Consumer thread. Worker threads will push
 * a message to the Queue in case of error, or if stop condition is reach.
 * This function checks the type of the message and calls the corresponding
 * function to the type, that will ran on the main thread, so in case of error
 * or stop condition the pipeline could be stopped from the main thread.
 */
static gboolean facq_pipeline_monitor_timeout_func(gpointer monitor)
{
	FacqPipelineMonitor *mon = FACQ_PIPELINE_MONITOR(monitor);
	FacqPipelineMessage *msg = NULL;

	msg = g_async_queue_try_pop(mon->priv->q);
	if(msg){
		switch(facq_pipeline_message_get_msg_type(msg)){
		case FACQ_PIPELINE_MESSAGE_TYPE_N:
		case FACQ_PIPELINE_MESSAGE_TYPE_ERROR:
			mon->priv->error_cb(msg,mon->priv->data);
		break;
		case FACQ_PIPELINE_MESSAGE_TYPE_STOP:
			mon->priv->stop_cb(msg,mon->priv->data);
		break;
		}
		facq_pipeline_message_free(msg);
		return FALSE;
	}
	return TRUE;
}
Exemple #17
0
BOOL rf_check_fds(RemminaProtocolWidget* gp)
{
    UINT16 flags;
    gchar buf[100];
    rdpInput* input;
    rfContext* rfi;
    RemminaPluginRdpEvent* event;

    rfi = GET_DATA(gp);

    if (rfi->event_queue == NULL)
        return True;

    input = rfi->instance->input;

    while ((event =(RemminaPluginRdpEvent*) g_async_queue_try_pop(rfi->event_queue)) != NULL)
    {
        switch (event->type)
        {
        case REMMINA_RDP_EVENT_TYPE_SCANCODE:
            flags = event->key_event.extended ? KBD_FLAGS_EXTENDED : 0;
            flags |= event->key_event.up ? KBD_FLAGS_RELEASE : KBD_FLAGS_DOWN;
            input->KeyboardEvent(input, flags, event->key_event.key_code);
            break;

        case REMMINA_RDP_EVENT_TYPE_MOUSE:
            input->MouseEvent(input, event->mouse_event.flags,
                              event->mouse_event.x, event->mouse_event.y);
            break;
        }

        g_free(event);
    }

    if (read(rfi->event_pipe[0], buf, sizeof (buf)))
    {
    }

    return True;
}
Exemple #18
0
gboolean remmina_rdp_event_queue_ui(RemminaProtocolWidget* gp)
{
	rfContext* rfi;
	RemminaPluginRdpUiObject* ui;

	rfi = GET_DATA(gp);

	ui = (RemminaPluginRdpUiObject*) g_async_queue_try_pop(rfi->ui_queue);

	if (ui)
	{
		switch (ui->type)
		{
			case REMMINA_RDP_UI_UPDATE_REGION:
				remmina_rdp_event_update_region(gp, ui);
				break;

			case REMMINA_RDP_UI_CONNECTED:
				remmina_rdp_event_connected(gp, ui);
				break;

			case REMMINA_RDP_UI_UPDATE_CURSOR:
				remmina_rdp_event_update_cursor(gp, ui);
				break;

			default:
				break;
		}
		rf_object_free(gp, ui);

		return TRUE;
	}
	else
	{
		LOCK_BUFFER(FALSE)
		rfi->ui_handler = 0;
		UNLOCK_BUFFER(FALSE)
		return FALSE;
	}
}
/**
 * gst_v4l2_buffer_pool_get:
 * @pool:   the "this" object
 * @blocking:  should this call suspend until there is a buffer available
 *    in the buffer pool?
 *
 * Get an available buffer in the pool
 */
GstV4l2Buffer *
gst_v4l2_buffer_pool_get (GstV4l2BufferPool * pool, gboolean blocking)
{
  GstV4l2Buffer *buf;

  if (blocking) {
    buf = g_async_queue_pop (pool->avail_buffers);
  } else {
    buf = g_async_queue_try_pop (pool->avail_buffers);
  }

  if (buf) {
    GST_V4L2_BUFFER_POOL_LOCK (pool);
    GST_BUFFER_SIZE (buf) = buf->vbuffer.length;
    GST_BUFFER_FLAG_UNSET (buf, 0xffffffff);
    GST_V4L2_BUFFER_POOL_UNLOCK (pool);
  }

  pool->running = TRUE;

  return buf;
}
Exemple #20
0
void
_tf_allegro_process_incoming (struct TfAlTimerState *tf)
{
  MTfMsg *msg;
  while ((!tf->kill_me) &&
         (msg = g_async_queue_try_pop (tf->qu_in)))
    {
      switch (msg->msg_type)
        {
      case TF_MSGTYPE_ALLEGRO_TIMER:
          MTfMsgAllegroTimer *mm;
          mm = M_TFMSG_ALLEGRO_TIMER (msg);

          if (mm->kill)
              tf->kill_me = TRUE;
          break;
      default:
          g_xassert (("EEH MAJI, UNHANDLED MESSAGE TYPE", FALSE));
          break;
        }
    }
}
static gpointer
task_thread (RBMtpThread *thread)
{
	RBMtpThreadTask *task;
	gboolean quit = FALSE;

	rb_debug ("MTP device worker thread starting");
	while (quit == FALSE) {

		task = g_async_queue_pop (thread->queue);
		quit = run_task (thread, task);
		destroy_task (task);
	}

	rb_debug ("MTP device worker thread exiting");
	
	/* clean up any queued tasks */
	while ((task = g_async_queue_try_pop (thread->queue)) != NULL)
		destroy_task (task);

	return NULL;
}
Exemple #22
0
void li_tasklet_pool_free(liTaskletPool *pool) {
	liTasklet *t;

	if (!pool) return;

	li_tasklet_pool_set_threads(pool, 0);

	while (NULL != (t = g_async_queue_try_pop(pool->finished))) {
		t->finished_cb(t->data);
	}
	g_async_queue_unref(pool->finished);
	pool->finished = NULL;

	ev_ref(pool->loop);
	ev_async_stop(pool->loop, &pool->finished_watcher);

	if (-1 == pool->delete_later) {
		pool->delete_later = 1;
	} else {
		g_slice_free(liTaskletPool, pool);
	}
}
static void janus_websockets_destroy_client(
		janus_websockets_client *ws_client,
		struct lws *wsi,
		const char *log_prefix) {
	if(!ws_client || !g_atomic_int_compare_and_exchange(&ws_client->destroyed, 0, 1))
		return;
	/* Cleanup */
	janus_mutex_lock(&ws_client->ts->mutex);
	JANUS_LOG(LOG_INFO, "[%s-%p] Destroying WebSocket client\n", log_prefix, wsi);
	ws_client->wsi = NULL;
	/* Notify handlers about this transport being gone */
	if(notify_events && gateway->events_is_enabled()) {
		json_t *info = json_object();
		json_object_set_new(info, "event", json_string("disconnected"));
		gateway->notify_event(&janus_websockets_transport, ws_client->ts, info);
	}
	/* Notify core */
	gateway->transport_gone(&janus_websockets_transport, ws_client->ts);
	ws_client->ts->transport_p = NULL;
	/* Remove messages queue too, if needed */
	if(ws_client->messages != NULL) {
		char *response = NULL;
		while((response = g_async_queue_try_pop(ws_client->messages)) != NULL) {
			g_free(response);
		}
		g_async_queue_unref(ws_client->messages);
	}
	/* ... and the shared buffers */
	g_free(ws_client->incoming);
	ws_client->incoming = NULL;
	g_free(ws_client->buffer);
	ws_client->buffer = NULL;
	ws_client->buflen = 0;
	ws_client->bufpending = 0;
	ws_client->bufoffset = 0;
	janus_mutex_unlock(&ws_client->ts->mutex);
	janus_transport_session_destroy(ws_client->ts);
}
Exemple #24
0
static void __client_injector_cb(struct ev_loop *loop, struct tls_user_context_t *context, int revents)
{
    user_session_t * session;
#if DEBUG_ENABLE
    int i = 0;
#endif

    lock_client_datas();
    while ((session = (user_session_t *) g_async_queue_try_pop(mx_queue))) {
        if (session == NULL)
            continue;
        if (session->pending_disconnect) {
            log_message(INFO,
                        DEBUG_AREA_USER,
                        "disconnecting \'%s\' %d"
#if DEBUG_ENABLE
                        "(%d)"
#endif
                        , session->user_name,
                        session->socket
#if DEBUG_ENABLE
                        , i
#endif
                       );
            delete_locked_client_by_socket(session->socket);
            continue;
        }
        debug_log_message(VERBOSE_DEBUG, DEBUG_AREA_USER, "reinjecting %d (%d)",
                          session->socket, i);
        ev_io_start(session->srv_context->loop, &session->client_watcher);
        session->activated = TRUE;
#if DEBUG_ENABLE
        i++;
#endif
    }
    unlock_client_datas();

}
Exemple #25
0
static void __delete_by_did(gpointer key, gpointer value,
                            gpointer user_data)
{
        SaHpiDomainIdT did = *((SaHpiDomainIdT *) user_data);
        struct oh_session *session = (struct oh_session *) value;
        int i, len;
        gpointer event = NULL;

        if (!session) {
                dbg("Session does not exist!");
                return;
        }

        if (session->did != did) {
                return;
        }

        oh_sessions.list = g_slist_remove(oh_sessions.list, session);
        g_hash_table_remove(oh_sessions.table, &(session->id));

        /* Neutralize event queue */
        len = g_async_queue_length(session->eventq);
        if (len < 0) {
                for (i = 0; i > len; i--) {
                        g_async_queue_push(session->eventq,
                                           oh_generate_hpi_event());
                }
        } else if (len > 0) {
                for (i = 0; i < len; i++) {
                        event = g_async_queue_try_pop(session->eventq);
                        if (event)
                                oh_event_free(event, FALSE);
                        event = NULL;
                }
        }
        g_async_queue_unref(session->eventq);
        g_free(session);
}
static gboolean
byzanz_queue_input_stream_close (GInputStream * input_stream,
				 GCancellable * cancellable,
				 GError **      error)
{
  ByzanzQueueInputStream *stream = BYZANZ_QUEUE_INPUT_STREAM (input_stream);
  GFile *file;

  if (!byzanz_queue_input_stream_close_input (stream, cancellable, error))
    return FALSE;

  g_async_queue_lock (stream->queue->files);
  stream->queue->input_closed = TRUE;
  file = g_async_queue_try_pop_unlocked (stream->queue->files);
  g_async_queue_unlock (stream->queue->files);

  while (file) {
    g_file_delete (file, NULL, NULL);
    file = g_async_queue_try_pop (stream->queue->files);
  }

  return TRUE;
}
Exemple #27
0
static gboolean
transform_chunk (YelpTransform *transform)
{
    gchar *chunk_id;

    transform->idle_funcs--;
    if (transform->released)
	return FALSE;

    chunk_id = (gchar *) g_async_queue_try_pop (transform->queue);

    if (chunk_id) {
	if (transform->func)
	    transform->func (transform,
			     YELP_TRANSFORM_CHUNK,
			     chunk_id,
			     transform->user_data);
	else
	    g_free (chunk_id);
    }

    return FALSE;
}
/**
 * gst_overlay_buffer_pool_get:
 * @pool:   the "this" object
 * @blocking:  should this call suspend until there is a buffer available
 *    in the buffer pool?
 *
 * Get an available buffer in the pool
 */
GstOverlayBuffer *
gst_overlay_buffer_pool_get (GstOverlayBufferPool * pool, gboolean blocking)
{
  GstOverlayBuffer *buf;
  GstSurfaceFlingerSink *surfacesink = GST_SURFACEFLINGERSINK (pool->overlayelem);

  if (blocking) {
    buf = g_async_queue_pop (pool->avail_buffers);
  } else {
    buf = g_async_queue_try_pop (pool->avail_buffers);
  }

  if (buf && buf != GST_OVERLAY_BUFFER_SENTINEL) {
    GST_OVERLAY_BUFFER_POOL_LOCK (pool);
    GST_BUFFER_SIZE (buf) = videoflinger_device_get_overlay_buf_length(surfacesink->videodev);
    GST_BUFFER_FLAG_UNSET (buf, 0xffffffff);
    GST_OVERLAY_BUFFER_POOL_UNLOCK (pool);
  }

  pool->running = TRUE;

  return buf;
}
Exemple #29
0
int
main (int argc, char **argv)
{
  g_thread_init (NULL);
  g_type_init ();

  GAsyncQueue *qu;
  qu = g_async_queue_new ();

  gpointer
  th1_f (gpointer data)
  {
    gpointer wat;

    while (TRUE)
      {
        //wat = g_async_queue_pop (qu);
        wat = g_async_queue_try_pop (qu);
        g_thread_yield ();
      }

    return NULL;
  }
Exemple #30
0
static gboolean string_job_dispatch (GSource* source, GSourceFunc callback, gpointer user_data)
{
  gpointer message;
  message = g_async_queue_try_pop (darktable.lua_state.string_job_queue);
  if (message == NULL)
  {
    return TRUE;
  }
  string_call_data* data = (string_call_data*)message;

  dt_lua_lock();
  lua_State* L= darktable.lua_state.state;
  lua_State *new_thread = lua_newthread(L);
  int reference = save_thread(L);
  lua_pushlightuserdata(new_thread,data->cb);
  lua_pushlightuserdata(new_thread,data->cb_data);
  lua_pushinteger(new_thread,data->nresults);

  int load_result = luaL_loadstring(new_thread, data->function);
  if(load_result != LUA_OK)
  {
    if(data->cb) {
      data->cb(new_thread,load_result,data->cb_data);
    } else {
      dt_lua_check_print_error(new_thread,load_result);
    }
    drop_thread(L,reference);
    dt_lua_unlock();
    string_data_destroy(data);
    return G_SOURCE_CONTINUE;
  }

  run_async_thread(L,reference);
  dt_lua_unlock();
  string_data_destroy(data);
  return G_SOURCE_CONTINUE;
}