Ejemplo n.º 1
0
static void
gst_hls_demux_dispose (GObject * obj)
{
  GstHLSDemux *demux = GST_HLS_DEMUX (obj);

  g_cond_free (demux->fetcher_cond);
  g_mutex_free (demux->fetcher_lock);

  g_cond_free (demux->thread_cond);
  g_mutex_free (demux->thread_lock);

  if (GST_TASK_STATE (demux->task) != GST_TASK_STOPPED) {
    gst_task_stop (demux->task);
    gst_task_join (demux->task);
  }
  gst_object_unref (demux->task);
  g_static_rec_mutex_free (&demux->task_lock);

  gst_object_unref (demux->fetcher_bus);
  gst_object_unref (demux->fetcherpad);

  gst_hls_demux_reset (demux, TRUE);

  gst_object_unref (demux->download);

  G_OBJECT_CLASS (parent_class)->dispose (obj);
}
Ejemplo n.º 2
0
void test_lock_start()
{
  GstTask *t;
  gboolean ret;
    //xmlfile = "test_lock_start";
 std_log(LOG_FILENAME_LINE, "Test Started test_lock_start");

  t = gst_task_create (task_func, NULL);
   fail_if (t == NULL);
  TEST_ASSERT_FAIL
   gst_task_set_lock (t, &task_mutex);
  task_cond = g_cond_new ();
  task_lock = g_mutex_new ();
  g_mutex_lock (task_lock);
   GST_DEBUG ("starting");
  ret = gst_task_start (t);
  fail_unless (ret == TRUE);
  TEST_ASSERT_FAIL
  /* wait for it to spin up */
  GST_DEBUG ("waiting");
  g_cond_wait (task_cond, task_lock);
  GST_DEBUG ("done waiting");
  g_mutex_unlock (task_lock);
  /* cannot set mutex now */
  ASSERT_WARNING (gst_task_set_lock (t, &task_mutex));//b failing
  GST_DEBUG ("joining");
  ret = gst_task_join (t);
    fail_unless (ret == TRUE);
  TEST_ASSERT_FAIL
  gst_object_unref (t);
  std_log(LOG_FILENAME_LINE, "Test Successful");
    create_xml(0);
}
Ejemplo n.º 3
0
void test_lock()
{
  GstTask *t;
  gboolean ret;
    //xmlfile = "test_lock";
 std_log(LOG_FILENAME_LINE, "Test Started test_lock");

  t = gst_task_create (task_func, NULL);
  fail_if (t == NULL);
  TEST_ASSERT_FAIL

  gst_task_set_lock (t, &task_mutex);

  GST_DEBUG ("pause");
  ret = gst_task_pause (t);
  fail_unless (ret == TRUE);
  TEST_ASSERT_FAIL

  g_usleep (1 * G_USEC_PER_SEC / 2);

  GST_DEBUG ("joining");
  ret = gst_task_join (t);
  fail_unless (ret == TRUE);
  TEST_ASSERT_FAIL

  g_usleep (1 * G_USEC_PER_SEC / 2);

  gst_object_unref (t);
  std_log(LOG_FILENAME_LINE, "Test Successful");
    create_xml(0);
}
Ejemplo n.º 4
0
static gboolean
gst_decklink_src_stop (GstElement * element)
{
  GstDecklinkSrc *decklinksrc = GST_DECKLINK_SRC (element);

  gst_task_stop (decklinksrc->task);

  g_mutex_lock (&decklinksrc->mutex);
  decklinksrc->stop = TRUE;
  g_cond_signal (&decklinksrc->cond);
  g_mutex_unlock (&decklinksrc->mutex);

  gst_task_join (decklinksrc->task);

  decklinksrc->input->StopStreams ();
  decklinksrc->input->DisableVideoInput ();
  decklinksrc->input->DisableAudioInput ();

  g_list_free_full (decklinksrc->pending_events,
      (GDestroyNotify) gst_mini_object_unref);
  decklinksrc->pending_events = NULL;
  decklinksrc->have_events = FALSE;
  decklinksrc->pending_eos = FALSE;

  return TRUE;
}
Ejemplo n.º 5
0
static gboolean
gst_decklink_src_stop (GstElement * element)
{
  GstDecklinkSrc *decklinksrc = GST_DECKLINK_SRC (element);

  gst_task_stop (decklinksrc->task);

  g_mutex_lock (decklinksrc->mutex);
  decklinksrc->stop = TRUE;
  g_cond_signal (decklinksrc->cond);
  g_mutex_unlock (decklinksrc->mutex);

  gst_task_join (decklinksrc->task);

  decklinksrc->input->StopStreams ();
  decklinksrc->input->DisableVideoInput ();
  decklinksrc->input->DisableAudioInput ();

  decklinksrc->input->Release ();
  decklinksrc->input = NULL;

  decklinksrc->decklink->Release ();
  decklinksrc->decklink = NULL;

  return TRUE;
}
Ejemplo n.º 6
0
void
sefctrler_finalize (GObject * object)
{
  SndEventBasedController *this = SEFCTRLER (object);
  g_hash_table_destroy (this->subflows);
  gst_task_stop (this->thread);
  gst_task_join (this->thread);

  g_object_unref (this->sysclock);
}
Ejemplo n.º 7
0
static void
gst_hls_demux_dispose (GObject * obj)
{
  GstHLSDemux *demux = GST_HLS_DEMUX (obj);

  if (demux->stream_task) {
    if (GST_TASK_STATE (demux->stream_task) != GST_TASK_STOPPED) {
      GST_DEBUG_OBJECT (demux, "Leaving streaming task");
      gst_task_stop (demux->stream_task);
      gst_task_join (demux->stream_task);
    }
    gst_object_unref (demux->stream_task);
    g_rec_mutex_clear (&demux->stream_lock);
    demux->stream_task = NULL;
  }

  if (demux->updates_task) {
    if (GST_TASK_STATE (demux->updates_task) != GST_TASK_STOPPED) {
      GST_DEBUG_OBJECT (demux, "Leaving updates task");
      gst_task_stop (demux->updates_task);
      gst_task_join (demux->updates_task);
    }
    gst_object_unref (demux->updates_task);
    g_mutex_clear (&demux->updates_timed_lock);
    g_rec_mutex_clear (&demux->updates_lock);
    demux->updates_task = NULL;
  }

  if (demux->downloader != NULL) {
    g_object_unref (demux->downloader);
    demux->downloader = NULL;
  }

  gst_hls_demux_reset (demux, TRUE);

  g_queue_free (demux->queue);

  G_OBJECT_CLASS (parent_class)->dispose (obj);
}
Ejemplo n.º 8
0
static void
task_func2 (void *data)
{
  gboolean ret;
  GstTask *t = *((GstTask **) data);

  g_mutex_lock (&task_lock);
  GST_DEBUG ("signal");
  g_cond_signal (&task_cond);
  g_mutex_unlock (&task_lock);

  ASSERT_WARNING (ret = gst_task_join (t));
  fail_unless (ret == FALSE);
}
Ejemplo n.º 9
0
static void
	stop_eos_task (GstAmlVdec *amlvdec)
{
    if (! amlvdec->eos_task)
        return;

    gst_task_stop (amlvdec->eos_task);

    g_rec_mutex_lock (&amlvdec->eos_lock);

    g_rec_mutex_unlock (&amlvdec->eos_lock);
    gst_task_join (amlvdec->eos_task);
    gst_object_unref (amlvdec->eos_task);
    amlvdec->eos_task = NULL;
}
Ejemplo n.º 10
0
static void
gst_swfdec_dispose (GObject * object)
{
  GstSwfdec *swfdec = GST_SWFDEC (object);

  gst_task_stop (swfdec->task);
  gst_task_join (swfdec->task);
  gst_object_unref (swfdec->task);
  g_static_rec_mutex_free (&swfdec->mutex);

  g_object_unref (swfdec->adapter);

  swfdec_decoder_free (swfdec->decoder);

  G_OBJECT_CLASS (parent_class)->dispose (object);
}
Ejemplo n.º 11
0
/*
 * Decrement the reference count on the curl multi loop. If this is called by
 * the last instance to hold a reference, shut down the worker. (Otherwise
 * GStreamer can't close down with a thread still running). Also offers the
 * "force_all" boolean parameter, which if TRUE removes all references and shuts
 * down.
 */
