diff --git a/include/libsaria/audio.h b/include/libsaria/audio.h index 43697cd5..0a1c7a68 100644 --- a/include/libsaria/audio.h +++ b/include/libsaria/audio.h @@ -15,7 +15,8 @@ class Audio string cur_file; void reset(); - void change_state(GstState); + bool change_state(GstState); + void check_state(GstState); public: Audio(); @@ -25,8 +26,8 @@ class Audio void load(string); /* Control functions */ - void play(); - void pause(); + bool play(); + bool pause(); void seek(); }; diff --git a/libsaria/audio/controls.cpp b/libsaria/audio/controls.cpp index 49db47c7..e378fa29 100644 --- a/libsaria/audio/controls.cpp +++ b/libsaria/audio/controls.cpp @@ -1,19 +1,33 @@ #include +#include -void Audio::change_state(GstState new_state) +bool Audio::change_state(GstState new_state) { - gst_element_set_state(GST_ELEMENT(player), new_state); + GstStateChangeReturn ret; + ret = gst_element_set_state(GST_ELEMENT(player), new_state); + switch(ret) { + case GST_STATE_CHANGE_SUCCESS: + case GST_STATE_CHANGE_ASYNC: + return true; + default: + return false; + } } -void Audio::play() +void Audio::check_state(GstState state) { - change_state(GST_STATE_PLAYING); + } -void Audio::pause() +bool Audio::play() { - change_state(GST_STATE_PAUSED); + return change_state(GST_STATE_PLAYING); +} + +bool Audio::pause() +{ + return change_state(GST_STATE_PAUSED); } /*