libsaria: Store current audio volume
This allows me to restore the volume on startup.
This commit is contained in:
parent
f7d7d5e038
commit
603a76964b
|
@ -32,8 +32,8 @@ namespace libsaria
|
|||
string durstr();
|
||||
|
||||
/* Volume functions */
|
||||
double get_volume();
|
||||
void set_volume(double);
|
||||
float get_volume();
|
||||
void set_volume(float);
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ namespace libsaria
|
|||
g_signal_connect(player, "about-to-finish", G_CALLBACK(about_to_finish), NULL);
|
||||
g_signal_connect(player, "audio-changed", G_CALLBACK(audio_changed), NULL);
|
||||
|
||||
set_volume(1.0);
|
||||
init_volume();
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -13,4 +13,12 @@ extern GstBus *bus;
|
|||
|
||||
void load_file(GstElement *, string);
|
||||
|
||||
namespace libsaria
|
||||
{
|
||||
namespace audio
|
||||
{
|
||||
void init_volume();
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* LIBSARIA_AUDIO_PRIVATE_H */
|
||||
|
|
|
@ -1,25 +1,33 @@
|
|||
|
||||
#include <libsaria/audio.h>
|
||||
#include <libsaria/prefs.h>
|
||||
#include "audio.h"
|
||||
|
||||
static double cur_volume;
|
||||
void configure_volume(float 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);
|
||||
}
|
||||
|
||||
namespace libsaria
|
||||
{
|
||||
|
||||
void audio::set_volume(double volume)
|
||||
void audio::set_volume(float 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;
|
||||
prefs::set("volume", volume);
|
||||
}
|
||||
|
||||
double audio::get_volume()
|
||||
void audio::init_volume()
|
||||
{
|
||||
return cur_volume;
|
||||
configure_volume(prefs::get_float("volume", 1.0));
|
||||
}
|
||||
|
||||
float audio::get_volume()
|
||||
{
|
||||
return prefs::get_float("volume", 1.0);
|
||||
}
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue