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; }
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); }
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); } }
void mate_volume_applet_preferences_change (MateVolumeAppletPreferences *prefs, GstMixer *mixer, GList *tracks) { GtkTreeIter iter; GtkTreeSelection *sel; GtkListStore *store; GtkTreeModel *model; const GList *item; gchar *label; gboolean change = (mixer != prefs->mixer), res; GList *tree_iter; /* because the old list of tracks is cleaned out when the application removes * all the tracks, we need to keep a backup of the list before clearing it */ GList *old_selected_tracks = g_list_copy (tracks); prefs->track_lock = TRUE; if (change) { /* remove old */ model = gtk_tree_view_get_model (GTK_TREE_VIEW (prefs->treeview)); store = GTK_LIST_STORE (model); 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 (mixer)); /* select active element */ model = gtk_combo_box_get_model (GTK_COMBO_BOX (prefs->optionmenu)); for (res = gtk_tree_model_get_iter_first (model, &iter); res; res = gtk_tree_model_iter_next (model, &iter)) { gtk_tree_model_get (model, &iter, COL_LABEL, &label, -1); if (!strcmp (label, g_object_get_data (G_OBJECT (mixer), "mate-volume-applet-name"))) { gtk_combo_box_set_active_iter (GTK_COMBO_BOX (prefs->optionmenu), &iter); } g_free (label); } /* now over to the tracks */ model = gtk_tree_view_get_model (GTK_TREE_VIEW (prefs->treeview)); store = GTK_LIST_STORE (model); sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (prefs->treeview)); /* add all tracks */ for (item = gst_mixer_list_tracks (mixer); item; item = item->next) { GstMixerTrack *track = item->data; if (track->num_channels <= 0) continue; gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, COL_LABEL, track->label, COL_TRACK, track, -1); /* select active tracks */ for (tree_iter = g_list_first (old_selected_tracks); tree_iter; tree_iter = tree_iter->next) { GstMixerTrack *test_against = tree_iter->data; if (!strcmp (test_against->label, track->label)) gtk_tree_selection_select_iter (sel, &iter); } } } else { model = gtk_tree_view_get_model (GTK_TREE_VIEW (prefs->treeview)); sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (prefs->treeview)); gtk_tree_selection_unselect_all (sel); for (res = gtk_tree_model_get_iter_first (model, &iter); res == TRUE; res = gtk_tree_model_iter_next (model, &iter)) { gtk_tree_model_get (model, &iter, COL_LABEL, &label, -1); /* select active tracks */ for (tree_iter = g_list_first (old_selected_tracks); tree_iter; tree_iter = tree_iter->next) { GstMixerTrack *track = tree_iter->data; if (!strcmp (track->label, label)) gtk_tree_selection_select_iter (sel, &iter); } g_free (label); } } prefs->track_lock = FALSE; g_list_free (old_selected_tracks); }