libsaria: Remove the get_player() function
I declared the variables in the local header file for use by the audio layer. I think this will make things a bit more efficient.
This commit is contained in:
parent
2458061cf3
commit
f8f5f87e54
|
@ -4,13 +4,8 @@
|
|||
#include <libsaria/print.h>
|
||||
#include "audio.h"
|
||||
|
||||
static GstElement *player = NULL;
|
||||
static GstBus *bus = NULL;
|
||||
|
||||
GstElement *get_player()
|
||||
{
|
||||
return player;
|
||||
}
|
||||
GstElement *player = NULL;
|
||||
GstBus *bus = NULL;
|
||||
|
||||
static void parse_error(GstMessage *error)
|
||||
{
|
||||
|
|
|
@ -8,6 +8,7 @@ extern "C" {
|
|||
#include <gst/gst.h>
|
||||
}
|
||||
|
||||
GstElement *get_player();
|
||||
extern GstElement *player;
|
||||
extern GstBus *bus;
|
||||
|
||||
#endif /* LIBSARIA_AUDIO_PRIVATE_H */
|
||||
|
|
|
@ -10,10 +10,7 @@ static GstState cur_state = GST_STATE_NULL;
|
|||
static bool change_state(GstState new_state)
|
||||
{
|
||||
GstStateChangeReturn ret;
|
||||
ret = gst_element_set_state(
|
||||
GST_ELEMENT(get_player()),
|
||||
new_state
|
||||
);
|
||||
ret = gst_element_set_state(GST_ELEMENT(player), new_state);
|
||||
|
||||
switch(ret) {
|
||||
case GST_STATE_CHANGE_SUCCESS:
|
||||
|
@ -65,7 +62,7 @@ namespace libsaria
|
|||
reset();
|
||||
println("Loading uri: " + uri);
|
||||
cur_file = file;
|
||||
g_object_set(G_OBJECT(get_player()), "uri", uri.c_str(), NULL);
|
||||
g_object_set(G_OBJECT(player), "uri", uri.c_str(), NULL);
|
||||
trigger_callback(TRACK_LOADED);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ using namespace std;
|
|||
static bool get_duration(gint64 &duration)
|
||||
{
|
||||
GstFormat fmt = GST_FORMAT_TIME;
|
||||
return gst_element_query_duration(GST_ELEMENT(get_player()),
|
||||
return gst_element_query_duration(GST_ELEMENT(player),
|
||||
&fmt,
|
||||
&duration);
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ static bool get_duration(gint64 &duration)
|
|||
static bool get_position(gint64 &position)
|
||||
{
|
||||
GstFormat fmt = GST_FORMAT_TIME;
|
||||
return gst_element_query_position(GST_ELEMENT(get_player()),
|
||||
return gst_element_query_position(GST_ELEMENT(player),
|
||||
&fmt,
|
||||
&position);
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ namespace libsaria
|
|||
|
||||
void audio::seek_to(double pos)
|
||||
{
|
||||
gst_element_seek_simple(GST_ELEMENT(get_player()),
|
||||
gst_element_seek_simple(GST_ELEMENT(player),
|
||||
GST_FORMAT_TIME,
|
||||
GST_SEEK_FLAG_FLUSH,
|
||||
pos);
|
||||
|
@ -45,7 +45,7 @@ namespace libsaria
|
|||
new_pos = cur_pos + (dt * GST_SECOND);
|
||||
if (new_pos < 0)
|
||||
new_pos = 0;
|
||||
gst_element_seek_simple(GST_ELEMENT(get_player()),
|
||||
gst_element_seek_simple(GST_ELEMENT(player),
|
||||
GST_FORMAT_TIME,
|
||||
GST_SEEK_FLAG_FLUSH,
|
||||
new_pos);
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace libsaria
|
|||
g_value_init(&value, G_TYPE_DOUBLE);
|
||||
g_value_set_double(&value, volume);
|
||||
|
||||
g_object_set_property(G_OBJECT(get_player()), "volume", &value);
|
||||
g_object_set_property(G_OBJECT(player), "volume", &value);
|
||||
cur_volume = volume;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue