gst: More driver cleanups
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
3da3c8aeea
commit
9aaa8649ce
38
gui/gst.cpp
38
gui/gst.cpp
|
@ -1,5 +1,9 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2014 (c) Anna Schumaker.
|
* 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/audio.h>
|
||||||
#include <core/driver.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
|
class GSTDriver : public Driver
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void load(const std::string &filepath)
|
void load(const std::string &filepath)
|
||||||
{
|
{
|
||||||
gchar *uri;
|
gchar *uri = gst_filename_to_uri(filepath.c_str(), NULL);
|
||||||
|
|
||||||
gst_change_state(GST_STATE_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_object_set(G_OBJECT(gst_player), "uri", uri, NULL);
|
||||||
g_free(uri);
|
g_free(uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool play()
|
bool play() { return gst_change_state(GST_STATE_PLAYING); }
|
||||||
{
|
bool pause() { return gst_change_state(GST_STATE_PAUSED); }
|
||||||
return gst_change_state(GST_STATE_PLAYING);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool pause()
|
|
||||||
{
|
|
||||||
return gst_change_state(GST_STATE_PAUSED);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool is_playing()
|
bool is_playing()
|
||||||
{
|
{
|
||||||
GstState state;
|
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;
|
return state == GST_STATE_PLAYING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +63,9 @@ public:
|
||||||
long position()
|
long position()
|
||||||
{
|
{
|
||||||
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 position;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -78,7 +73,9 @@ public:
|
||||||
long duration()
|
long duration()
|
||||||
{
|
{
|
||||||
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 duration;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -132,7 +129,6 @@ void init_gst(int *argc, char ***argv)
|
||||||
void quit_gst()
|
void quit_gst()
|
||||||
{
|
{
|
||||||
delete gst_driver;
|
delete gst_driver;
|
||||||
|
|
||||||
gst_change_state(GST_STATE_NULL);
|
gst_change_state(GST_STATE_NULL);
|
||||||
gst_deinit();
|
gst_deinit();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue