aboutsummaryrefslogtreecommitdiffstats
path: root/src/volume.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/volume.c79
1 files changed, 8 insertions, 71 deletions
diff --git a/src/volume.c b/src/volume.c
index 3d240f4e4..3e6079cd6 100644
--- a/src/volume.c
+++ b/src/volume.c
@@ -40,8 +40,6 @@
#define SW_VOLUME_STATE "sw_volume: "
-static enum mixer_type volume_mixer_type = MIXER_TYPE_HARDWARE;
-
static unsigned volume_software_set = 100;
/** the cached hardware mixer value; invalid if negative */
@@ -51,37 +49,15 @@ static GTimer *hardware_volume_timer;
void volume_finish(void)
{
- if (volume_mixer_type == MIXER_TYPE_HARDWARE)
- g_timer_destroy(hardware_volume_timer);
+ g_timer_destroy(hardware_volume_timer);
}
void volume_init(void)
{
- const struct config_param *param = config_get_param(CONF_MIXER_TYPE);
- //hw mixing is by default
- if (param) {
- volume_mixer_type = mixer_type_parse(param->value);
- switch (volume_mixer_type) {
- case MIXER_TYPE_NONE:
- case MIXER_TYPE_SOFTWARE:
- mixer_disable_all();
- break;
-
- case MIXER_TYPE_HARDWARE:
- //nothing to do
- break;
-
- case MIXER_TYPE_UNKNOWN:
- g_error("unknown mixer type %s at line %i\n",
- param->value, param->line);
- }
- }
-
- if (volume_mixer_type == MIXER_TYPE_HARDWARE)
- hardware_volume_timer = g_timer_new();
+ hardware_volume_timer = g_timer_new();
}
-static int hardware_volume_get(void)
+int volume_level_get(void)
{
assert(hardware_volume_timer != NULL);
@@ -95,43 +71,12 @@ static int hardware_volume_get(void)
return last_hardware_volume;
}
-static int software_volume_get(void)
-{
- return volume_software_set;
-}
-
-int volume_level_get(void)
-{
- switch (volume_mixer_type) {
- case MIXER_TYPE_SOFTWARE:
- return software_volume_get();
- case MIXER_TYPE_HARDWARE:
- return hardware_volume_get();
- case MIXER_TYPE_NONE:
- case MIXER_TYPE_UNKNOWN:
- return -1;
- }
-
- /* unreachable */
- assert(false);
- return -1;
-}
-
static bool software_volume_change(unsigned volume)
{
assert(volume <= 100);
volume_software_set = volume;
-
- if (volume >= 100)
- volume = PCM_VOLUME_1;
- else if (volume <= 0)
- volume = 0;
- else
- volume = pcm_float_to_volume((exp(volume / 25.0) - 1) /
- (54.5981500331F - 1));
-
- setPlayerSoftwareVolume(volume);
+ mixer_all_set_software_volume(volume);
return true;
}
@@ -148,16 +93,11 @@ bool volume_level_change(unsigned volume)
{
assert(volume <= 100);
+ volume_software_set = volume;
+
idle_add(IDLE_MIXER);
- switch (volume_mixer_type) {
- case MIXER_TYPE_HARDWARE:
- return hardware_volume_change(volume);
- case MIXER_TYPE_SOFTWARE:
- return software_volume_change(volume);
- default:
- return true;
- }
+ return hardware_volume_change(volume);
}
void read_sw_volume_state(FILE *fp)
@@ -166,8 +106,6 @@ void read_sw_volume_state(FILE *fp)
char *end = NULL;
long int sv;
- if (volume_mixer_type != MIXER_TYPE_SOFTWARE)
- return;
while (fgets(buf, sizeof(buf), fp)) {
if (!g_str_has_prefix(buf, SW_VOLUME_STATE))
continue;
@@ -184,6 +122,5 @@ void read_sw_volume_state(FILE *fp)
void save_sw_volume_state(FILE *fp)
{
- if (volume_mixer_type == MIXER_TYPE_SOFTWARE)
- fprintf(fp, SW_VOLUME_STATE "%u\n", volume_software_set);
+ fprintf(fp, SW_VOLUME_STATE "%u\n", volume_software_set);
}