static GstPadProbeReturn
eos_pushed_probe (GstPad * pad, GstPadProbeInfo * info, gpointer udata)
{
  g_mutex_lock (&eos_probe_lock);
  if (GST_EVENT_TYPE (info->data) == GST_EVENT_EOS) {
    eos_received = TRUE;
    g_cond_broadcast (&eos_probe_cond);
  }
  g_mutex_unlock (&eos_probe_lock);

  return GST_PAD_PROBE_OK;
}
static void
_run_message_sync (GstGLSyncMessage * message)
{

  if (message->callback)
    message->callback (message->data);

  g_mutex_lock (&message->window->priv->sync_message_lock);
  message->fired = TRUE;
  g_cond_broadcast (&message->window->priv->sync_message_cond);
  g_mutex_unlock (&message->window->priv->sync_message_lock);
}
Exemple #3
0
void Scheduler::addJob(Job * job, JobPriority priority) {
	XOJ_CHECK_TYPE(Scheduler);

	g_mutex_lock(this->jobQueueMutex);

	job->ref();
	g_queue_push_tail(this->jobQueue[priority], job);
	g_cond_broadcast(this->jobQueueCond);

	SDEBUG("add job: %ld\n", (long)job);

	g_mutex_unlock(this->jobQueueMutex);
}
Exemple #4
0
static void
ev_job_queue_push (EvSchedulerJob *job,
		   EvJobPriority   priority)
{
	ev_debug_message (DEBUG_JOBS, "%s priority %d", EV_GET_TYPE_NAME (job->job), priority);
	
	g_mutex_lock (&job_queue_mutex);

	g_queue_push_tail (job_queue[priority], job);
	g_cond_broadcast (&job_queue_cond);
	
	g_mutex_unlock (&job_queue_mutex);
}
int  glib_jsonrpc_server_send_async_response(GLibJsonRpcAsyncQuery *_query,
                                             int error_num,
                                             JsonNode *reply)
{
  GLibJsonRpcAsyncQueryPrivate *query = (GLibJsonRpcAsyncQueryPrivate *)_query;
  query->reply = reply;
  query->error_num = error_num;
  g_mutex_lock(&query->mutex);
  g_cond_broadcast(&query->cond);
  g_mutex_unlock(&query->mutex);

  return TRUE;
}
Exemple #6
0
static gboolean
gst_app_src_unlock_stop (GstBaseSrc * bsrc)
{
  GstAppSrc *appsrc = GST_APP_SRC (bsrc);

  g_mutex_lock (appsrc->priv->mutex);
  GST_DEBUG_OBJECT (appsrc, "unlock stop");
  appsrc->priv->flushing = FALSE;
  g_cond_broadcast (appsrc->priv->cond);
  g_mutex_unlock (appsrc->priv->mutex);

  return TRUE;
}
Exemple #7
0
gpointer
idle_thread_func(gpointer user_data)
{
  PluginOption *option = ((ThreadData *)user_data)->option;
  int thread_index = ((ThreadData *)user_data)->index;
  int sock_fd = connect_ip_socket(SOCK_STREAM, option->target, option->port, option->use_ipv6);;

  SSL *ssl = open_ssl_connection(sock_fd);
  if (ssl == NULL)
    {
      ERROR("can not connect to %s:%s (%p)\n",option->target, option->port,g_thread_self());
    }
  else
    {
      DEBUG("(%d) connected to server on socket (%p)\n",thread_index,g_thread_self());
    }

  g_mutex_lock(thread_lock);
  connect_finished++;

  if (connect_finished == active_thread_count + idle_thread_count)
    g_cond_broadcast(thread_connected);

  g_mutex_unlock(thread_lock);

  DEBUG("thread (%s,%p) created. wait for start ...\n",loggen_plugin_info.name,g_thread_self());
  g_mutex_lock(thread_lock);
  while (!thread_run)
    {
      g_cond_wait(thread_start,thread_lock);
    }
  g_mutex_unlock(thread_lock);

  DEBUG("thread (%s,%p) started. (r=%d,c=%d)\n",loggen_plugin_info.name,g_thread_self(),option->rate,
        option->number_of_messages);

  while (thread_run && active_thread_count>0)
    {
      g_usleep(10*1000);
    }

  g_mutex_lock(thread_lock);
  idle_thread_count--;
  g_mutex_unlock(thread_lock);

  close_ssl_connection(ssl);
  close(sock_fd);
  g_thread_exit(NULL);
  return NULL;
}
Exemple #8
0
/**
 * If the Scheduler is blocking because we are zooming and there are only render jobs
 * we need to wakeup it later
 */