void
gst_curl_multi_context_unref (GstCurlMultiContext * thiz)
{
  g_mutex_lock(&thiz->mutex);
  thiz->refcount--;
  GST_INFO ("Worker thread refcount is now %u", thiz->refcount);

  if (thiz->refcount <= 0) {
    /* Everything's done! Clean up. */
    gst_task_pause (thiz->task);
    g_cond_signal (&thiz->signal);
    g_mutex_unlock (&thiz->mutex);
    gst_task_join (thiz->task);
  } else {
    g_mutex_unlock(&thiz->mutex);
  }
}
Ejemplo n.º 12
0
static GstStateChangeReturn
gst_qt_moov_recover_change_state (GstElement * element,
    GstStateChange transition)
{
  GstStateChangeReturn ret;
  GstQTMoovRecover *qtmr = GST_QT_MOOV_RECOVER_CAST (element);

  switch (transition) {
    case GST_STATE_CHANGE_NULL_TO_READY:
      qtmr->task = gst_task_create (gst_qt_moov_recover_run, qtmr);
      qtmr->task_mutex = g_new (GStaticRecMutex, 1);
      g_static_rec_mutex_init (qtmr->task_mutex);
      gst_task_set_lock (qtmr->task, qtmr->task_mutex);
      break;
    case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
      gst_task_start (qtmr->task);
      break;
    default:
      break;
  }

  ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);

  switch (transition) {
    case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
      gst_task_stop (qtmr->task);
      gst_task_join (qtmr->task);
      break;
    case GST_STATE_CHANGE_READY_TO_NULL:
      g_assert (gst_task_get_state (qtmr->task) == GST_TASK_STOPPED);
      gst_object_unref (qtmr->task);
      qtmr->task = NULL;
      g_static_rec_mutex_free (qtmr->task_mutex);
      break;
    default:
      break;
  }
  return ret;
}
Ejemplo n.º 13
0
static GstStateChangeReturn
gst_hls_demux_change_state (GstElement * element, GstStateChange transition)
{
  GstStateChangeReturn ret;
  GstHLSDemux *demux = GST_HLS_DEMUX (element);

  switch (transition) {
    case GST_STATE_CHANGE_READY_TO_PAUSED:
      gst_hls_demux_reset (demux, FALSE);
      break;
    case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
      /* Start the streaming loop in paused only if we already received
         the main playlist. It might have been stopped if we were in PAUSED
         state and we filled our queue with enough cached fragments
       */
      if (gst_m3u8_client_get_uri (demux->client)[0] != '\0')
        gst_hls_demux_start_update (demux);
      break;
    default:
      break;
  }

  ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);

  switch (transition) {
    case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
      gst_hls_demux_stop_update (demux);
      break;
    case GST_STATE_CHANGE_PAUSED_TO_READY:
      demux->cancelled = TRUE;
      gst_hls_demux_stop (demux);
      gst_task_join (demux->task);
      gst_hls_demux_reset (demux, FALSE);
      break;
    default:
      break;
  }
  return ret;
}
Ejemplo n.º 14
0
void
gst_alsa_mixer_free (GstAlsaMixer * mixer)
{
  g_return_if_fail (mixer != NULL);

  if (mixer->task) {
    if (write (mixer->pfd[1], "stop", 5) <= 0) {
      GST_ERROR ("Cannot send " "stop" " to alsamixer task");
      close (mixer->pfd[1]);
      mixer->pfd[1] = -1;
    }

    if (gst_task_join (mixer->task) == FALSE) {
      GST_ERROR ("Cannot join alsamixer task");
    }

    gst_object_unref (mixer->task);
    mixer->task = NULL;
  }

  g_static_rec_mutex_free (mixer->task_mutex);
  g_free (mixer->task_mutex);
  mixer->task_mutex = NULL;

  if (mixer->pfd[0] > 0) {
    close (mixer->pfd[0]);
    mixer->pfd[0] = -1;
  }

  if (mixer->pfd[1] > 0) {
    close (mixer->pfd[1]);
    mixer->pfd[1] = -1;
  }

  if (mixer->interface) {
    g_object_unref (G_OBJECT (mixer->interface));
    mixer->interface = NULL;
  }

  if (mixer->device) {
    g_free (mixer->device);
    mixer->device = NULL;
  }

  if (mixer->cardname) {
    g_free (mixer->cardname);
    mixer->cardname = NULL;
  }

  if (mixer->tracklist) {
    g_list_foreach (mixer->tracklist, (GFunc) g_object_unref, NULL);
    g_list_free (mixer->tracklist);
    mixer->tracklist = NULL;
  }

  if (mixer->handle) {
    snd_mixer_close (mixer->handle);
    mixer->handle = NULL;
  }

  g_static_rec_mutex_free (mixer->rec_mutex);
  g_free (mixer->rec_mutex);
  mixer->rec_mutex = NULL;

  g_free (mixer);
}
Ejemplo n.º 15
0
static GstStateChangeReturn
gst_merger_change_state (GstElement * element, GstStateChange transition)
{
  GstMerger *merger = GST_MERGER (element);
  GstStateChangeReturn ret;

  GST_INFO_OBJECT (merger, "Transition %d", transition);

  switch (transition) {

    case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
    {
      bool res;

      GST_INFO_OBJECT (merger, "Stoping Task");
      merger->stop = 1;
      g_cond_signal (&merger->task_cond);
      GST_INFO_OBJECT (merger, "Stoping Task.");
      res = gst_task_stop (merger->task);
      GST_INFO_OBJECT (merger, "Stoping Task.. %d", res);

      GST_INFO_OBJECT (merger, "Task state %d", merger->task->state);
      res = gst_task_join (merger->task);
      GST_INFO_OBJECT (merger, "Stoping Task... %d", res);
    }
      break;

    case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
    {
      bool res;
      GST_INFO_OBJECT (merger, "Starting Task");
      merger->stop = 0;
      res = gst_task_start (merger->task);
      GST_INFO_OBJECT (merger, "Starting Task. %d", res);
    }
      break;

    case GST_STATE_CHANGE_READY_TO_PAUSED:
      gst_segment_init (&merger->s_segment, GST_FORMAT_UNDEFINED);
      g_queue_init (&merger->bufs_l);
      g_queue_init (&merger->bufs_r);
      break;
    default:
      break;
  }

  ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);

  switch (transition) {
    case GST_STATE_CHANGE_PAUSED_TO_READY:{
      GstBuffer *buf;
      while ((buf = g_queue_pop_head (&merger->bufs_l)))
        gst_buffer_unref (buf);
      while ((buf = g_queue_pop_head (&merger->bufs_r)))
        gst_buffer_unref (buf);
      break;
    }
    default:
      break;
  }
  return ret;
}
Ejemplo n.º 16
0
static GstStateChangeReturn
gst_swfdec_change_state (GstElement * element, GstStateChange transition)
{
  GstSwfdec *swfdec = GST_SWFDEC (element);
  GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;

  switch (transition) {
    case GST_STATE_CHANGE_NULL_TO_READY:
      break;
    case GST_STATE_CHANGE_READY_TO_PAUSED:
    {
      gst_adapter_clear (swfdec->adapter);
      /*
         gst_swfdec_vo_open (swfdec);
         swfdec_decoder_new (swfdec->decoder, swfdec->accel, swfdec->vo);

         swfdec->decoder->is_sequence_needed = 1;
         swfdec->decoder->frame_rate_code = 0;
       */
      swfdec->timestamp = 0;
      swfdec->closed = FALSE;

      /* reset the initial video state */
      swfdec->have_format = FALSE;
      swfdec->format = -1;
      swfdec->width = -1;
      swfdec->height = -1;
      swfdec->first = TRUE;
      break;
    }
    case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
      gst_task_start (swfdec->task);
      break;
    default:
      break;
  }

  ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);

  switch (transition) {
    case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
      gst_task_pause (swfdec->task);
      gst_task_join (swfdec->task);
      break;
    case GST_STATE_CHANGE_PAUSED_TO_READY:
      /* if we are not closed by an EOS event do so now, this cen send a few frames but
       * we are prepared to not really send them (see above) */
      if (!swfdec->closed) {
        /*swf_close (swfdec->decoder); */
        swfdec->closed = TRUE;
      }
      /* gst_swfdec_vo_destroy (swfdec); */
      break;
    case GST_STATE_CHANGE_READY_TO_NULL:
      gst_task_stop (swfdec->task);
      gst_task_join (swfdec->task);
      break;
    default:
      break;
  }

  return ret;

}