コード例 #1
0
ファイル: mixerutils.c プロジェクト: matsu/gst-plugins-base
static gboolean
gst_audio_mixer_filter_check_element (GstElement * element)
{
  GstStateChangeReturn ret;

  /* open device (only then we can know for sure whether it is a mixer) */
  gst_element_set_state (element, GST_STATE_READY);
  ret = gst_element_get_state (element, NULL, NULL, 1 * GST_SECOND);
  if (ret != GST_STATE_CHANGE_SUCCESS) {
    GST_DEBUG ("could not open device / set element to READY");
    gst_element_set_state (element, GST_STATE_NULL);
    return FALSE;
  }

  /* is this device a mixer? */
  if (!GST_IS_MIXER (element)) {
    GST_DEBUG ("element is not a mixer");
    gst_element_set_state (element, GST_STATE_NULL);
    return FALSE;
  }

  /* any tracks? */
  if (!gst_mixer_list_tracks (GST_MIXER (element))) {
    GST_DEBUG ("element is a mixer, but has no tracks");
    gst_element_set_state (element, GST_STATE_NULL);
    return FALSE;
  }

  GST_DEBUG ("element is a mixer with mixer tracks");
  return TRUE;
}
コード例 #2
0
static void
_xfce_mixer_card_combo_set_active_card (XfceMixerCardCombo *combo,
                                        GstElement         *card)
{
  GstElement *current_card = NULL;
  GtkTreeIter iter;
  gboolean    valid_iter;

  g_return_if_fail (IS_XFCE_MIXER_CARD_COMBO (combo));

  if (G_LIKELY (GST_IS_MIXER (card)))
    {
      valid_iter = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (combo->list_store), &iter);

      while (valid_iter)
        {
          gtk_tree_model_get (GTK_TREE_MODEL (combo->list_store), &iter, CARD_COLUMN, &current_card, -1);

          if (G_UNLIKELY (current_card == card))
            break;

          valid_iter = gtk_tree_model_iter_next (GTK_TREE_MODEL (combo->list_store), &iter);
        }
    }

  if (G_LIKELY (card != NULL && current_card == card))
    gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo), &iter);
  else
    gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);
}
コード例 #3
0
void
xfce_mixer_track_combo_set_soundcard (XfceMixerTrackCombo *combo,
                                      GstElement          *card)
{
  XfceMixerTrackType type;
  GtkTreeIter        tree_iter;
  const GList       *iter;
  GList             *cards;
  gchar             *label;
  gint               counter;
  gint               active_index = 0;

  g_return_if_fail (IS_XFCE_MIXER_TRACK_COMBO (combo));

  /* Remember card. If the card is invalid, use the first one available */
  if (GST_IS_MIXER (card))
    combo->card = card;
  else
    {
      cards = xfce_mixer_get_cards ();

      if (G_LIKELY (g_list_length (cards) > 0))
        combo->card = g_list_first (cards)->data;
    }

  /* Clear the list store data */
  gtk_list_store_clear (combo->list_store);

  for (iter = gst_mixer_list_tracks (GST_MIXER (combo->card)), counter = 0; iter != NULL; iter = g_list_next (iter))
    {
      type = xfce_mixer_track_type_new (iter->data);

      if (type == XFCE_MIXER_TRACK_TYPE_PLAYBACK || type == XFCE_MIXER_TRACK_TYPE_CAPTURE)
        {
          g_object_get (GST_MIXER_TRACK (iter->data), "label", &label, NULL);

          gtk_list_store_append (combo->list_store, &tree_iter);
          gtk_list_store_set (combo->list_store, &tree_iter, 
                              NAME_COLUMN, label, 
                              TRACK_COLUMN, GST_MIXER_TRACK (iter->data), -1);

          g_free (label);

          if (G_UNLIKELY (combo->track != NULL && combo->track == GST_MIXER_TRACK (iter->data)))
            active_index = counter;

          ++counter;
        }
    }

  gtk_combo_box_set_active (GTK_COMBO_BOX (combo), active_index);
}
コード例 #4
0
GtkWidget*
xfce_mixer_option_new (GstElement    *card,
                       GstMixerTrack *track)
{
  XfceMixerOption *option;

  g_return_val_if_fail (GST_IS_MIXER (card), NULL);
  g_return_val_if_fail (GST_IS_MIXER_TRACK (track), NULL);
  
  option = g_object_new (TYPE_XFCE_MIXER_OPTION, NULL);
  option->card = card;
  option->track = track;

  xfce_mixer_option_create_contents (option);

  return GTK_WIDGET (option);
}
コード例 #5
0
GtkWidget *
mate_volume_control_preferences_new (GstElement  *element)
{
  MateVolumeControlPreferences *prefs;

  g_return_val_if_fail (GST_IS_MIXER (element), NULL);

  /* element */
  prefs = g_object_new (MATE_VOLUME_CONTROL_TYPE_PREFERENCES, NULL);
  prefs->settings = g_settings_new (MATE_VOLUME_CONTROL_SCHEMA);

  mate_volume_control_preferences_change (prefs, element);

  /* gsettings */
  g_signal_connect (prefs->settings, "changed::" MATE_VOLUME_CONTROL_KEY_SHOWN_ELEMENTS,
                    G_CALLBACK (cb_gsettings), prefs);

  return GTK_WIDGET (prefs);
}
コード例 #6
0
void
mate_volume_control_preferences_change (MateVolumeControlPreferences *prefs,
					 GstElement *element)
{
  GstMixer *mixer;
  GtkTreeIter iter;
  GtkListStore *store;
  const GList *item;
  gint pgnum;

  g_return_if_fail (GST_IS_MIXER (element));
  mixer = GST_MIXER (element);

  store = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (prefs->treeview)));

  /* remove old */
  while (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter)) {
    gtk_list_store_remove (store, &iter);
  }

  /* take/put reference */
  gst_object_replace ((GstObject **) &prefs->mixer, GST_OBJECT (element));

  /* add all tracks */
  mate_volume_control_element_whitelist (mixer, NULL);
  for (item = gst_mixer_list_tracks (mixer);
       item != NULL; item = item->next) {
    GstMixerTrack *track = item->data;
    gboolean active = mate_volume_control_element_is_to_show (prefs->settings, mixer, track);

    pgnum = get_page_num (mixer, track);
    gtk_list_store_append (store, &iter);
    gtk_list_store_set (store, &iter,
			COL_ACTIVE, active,
			COL_LABEL, track->label,
			COL_TRACK, track,
			COL_TYPE, get_page_description (pgnum),
			COL_PAGE, pgnum,
			-1);
  }
}