bool Scheduler::jobRenderThreadTimer(Scheduler * scheduler) {
	XOJ_CHECK_TYPE_OBJ(scheduler, Scheduler);

	scheduler->jobRenderThreadTimerId = 0;

	g_mutex_lock(scheduler->blockRenderMutex);
	g_free(scheduler->blockRenderZoomTime);
	scheduler->blockRenderZoomTime = NULL;
	g_mutex_unlock(scheduler->blockRenderMutex);

	g_cond_broadcast(scheduler->jobQueueCond);

	return false;
}
Exemple #9
0
static void
handoff_handler (GstElement *fakesink, GstBuffer *buffer, GstPad *pad,
    gpointer user_data)
{
  g_mutex_lock (&count_mutex);
  buffer_count ++;

  GST_LOG ("buffer %d", buffer_count);

  if (buffer_count == BUFFER_COUNT)
    g_cond_broadcast (&count_cond);
  ts_fail_unless (buffer_count <= SEND_BUFFER_COUNT);
  g_mutex_unlock (&count_mutex);
}
static gpointer moose_job_manager_executor(gpointer data) {
    MooseJob *job;
    MooseJobManager *jm = MOOSE_JOB_MANAGER(data);
    MooseJobManagerPrivate *priv = jm->priv;

    while((job = g_async_queue_pop(jm->priv->job_queue)) != &priv->terminator) {
        gboolean is_already_canceled = FALSE;

        /* Check if the previous job needs to be freed.
         * Also remember the current one and check if its
         * already cancelled */
        g_mutex_lock(&priv->current_job_mutex);
        {
            /* Free previous job (last job is freed in moose_job_manager_unref() */
            if(priv->current_job != NULL) {
                moose_job_free(priv->current_job);
            }

            priv->current_job = job;
            is_already_canceled = job->cancel;
            g_mutex_unlock(&priv->current_job_mutex);

            /* Do actual job */
            if(is_already_canceled == FALSE) {
                void *item = NULL;

                g_object_ref(jm);
                {
                    g_signal_emit(jm, SIGNALS[SIGNAL_DISPATCH], 0, &job->cancel,
                                  job->job_data, &item);
                }
                g_object_unref(jm);

                g_mutex_lock(&priv->hash_table_mutex);
                { g_hash_table_insert(priv->results, GINT_TO_POINTER(job->id), item); }
                g_mutex_unlock(&priv->hash_table_mutex);
            }
        }

        /* Signal that a job was finished */
        g_mutex_lock(&priv->finish_mutex);
        {
            priv->last_finished_job = job->id;
            g_cond_broadcast(&priv->finish_cond);
        }
        g_mutex_unlock(&priv->finish_mutex);
    }

    return NULL;
}
Exemple #11
0
static gboolean
gst_app_src_unlock (GstBaseSrc * bsrc)
{
  GstAppSrc *appsrc = GST_APP_SRC_CAST (bsrc);
  GstAppSrcPrivate *priv = appsrc->priv;

  g_mutex_lock (&priv->mutex);
  GST_DEBUG_OBJECT (appsrc, "unlock start");
  priv->flushing = TRUE;
  g_cond_broadcast (&priv->cond);
  g_mutex_unlock (&priv->mutex);

  return TRUE;
}
Exemple #12
0
/**
 * gst_app_src_set_max_bytes:
 * @appsrc: a #GstAppSrc
 * @max: the maximum number of bytes to queue
 *
 * Set the maximum amount of bytes that can be queued in @appsrc.
 * After the maximum amount of bytes are queued, @appsrc will emit the
 * "enough-data" signal.
 * 
 * Since: 0.10.22
 */
