libsaria: Change volume function

I introduced a function for directly setting the new volume level.  It
does not allow changing by some value.
This commit is contained in:
Bryan Schumaker 2011-09-03 09:49:09 -04:00
parent cfc86bd891
commit f354a305ae
4 changed files with 19 additions and 0 deletions

View File

@ -21,8 +21,10 @@ class Audio
Audio();
~Audio();
/* Other functions */
void init(int, char **);
void load(string);
void set_volume(double);
/* Control functions */
bool play();

View File

@ -15,7 +15,9 @@ class Libsaria
Libsaria(int, char**);
~Libsaria();
/* Other functions */
void load(string);
void set_volume(double);
void register_callback(callback_t, void (*)());
/* Control functions */

10
libsaria/audio/volume.cpp Normal file
View File

@ -0,0 +1,10 @@
#include <libsaria/audio.h>
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);
}

View File

@ -15,3 +15,8 @@ void Libsaria::load(string filepath)
audio.load(filepath);
play();
}
void Libsaria::set_volume(double volume)
{
audio.set_volume(volume);
}