예제 #1
0
static void
gst_pulsesrc_finalize (GObject * object)
{
  GstPulseSrc *pulsesrc = GST_PULSESRC_CAST (object);

  g_free (pulsesrc->server);
  g_free (pulsesrc->device);

  if (pulsesrc->properties)
    gst_structure_free (pulsesrc->properties);
  if (pulsesrc->proplist)
    pa_proplist_free (pulsesrc->proplist);

  if (pulsesrc->mixer) {
    gst_pulsemixer_ctrl_free (pulsesrc->mixer);
    pulsesrc->mixer = NULL;
  }

  if (pulsesrc->probe) {
    gst_pulseprobe_free (pulsesrc->probe);
    pulsesrc->probe = NULL;
  }

  G_OBJECT_CLASS (parent_class)->finalize (object);
}
예제 #2
0
GstPulseMixerCtrl *
gst_pulsemixer_ctrl_new (GObject * object, const gchar * server,
    const gchar * device, GstPulseMixerType type)
{
  GstPulseMixerCtrl *c = NULL;

  c = g_new (GstPulseMixerCtrl, 1);
  c->object = g_object_ref (object);
  c->tracklist = NULL;
  c->server = g_strdup (server);
  c->device = g_strdup (device);
  c->mainloop = NULL;
  c->context = NULL;
  c->track = NULL;
  c->ignore_queries = c->outstandig_queries = 0;

  pa_cvolume_mute (&c->volume, PA_CHANNELS_MAX);
  pa_channel_map_init (&c->channel_map);
  c->muted = 0;
  c->index = PA_INVALID_INDEX;
  c->type = type;
  c->name = NULL;
  c->description = NULL;

  c->time_event = NULL;
  c->update_volume = c->update_mute = FALSE;

  if (!(gst_pulsemixer_ctrl_open (c))) {
    gst_pulsemixer_ctrl_free (c);
    return NULL;
  }

  return c;
}
예제 #3
0
static GstStateChangeReturn
gst_pulsesrc_change_state (GstElement * element, GstStateChange transition)
{
  GstStateChangeReturn ret;
  GstPulseSrc *this = GST_PULSESRC_CAST (element);
  int e;

  switch (transition) {
    case GST_STATE_CHANGE_NULL_TO_READY:
      this->mainloop = pa_threaded_mainloop_new ();
      g_assert (this->mainloop);

      e = pa_threaded_mainloop_start (this->mainloop);
      g_assert (e == 0);

      if (!this->mixer)
        this->mixer =
            gst_pulsemixer_ctrl_new (G_OBJECT (this), this->server,
            this->device, GST_PULSEMIXER_SOURCE);
      break;
    case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
      /* uncork and start recording */
      gst_pulsesrc_play (this);
      break;
    case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
      /* stop recording ASAP by corking */
      pa_threaded_mainloop_lock (this->mainloop);
      GST_DEBUG_OBJECT (this, "corking");
      gst_pulsesrc_set_corked (this, TRUE, FALSE);
      pa_threaded_mainloop_unlock (this->mainloop);
      break;
    default:
      break;
  }

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

  switch (transition) {
    case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
      /* now make sure we get out of the _read method */
      gst_pulsesrc_pause (this);
      break;
    case GST_STATE_CHANGE_READY_TO_NULL:
      if (this->mixer) {
        gst_pulsemixer_ctrl_free (this->mixer);
        this->mixer = NULL;
      }

      if (this->mainloop)
        pa_threaded_mainloop_stop (this->mainloop);

      gst_pulsesrc_destroy_context (this);

      if (this->mainloop) {
        pa_threaded_mainloop_free (this->mainloop);
        this->mainloop = NULL;
      }
      break;
    default:
      break;
  }

  return ret;
}