void
gst_app_src_set_max_bytes (GstAppSrc * appsrc, guint64 max)
{
  g_return_if_fail (GST_IS_APP_SRC (appsrc));

  g_mutex_lock (appsrc->priv->mutex);
  if (max != appsrc->priv->max_bytes) {
    GST_DEBUG_OBJECT (appsrc, "setting max-bytes to %" G_GUINT64_FORMAT, max);
    appsrc->priv->max_bytes = max;
    /* signal the change */
    g_cond_broadcast (appsrc->priv->cond);
  }
  g_mutex_unlock (appsrc->priv->mutex);
}
static GstBusSyncReply
gst_hls_demux_fetcher_bus_handler (GstBus * bus,
    GstMessage * message, gpointer data)
{
  GstHLSDemux *demux = GST_HLS_DEMUX (data);

  if (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ERROR) {
    demux->fetcher_error = TRUE;
    g_cond_broadcast (demux->fetcher_cond);
  }

  gst_message_unref (message);
  return GST_BUS_DROP;
}
Exemple #14
0
/**
 * g_cancellable_cancel:
 * @cancellable: a #GCancellable object.
 * 
 * Will set @cancellable to cancelled, and will emit the
 * #GCancellable::cancelled signal. (However, see the warning about
 * race conditions in the documentation for that signal if you are
 * planning to connect to it.)
 *
 * This function is thread-safe. In other words, you can safely call
 * it from a thread other than the one running the operation that was
 * passed the @cancellable.
 *
 * The convention within gio is that cancelling an asynchronous
 * operation causes it to complete asynchronously. That is, if you
 * cancel the operation from the same thread in which it is running,
 * then the operation's #GAsyncReadyCallback will not be invoked until
 * the application returns to the main loop.
 **/
