libsaria: Added a get_volume() function

I use this function to get the current volume levels.  I added and extra
variable to the Audio class to track what the current volume is.
This commit is contained in:
Bryan Schumaker 2011-09-03 10:24:34 -04:00
parent 5a8cafa4d8
commit ceddd240ca
5 changed files with 16 additions and 0 deletions

View File

@ -13,6 +13,7 @@ class Audio
private:
GstElement *player;
string cur_file;
double cur_volume;
void reset();
bool change_state(GstState);
@ -25,6 +26,7 @@ class Audio
void init(int, char **);
void load(string);
void set_volume(double);
double get_volume();
/* Control functions */
bool play();

View File

@ -18,6 +18,7 @@ class Libsaria
/* Other functions */
void load(string);
void set_volume(double);
double get_volume();
void register_callback(callback_t, void (*)());
/* Control functions */

View File

@ -25,6 +25,7 @@ void Audio::init(int argc, char **argv)
print("Initializing gstreamer");
init_gstreamer(argc, argv);
player = gst_element_factory_make("playbin2", "player");
set_volume(1.0);
}
void Audio::reset()

View File

@ -6,5 +6,12 @@ void Audio::set_volume(double volume)
GValue value = { 0, };
g_value_init(&value, G_TYPE_DOUBLE);
g_value_set_double(&value, volume);
g_object_set_property(G_OBJECT(player), "volume", &value);
cur_volume = volume;
}
double Audio::get_volume()
{
return cur_volume;
}

View File

@ -21,3 +21,8 @@ void Libsaria::set_volume(double volume)
audio.set_volume(volume);
trigger_callback(VOLUME);
}
double Libsaria::get_volume()
{
return audio.get_volume();
}