gst: More driver cleanups

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2014-12-20 11:49:22 -05:00
parent 3da3c8aeea
commit 9aaa8649ce
1 changed files with 17 additions and 21 deletions

View File

@ -1,5 +1,9 @@
/*
* Copyright 2014 (c) Anna Schumaker.
*
* The gst_init() function parses command line options passed to Ocarina
* through argv. Use the command `gst-inspect-1.0 --help-gst` to find
* what options are supported.
*/
#include <core/audio.h>
#include <core/driver.h>
@ -23,39 +27,28 @@ static bool gst_change_state(GstState state)
}
/**
* Driver for the GStreamer audio library.
*
* The shell command `gst-inspect-1.0 --help-gst` details the command line
* options that can be passed to Ocarina.
*/
class GSTDriver : public Driver
{
public:
void load(const std::string &filepath)
{
gchar *uri;
gchar *uri = gst_filename_to_uri(filepath.c_str(), NULL);
gst_change_state(GST_STATE_NULL);
uri = gst_filename_to_uri(filepath.c_str(), NULL);
g_object_set(G_OBJECT(gst_player), "uri", uri, NULL);
g_free(uri);
}
bool play()
{
return gst_change_state(GST_STATE_PLAYING);
}
bool pause()
{
return gst_change_state(GST_STATE_PAUSED);
}
bool play() { return gst_change_state(GST_STATE_PLAYING); }
bool pause() { return gst_change_state(GST_STATE_PAUSED); }
bool is_playing()
{
GstState state;
gst_element_get_state(gst_player, &state, NULL, GST_CLOCK_TIME_NONE);
gst_element_get_state(gst_player,
&state,
NULL,
GST_CLOCK_TIME_NONE);
return state == GST_STATE_PLAYING;
}
@ -70,7 +63,9 @@ public:
long position()
{
long position;
if (gst_element_query_position(gst_player, GST_FORMAT_TIME, &position))
if (gst_element_query_position(gst_player,
GST_FORMAT_TIME,
&position))
return position;
return 0;
}
@ -78,7 +73,9 @@ public:
long duration()
{
long duration;
if (gst_element_query_duration(gst_player, GST_FORMAT_TIME, &duration))
if (gst_element_query_duration(gst_player,
GST_FORMAT_TIME,
&duration))
return duration;
return 0;
}
@ -132,7 +129,6 @@ void init_gst(int *argc, char ***argv)
void quit_gst()
{
delete gst_driver;
gst_change_state(GST_STATE_NULL);
gst_deinit();
}