void
g_cancellable_cancel (GCancellable *cancellable)
{
  GCancellablePrivate *priv;

  if (cancellable == NULL ||
      cancellable->priv->cancelled)
    return;

  priv = cancellable->priv;

  G_LOCK(cancellable);
  if (priv->cancelled)
    {
      G_UNLOCK (cancellable);
      return;
    }

  priv->cancelled = TRUE;
  priv->cancelled_running = TRUE;
#ifdef G_OS_WIN32
  if (priv->event)
    SetEvent (priv->event);
#endif
  if (priv->cancel_pipe[1] != -1)
    {
      const char ch = 'x';
      gssize c;

      do
        c = write (priv->cancel_pipe[1], &ch, 1);
      while (c == -1 && errno == EINTR);
    }
  G_UNLOCK(cancellable);

  g_object_ref (cancellable);
  g_signal_emit (cancellable, signals[CANCELLED], 0);

  G_LOCK(cancellable);

  priv->cancelled_running = FALSE;
  if (priv->cancelled_running_waiting)
    g_cond_broadcast (cancellable_cond);
  priv->cancelled_running_waiting = FALSE;

  G_UNLOCK(cancellable);

  g_object_unref (cancellable);
}
static void
gst_test_clock_remove_entry (GstTestClock * test_clock, GstClockEntry * entry)
{
  GstTestClockPrivate *priv = GST_TEST_CLOCK_GET_PRIVATE (test_clock);
  GstClockEntryContext *ctx;

  ctx = gst_test_clock_lookup_entry_context (test_clock, entry);
  if (ctx != NULL) {
    gst_clock_id_unref (ctx->clock_entry);
    priv->entry_contexts = g_list_remove (priv->entry_contexts, ctx);
    g_slice_free (GstClockEntryContext, ctx);

    g_cond_broadcast (&priv->entry_processed_cond);
  }
}
Exemple #16
0
static gboolean
cancel_impl(
    XferElement *elt,
    gboolean expect_eof)
{
    XferDestHolding *self = XFER_DEST_HOLDING(elt);
    gboolean rv;

    /* chain up first */
    rv = XFER_ELEMENT_CLASS(parent_class)->cancel(elt, expect_eof);

    /* then signal all of our condition variables, so that threads waiting on them
     * wake up and see elt->cancelled. */
    g_mutex_lock(self->ring_mutex);
    g_cond_broadcast(self->ring_add_cond);
    g_cond_broadcast(self->ring_free_cond);
    g_mutex_unlock(self->ring_mutex);

    g_mutex_lock(self->state_mutex);
    g_cond_broadcast(self->state_cond);
    g_mutex_unlock(self->state_mutex);

    return rv;
}
Exemple #17
0
static gboolean
io_thread_call_func(gpointer _data)
{
	struct call_data *data = _data;

	gpointer result = data->function(data->data);

	g_mutex_lock(io.mutex);
	data->done = true;
	data->result = result;
	g_cond_broadcast(io.cond);
	g_mutex_unlock(io.mutex);

	return false;
}
Exemple #18
0
void Scheduler::unblockRerenderZoom() {
	XOJ_CHECK_TYPE(Scheduler);

	g_mutex_lock(this->blockRenderMutex);

	g_free(this->blockRenderZoomTime);
	this->blockRenderZoomTime = NULL;
	if(this->jobRenderThreadTimerId) {
		g_source_remove(this->jobRenderThreadTimerId);
		this->jobRenderThreadTimerId = 0;
	}

	g_mutex_unlock(this->blockRenderMutex);

	g_cond_broadcast(this->jobQueueCond);
}
Exemple #19
0
/**
 * g_once_init_leave:
 * @location: location of a static initializable variable containing 0
 * @result: new non-0 value for *@value_location
 *
 * Counterpart to g_once_init_enter(). Expects a location of a static
 * 0-initialized initialization variable, and an initialization value
 * other than 0. Sets the variable to the initialization value, and
 * releases concurrent threads blocking in g_once_init_enter() on this
 * initialization variable.
 *
 * Since: 2.14
 */
void
(g_once_init_leave) (volatile void *location,
                     gsize          result)
{
  volatile gsize *value_location = location;

  g_return_if_fail (g_atomic_pointer_get (value_location) == NULL);
  g_return_if_fail (result != 0);
  g_return_if_fail (g_once_init_list != NULL);

  g_atomic_pointer_set (value_location, result);
  g_mutex_lock (&g_once_mutex);
  g_once_init_list = g_slist_remove (g_once_init_list, (void*) value_location);
  g_cond_broadcast (&g_once_cond);
  g_mutex_unlock (&g_once_mutex);
}
static void
kms_recorder_endpoint_state_changed (KmsRecorderEndpoint * self,
    KmsUriEndpointState state)
{
  KMS_URI_ENDPOINT_GET_CLASS (self)->change_state (KMS_URI_ENDPOINT (self),
      state);
  KMS_ELEMENT_UNLOCK (KMS_ELEMENT (self));

  g_mutex_lock (&self->priv->state_manager.mutex);
  self->priv->state_manager.changing = FALSE;
  if (self->priv->state_manager.locked > 0)
    g_cond_broadcast (&self->priv->state_manager.cond);
  g_mutex_unlock (&self->priv->state_manager.mutex);

  KMS_ELEMENT_LOCK (KMS_ELEMENT (self));
}
Exemple #21
0
/*
 * Set the value of a property for the server sink.
 */
