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); }
static void xfce_mixer_option_changed (GtkComboBox *combo, XfceMixerOption *option) { gchar *active_option; if (G_UNLIKELY (option->ignore_signals)) return; active_option = gtk_combo_box_get_active_text (combo); if (G_LIKELY (active_option != NULL)) { gst_mixer_set_option (GST_MIXER (option->card), GST_MIXER_OPTIONS (option->track), active_option); g_free (active_option); } }
static void xfce_mixer_option_create_contents (XfceMixerOption *option) { GstMixerOptions *options; GtkWidget *label; const GList *iter; const gchar *active_option; gchar *track_label; gchar *title; gint i; gtk_box_set_homogeneous (GTK_BOX (option), FALSE); gtk_box_set_spacing (GTK_BOX (option), 12); g_object_get (option->track, "label", &track_label, NULL); title = g_strdup_printf ("%s:", track_label); g_free (track_label); label = gtk_label_new (title); gtk_box_pack_start (GTK_BOX (option), label, FALSE, FALSE, 0); gtk_widget_show (label); options = GST_MIXER_OPTIONS (option->track); active_option = gst_mixer_get_option (GST_MIXER (option->card), options); option->combo = gtk_combo_box_new_text (); for (iter = options->values, i = 0; iter != NULL; iter = g_list_next (iter), ++i) { gtk_combo_box_append_text (GTK_COMBO_BOX (option->combo), iter->data); if (G_UNLIKELY (g_utf8_collate (active_option, iter->data) == 0)) gtk_combo_box_set_active (GTK_COMBO_BOX (option->combo), i); } gtk_box_pack_start (GTK_BOX (option), option->combo, FALSE, FALSE, 0); gtk_widget_show (option->combo); g_signal_connect (option->combo, "changed", G_CALLBACK (xfce_mixer_option_changed), option); g_free (title); }
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 xfce_mixer_option_update (XfceMixerOption *option) { GstMixerOptions *options; GtkTreeModel *model; GtkTreeIter iter; const gchar *active_option; gchar *str; g_return_if_fail (IS_XFCE_MIXER_OPTION (option)); options = GST_MIXER_OPTIONS (option->track); active_option = gst_mixer_get_option (GST_MIXER (option->card), options); model = gtk_combo_box_get_model (GTK_COMBO_BOX (option->combo)); if (gtk_tree_model_get_iter_first (model, &iter)) { do { gtk_tree_model_get (model, &iter, 0, &str, -1); if (G_UNLIKELY (g_utf8_collate (str, active_option) == 0)) { option->ignore_signals = TRUE; gtk_combo_box_set_active_iter (GTK_COMBO_BOX (option->combo), &iter); option->ignore_signals = FALSE; g_free (str); break; } g_free (str); } while (gtk_tree_model_iter_next (model, &iter)); } }
static void gst_audio_mixer_filter_do_filter (GstAudioMixerFilterFunc filter_func, GstElementFactory * factory, GstElement ** p_element, GList ** p_collection, gpointer user_data) { /* so, the element is a mixer, let's see if the caller wants it */ if (filter_func != NULL) { if (filter_func (GST_MIXER (*p_element), user_data) == TRUE) { *p_collection = g_list_prepend (*p_collection, *p_element); /* do not set state back to NULL here on purpose, caller * might want to keep the mixer open */ *p_element = NULL; } } else { gst_element_set_state (*p_element, GST_STATE_NULL); *p_collection = g_list_prepend (*p_collection, *p_element); *p_element = NULL; } /* create new element for further probing if the old one was cleared */ if (*p_element == NULL) { *p_element = gst_element_factory_create (factory, NULL); } }
static void update_mixer_device_combobox (const gchar *mixer_device, GladeXML *dialog) { GtkWidget *device_widget; GtkTreeModel *model; GtkTreeIter iter; device_widget = WID ("mixer_device"); model = gtk_combo_box_get_model (GTK_COMBO_BOX (device_widget)); /* try to find stored factory and device in the mixer device list */ if (mixer_device != NULL && *mixer_device != '\0') { if (gtk_tree_model_get_iter_first (model, &iter)) { do { gchar *device = NULL; gtk_tree_model_get (model, &iter, MIXER_DEVICE_MODEL_DEVICE_COLUMN, &device, -1); if (!strcmp (device, mixer_device)) { gtk_combo_box_set_active_iter (GTK_COMBO_BOX (device_widget), &iter); g_free (device); break; } g_free (device); } while (gtk_tree_model_iter_next (model, &iter)); } } /* try to select first mixer entry */ /* FIXME use the first with a master track */ if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (device_widget), &iter)) { if (gtk_tree_model_get_iter_first (model, &iter)) { gtk_combo_box_set_active_iter (GTK_COMBO_BOX (device_widget), &iter); } } /* fill track list */ if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (device_widget), &iter)) { GtkWidget *tracks_widget; GstElement *mixer; GtkTreeSelection *selection; GtkTreeModel *tracks_model; GSList *tracks; tracks_widget = WID ("mixer_tracks"); gtk_tree_model_get (model, &iter, MIXER_DEVICE_MODEL_MIXER_COLUMN, &mixer, -1); gst_element_set_state (mixer, GST_STATE_READY); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tracks_widget)); g_signal_handlers_block_by_func (G_OBJECT (selection), G_CALLBACK (mixer_tracks_selection_changed), NULL); tracks_model = create_mixer_tracks_tree_model_for_mixer (GST_MIXER (mixer)); gtk_tree_view_set_model (GTK_TREE_VIEW (tracks_widget), tracks_model); g_object_unref (tracks_model); gst_element_set_state (mixer, GST_STATE_NULL); gst_object_unref (GST_OBJECT (mixer)); /* updated mixer tracks selection */ tracks = gconf_client_get_list (gconf_client, DEFAULT_MIXER_TRACKS_KEY, GCONF_VALUE_STRING, NULL); update_mixer_tracks_selection (tracks, dialog); g_slist_foreach (tracks, (GFunc) g_free, NULL); g_slist_free (tracks); g_signal_handlers_unblock_by_func (G_OBJECT (selection), G_CALLBACK (mixer_tracks_selection_changed), NULL); } }