// Copyright (c) 2012 Bryan Schumaker. //#include #include #include #include #include "audio.h" #include using namespace std; //static GstElement *alsa = NULL; static list devices; gulong about_to_finish_id; /* static void about_to_finish(GstElement *playbin, gpointer data) { string file; println("About to finish!"); //file = libsaria::next_file(); if (file != "") load_file(playbin, file); } static void probe_devices() { GValueArray *array; GValue *value; devices.clear(); array = gst_property_probe_probe_and_get_values_name(GST_PROPERTY_PROBE(alsa), "device"); devices.push_back("default"); for (unsigned int i = 0; i < array->n_values; i++) { value = g_value_array_get_nth(array, i); devices.push_back(g_value_get_string(value)); } g_value_array_free(array); } static void set_alsa_device(string device) { g_object_set(G_OBJECT(alsa), "device", device.c_str(), NULL); } static void add_alsa() { println("Adding ALSA"); alsa = gst_element_factory_make("alsasink", "alsa"); probe_devices(); set_audio_sink(alsa); about_to_finish_id = g_signal_connect(player, "about-to-finish", G_CALLBACK(about_to_finish), NULL); } static void remove_alsa() { println("Removing ALSA"); g_signal_handler_disconnect(player, about_to_finish_id); set_alsa_device("default");*/ /* Removing the sink will also deallocate it */ /* set_audio_sink(NULL); }*/ namespace libsaria { /*void audio::use_alsa(bool use) { struct StoredAudioState state; save_audio_state(&state); if (use == true) add_alsa(); else remove_alsa(); load_audio_state(&state); prefs::set("alsa", use); } bool audio::using_alsa() { return false; //return prefs::get_bool("alsa"); } void audio::init_alsa() { if (using_alsa()) add_alsa(); } void audio::quit_alsa() { if (using_alsa()) remove_alsa(); } list *audio::get_alsa_devices() { return &devices; } void audio::set_device(string &device) { struct StoredAudioState state; save_audio_state(&state); g_object_set(G_OBJECT(alsa), "device", device.c_str(), NULL); load_audio_state(&state); }*/ }; /* Namespace: libsaria */