static void
gst_shm_sink_set_property (GObject * object, guint prop_id,
    const GValue * value, GParamSpec * pspec)
{
  GstShmSink *self = GST_SHM_SINK (object);
  int ret = 0;

  switch (prop_id) {
    case PROP_SOCKET_PATH:
      GST_OBJECT_LOCK (object);
      g_free (self->socket_path);
      self->socket_path = g_value_dup_string (value);
      GST_OBJECT_UNLOCK (object);
      break;
    case PROP_PERMS:
      GST_OBJECT_LOCK (object);
      self->perms = g_value_get_uint (value);
      if (self->pipe)
        ret = sp_writer_setperms_shm (self->pipe, self->perms);
      GST_OBJECT_UNLOCK (object);
      if (ret < 0)
        GST_WARNING_OBJECT (object, "Could not set permissions on pipe: %s",
            strerror (ret));
      break;
    case PROP_SHM_SIZE:
      GST_OBJECT_LOCK (object);
      if (self->pipe) {
        if (sp_writer_resize (self->pipe, g_value_get_uint (value)) < 0)
          GST_DEBUG_OBJECT (self, "Resized shared memory area from %u to "
              "%u bytes", self->size, g_value_get_uint (value));
        else
          GST_WARNING_OBJECT (self, "Could not resize shared memory area from"
              "%u to %u bytes", self->size, g_value_get_uint (value));
      }
      self->size = g_value_get_uint (value);
      GST_OBJECT_UNLOCK (object);
      break;
    case PROP_WAIT_FOR_CONNECTION:
      GST_OBJECT_LOCK (object);
      self->wait_for_connection = g_value_get_boolean (value);
      GST_OBJECT_UNLOCK (object);
      g_cond_broadcast (self->cond);
      break;
    default:
      break;
  }
}
Exemple #22
0
static gboolean
gst_app_src_stop (GstBaseSrc * bsrc)
{
  GstAppSrc *appsrc = GST_APP_SRC_CAST (bsrc);
  GstAppSrcPrivate *priv = appsrc->priv;

  g_mutex_lock (&priv->mutex);
  GST_DEBUG_OBJECT (appsrc, "stopping");
  priv->is_eos = FALSE;
  priv->flushing = TRUE;
  priv->started = FALSE;
  gst_app_src_flush_queued (appsrc);
  g_cond_broadcast (&priv->cond);
  g_mutex_unlock (&priv->mutex);

  return TRUE;
}
Exemple #23
0
static gboolean
event_func (GstPad * pad, GstObject * parent, GstEvent * event)
{
  gboolean res = TRUE;

  g_mutex_lock (&event_mutex);
  if (GST_EVENT_TYPE (event) == GST_EVENT_EOS) {
    have_eos = TRUE;
    GST_DEBUG ("signal EOS");
    g_cond_broadcast (&eos_cond);
  }
  g_mutex_unlock (&event_mutex);

  gst_event_unref (event);

  return res;
}
static gboolean
gst_int_ring_buffer_start (GstRingBuffer * buf)
{
  GstAudioRingbuffer *ringbuffer;

  ringbuffer = GST_AUDIO_RINGBUFFER (GST_OBJECT_PARENT (buf));

  GST_OBJECT_LOCK (ringbuffer);
  if (G_UNLIKELY (ringbuffer->waiting)) {
    ringbuffer->waiting = FALSE;
    GST_DEBUG_OBJECT (ringbuffer, "start, sending signal");
    g_cond_broadcast (ringbuffer->cond);
  }
  GST_OBJECT_UNLOCK (ringbuffer);

  return TRUE;
}
static void
gst_v4l2_buffer_pool_flush_start (GstBufferPool * bpool)
{
  GstV4l2BufferPool *pool = GST_V4L2_BUFFER_POOL (bpool);

  GST_DEBUG_OBJECT (pool, "start flushing");

  gst_poll_set_flushing (pool->poll, TRUE);

  GST_OBJECT_LOCK (pool);
  pool->empty = FALSE;
  g_cond_broadcast (&pool->empty_cond);
  GST_OBJECT_UNLOCK (pool);

  if (pool->other_pool)
    gst_buffer_pool_set_flushing (pool->other_pool, TRUE);
}
Exemple #26
0
void
egg_test_wait_stop (void)
{
	GTimeVal tv;

	g_get_current_time (&tv);
	g_time_val_add (&tv, 1000);

	g_assert (wait_mutex);
	g_assert (wait_condition);
	g_mutex_lock (wait_mutex);
		if (!wait_waiting)
			g_cond_timed_wait (wait_start, wait_mutex, &tv);
		g_assert (wait_waiting);
		g_cond_broadcast (wait_condition);
	g_mutex_unlock (wait_mutex);
}
Exemple #27
0
static void gst_shmdata_src_on_data(void *user_data, void *data, size_t size) {
  GstShmdataSrc *self = GST_SHMDATA_SRC (user_data);
  if (self->stop_read)
    return;
  self->current_data = data;
  self->current_size = size;
  self->bytes_since_last_request += size;
  // synchronizing with gst_shmdata_src_create
  g_mutex_lock (&self->on_data_mutex);
  self->on_data = TRUE;
  g_cond_broadcast (&self->on_data_cond);
  g_mutex_unlock (&self->on_data_mutex);
  g_mutex_lock (&self->data_rendered_mutex); 
  while(!self->data_rendered)  // spurious wake
    g_cond_wait (&self->data_rendered_cond, &self->data_rendered_mutex);
  self->data_rendered = FALSE;
  g_mutex_unlock (&self->data_rendered_mutex); 
}
Exemple #28
0
static void
flush_start (APP_STATE_T * state)
{
  GstMiniObject *object = NULL;

  g_mutex_lock (state->queue_lock);
  state->flushing = TRUE;
  g_cond_broadcast (state->cond);
  g_mutex_unlock (state->queue_lock);

  while ((object = g_async_queue_try_pop (state->queue))) {
    gst_mini_object_unref (object);
  }
  g_mutex_lock (state->queue_lock);
  flush_internal (state);
  state->popped_obj = NULL;
  g_mutex_unlock (state->queue_lock);
}
Exemple #29
0
void
ev_job_scheduler_update_job (EvJob         *job,
			     EvJobPriority  priority)
{
	GSList         *l;
	EvSchedulerJob *s_job = NULL;
	gboolean        need_resort = FALSE;

	/* Main loop jobs are scheduled inmediately */
	if (ev_job_get_run_mode (job) == EV_JOB_RUN_MAIN_LOOP)
		return;

	ev_debug_message (DEBUG_JOBS, "%s pirority %d", EV_GET_TYPE_NAME (job), priority);
	
	G_LOCK (job_list);

	for (l = job_list; l; l = l->next) {
		s_job = (EvSchedulerJob *)l->data;

		if (s_job->job == job) {
			need_resort = (s_job->priority != priority);
			break;
		}
	}
	
	G_UNLOCK (job_list);

	if (need_resort) {
		GList *list;
	
		g_mutex_lock (&job_queue_mutex);
		
		list = g_queue_find (job_queue[s_job->priority], s_job);
		if (list) {
			ev_debug_message (DEBUG_JOBS, "Moving job %s from pirority %d to %d",
					  EV_GET_TYPE_NAME (job), s_job->priority, priority);
			g_queue_delete_link (job_queue[s_job->priority], list);
			g_queue_push_tail (job_queue[priority], s_job);
			g_cond_broadcast (&job_queue_cond);
		}
		
		g_mutex_unlock (&job_queue_mutex);
	}
}
static gboolean
gst_hls_demux_fetcher_sink_event (GstPad * pad, GstEvent * event)
{
  GstHLSDemux *demux = GST_HLS_DEMUX (gst_pad_get_element_private (pad));

  switch (event->type) {
    case GST_EVENT_EOS:{
      GST_DEBUG_OBJECT (demux, "Got EOS on the fetcher pad");
      /* signal we have fetched the URI */
      if (!demux->cancelled)
        g_cond_broadcast (demux->fetcher_cond);
    }
    default:
      break;
  }

  gst_event_unref (event);
  return FALSE;
}