55 lines
995 B
C++
55 lines
995 B
C++
|
|
#include <libsaria/audio.h>
|
|
#include <libsaria/controls.h>
|
|
#include <libsaria/print.h>
|
|
#include "audio.h"
|
|
|
|
static GstElement *player = NULL;
|
|
static GstBus *bus = NULL;
|
|
|
|
GstElement *get_player()
|
|
{
|
|
return player;
|
|
}
|
|
|
|
static void parse_error(GstMessage *error)
|
|
{
|
|
GError *err;
|
|
gchar *debug;
|
|
|
|
gst_message_parse_error(error, &err, &debug);
|
|
g_print("Error: %s\n", err->message);
|
|
g_error_free(err);
|
|
g_free(debug);
|
|
}
|
|
|
|
static gboolean on_message(GstBus *bus, GstMessage *message, gpointer data)
|
|
{
|
|
switch (GST_MESSAGE_TYPE(message)) {
|
|
case GST_MESSAGE_ERROR:
|
|
parse_error(message);
|
|
case GST_MESSAGE_EOS:
|
|
libsaria::next();
|
|
default:
|
|
break;
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
namespace libsaria
|
|
{
|
|
|
|
void audio::init(int argc, char **argv)
|
|
{
|
|
println("Initializing audio driver");
|
|
gst_init(&argc, &argv);
|
|
|
|
player = gst_element_factory_make("playbin2", "player");
|
|
bus = gst_pipeline_get_bus(GST_PIPELINE(player));
|
|
|
|
gst_bus_add_watch(bus, on_message, NULL);
|
|
set_volume(1.0);
|
|
}
|
|
|
|
};
|