libsaria: Strip out old gstreamer code

Most of this was commented out and hasn't been used in almost a year.
The new gstreamer code doesn't have the property probe feature anymore,
so I can't reimplement my old alsa code.  I'll drop it for now and
figure it out later (after cleaning up this other code).

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
Bryan Schumaker 2012-11-11 14:15:05 -05:00
parent 83f8b1e543
commit 7557acc239
5 changed files with 1 additions and 245 deletions

View File

@ -15,37 +15,22 @@ namespace libsaria
{
void init(int, char**);
void quit();
/*void swap();
string get_current_file();*/
/* Alsa controls */
/*void use_alsa(bool);
bool using_alsa();
list<string> *get_alsa_devices();
void set_device(string &);*/
/* Playback control functions */
/*void load_file(string);*/
void load(string, bool);
void play();
void pause();
void toggle_play();
GstState get_state();
void stop();
/*bool is_playing();*/
/* Position related functions */
/*bool seek(int);*/
void seek_to(double);
gint64 duration();
gint64 position();
string posstr();
string durstr();
bool played();
/* Volume functions */
/*float get_volume();
void set_volume(float);*/
};
};

View File

@ -1,117 +0,0 @@
// Copyright (c) 2012 Bryan Schumaker.
//#include <gst/interfaces/propertyprobe.h>
#include <audio.h>
#include <prefs.h>
#include <print.h>
#include "audio.h"
#include <list>
using namespace std;
//static GstElement *alsa = NULL;
static list<string> 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<string> *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 */

View File

@ -1,13 +1,10 @@
// Copyright (c) 2011 Bryan Schumaker.
#include <audio.h>
#include <print.h>
#include <library.h>
#include <deck.h>
#include <audio.h>
#include "audio.h"
GstElement *player = NULL;
GstBus *bus = NULL;
//static bool restoring_state = false;
static void parse_error(GstMessage *error)
{
@ -20,17 +17,6 @@ static void parse_error(GstMessage *error)
g_free(debug);
}
/*static void notify_audio_changed()
{
println("Notify audio changed");
if (libsaria::get_pause_after()) {
libsaria::audio::pause();
libsaria::set_pause_after(false);
}
if (restoring_state == false)
trigger_callback(TRACK_LOADED);
}*/
static gboolean on_message(GstBus *bus, GstMessage *message, gpointer data)
{
switch (GST_MESSAGE_TYPE(message)) {
@ -44,45 +30,6 @@ static gboolean on_message(GstBus *bus, GstMessage *message, gpointer data)
return TRUE;
}
static void audio_changed(GstElement *playbin, gpointer data)
{
//notify_audio_changed();
}
/*
* Set sink to NULL to use the default sink
*/
/*void set_audio_sink(GstElement *sink)
{
g_object_set(G_OBJECT(player), "audio-sink", sink, NULL);
}
void save_audio_state(struct StoredAudioState *state)
{
state->cur_file = libsaria::audio::get_current_file();
state->position = libsaria::audio::position();
state->was_playing = libsaria::audio::is_playing();
}
void load_audio_state(struct StoredAudioState *state)
{
restoring_state = true;
libsaria::audio::load(state->cur_file);
if (state->was_playing == true)
libsaria::audio::play();
else
libsaria::audio::pause();*/
/*
* Wait for async play() or pause() to finish, otherwise
* the seek won't succeed
*/
/* gst_element_get_state(GST_ELEMENT(player), NULL, NULL, GST_CLOCK_TIME_NONE);
libsaria::audio::seek_to(state->position);
restoring_state = false;
}*/
namespace libsaria
{
@ -95,15 +42,10 @@ namespace libsaria
bus = gst_pipeline_get_bus(GST_PIPELINE(player));
gst_bus_add_watch(bus, on_message, NULL);
g_signal_connect(player, "audio-changed", G_CALLBACK(audio_changed), NULL);
/*init_volume();
init_alsa();*/
}
void audio::quit()
{
/*quit_alsa();*/
gst_deinit();
}

View File

@ -51,26 +51,6 @@ namespace libsaria
pos);
}
/*
* Use to seek forward or backward in a song
* by dt seconds.
*/
/*bool audio::seek(int dt)
{
bool ret;
gint64 pos;
ret = get_position(pos);
if (ret == true) {*/
/* Convert seconds to nano-seconds */
/* pos += (dt * GST_SECOND);
if (pos < 0)
pos = 0;
seek_to(pos);
}
return ret;
}*/
gint64 audio::duration()
{
gint64 duration;

View File

@ -1,34 +0,0 @@
// Copyright (c) 2011 Bryan Schumaker.
#include <audio.h>
#include <prefs.h>
#include "audio.h"
void configure_volume(float volume)
{
GValue value = { 0, };
g_value_init(&value, G_TYPE_DOUBLE);
g_value_set_double(&value, volume);
g_object_set_property(G_OBJECT(player), "volume", &value);
}
namespace libsaria
{
/*void audio::set_volume(float volume)
{
prefs::set("volume", volume);
}*/
void audio::init_volume()
{
//configure_volume(prefs::get_float("volume", 1.0));
}
/*float audio::get_volume()
{
//return prefs::get_float("volume", 1.0);
return 1.0;
}*/
};