summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-07-06 21:51:24 +0200
committerMax Kellermann <max@duempel.org>2009-07-06 21:51:24 +0200
commit90472526e00c671f76d78341b5e474fcf069d41e (patch)
tree1599ac0a94d11867558e0cb38ca2eaf3b3831848
parent206392ad1a9f4aa22d11719fb19f036c9f860272 (diff)
volume, mixer: removed the "relative" parameter
Since the "volume" command has been removed, nobody uses relative volumes anymore.
-rw-r--r--src/command.c2
-rw-r--r--src/mixer_all.c14
-rw-r--r--src/mixer_all.h5
-rw-r--r--src/volume.c44
-rw-r--r--src/volume.h2
5 files changed, 26 insertions, 41 deletions
diff --git a/src/command.c b/src/command.c
index 7f4444cfb..9f725edf1 100644
--- a/src/command.c
+++ b/src/command.c
@@ -1061,7 +1061,7 @@ handle_setvol(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
if (!check_int(client, &level, argv[1], need_integer))
return COMMAND_RETURN_ERROR;
- success = volume_level_change(level, 0);
+ success = volume_level_change(level);
if (!success) {
command_error(client, ACK_ERROR_SYSTEM,
"problems setting volume");
diff --git a/src/mixer_all.c b/src/mixer_all.c
index 252cb61ab..21ff44c35 100644
--- a/src/mixer_all.c
+++ b/src/mixer_all.c
@@ -70,7 +70,7 @@ mixer_all_get_volume(void)
}
static bool
-output_mixer_set_volume(unsigned i, int volume, bool relative)
+output_mixer_set_volume(unsigned i, int volume)
{
struct audio_output *output;
struct mixer *mixer;
@@ -85,14 +85,6 @@ output_mixer_set_volume(unsigned i, int volume, bool relative)
if (mixer == NULL)
return false;
- if (relative) {
- int prev = mixer_get_volume(mixer);
- if (prev < 0)
- return false;
-
- volume += prev;
- }
-
if (volume > 100)
volume = 100;
else if (volume < 0)
@@ -102,13 +94,13 @@ output_mixer_set_volume(unsigned i, int volume, bool relative)
}
bool
-mixer_all_set_volume(int volume, bool relative)
+mixer_all_set_volume(int volume)
{
bool success = false;
unsigned count = audio_output_count();
for (unsigned i = 0; i < count; i++)
- success = output_mixer_set_volume(i, volume, relative)
+ success = output_mixer_set_volume(i, volume)
|| success;
return success;
diff --git a/src/mixer_all.h b/src/mixer_all.h
index 66c4988de..1f6e016df 100644
--- a/src/mixer_all.h
+++ b/src/mixer_all.h
@@ -37,11 +37,10 @@ mixer_all_get_volume(void);
/**
* Sets the volume on all available mixers.
*
- * @param volume the volume (range 0..100 or -100..100 if #relative)
- * @param relative if true, then the #volume is added to the current value
+ * @param volume the volume (range 0..100)
* @return true on success, false on failure
*/
bool
-mixer_all_set_volume(int volume, bool relative);
+mixer_all_set_volume(int volume);
#endif
diff --git a/src/volume.c b/src/volume.c
index 938a51ac1..146c6b13a 100644
--- a/src/volume.c
+++ b/src/volume.c
@@ -117,51 +117,45 @@ int volume_level_get(void)
return -1;
}
-static bool software_volume_change(int change, bool rel)
+static bool software_volume_change(int volume)
{
- int new = change;
+ if (volume > 100)
+ volume = 100;
+ else if (volume < 0)
+ volume = 0;
- if (rel)
- new += volume_software_set;
+ volume_software_set = volume;
- if (new > 100)
- new = 100;
- else if (new < 0)
- new = 0;
-
- volume_software_set = new;
-
- /*new = 100.0*(exp(new/50.0)-1)/(M_E*M_E-1)+0.5; */
- if (new >= 100)
- new = PCM_VOLUME_1;
- else if (new <= 0)
- new = 0;
+ if (volume >= 100)
+ volume = PCM_VOLUME_1;
+ else if (volume <= 0)
+ volume = 0;
else
- new = pcm_float_to_volume((exp(new / 25.0) - 1) /
- (54.5981500331F - 1));
+ volume = pcm_float_to_volume((exp(volume / 25.0) - 1) /
+ (54.5981500331F - 1));
- setPlayerSoftwareVolume(new);
+ setPlayerSoftwareVolume(volume);
return true;
}
-static bool hardware_volume_change(int change, bool rel)
+static bool hardware_volume_change(int volume)
{
/* reset the cache */
last_hardware_volume = -1;
- return mixer_all_set_volume(change, rel);
+ return mixer_all_set_volume(volume);
}
-bool volume_level_change(int change, bool rel)
+bool volume_level_change(int volume)
{
idle_add(IDLE_MIXER);
switch (volume_mixer_type) {
case MIXER_TYPE_HARDWARE:
- return hardware_volume_change(change, rel);
+ return hardware_volume_change(volume);
case MIXER_TYPE_SOFTWARE:
- return software_volume_change(change, rel);
+ return software_volume_change(volume);
default:
return true;
}
@@ -182,7 +176,7 @@ void read_sw_volume_state(FILE *fp)
g_strchomp(buf);
sv = strtol(buf + strlen(SW_VOLUME_STATE), &end, 10);
if (G_LIKELY(!*end))
- software_volume_change(sv, 0);
+ software_volume_change(sv);
else
g_warning("Can't parse software volume: %s\n", buf);
return;
diff --git a/src/volume.h b/src/volume.h
index d5b9fec19..035d7215b 100644
--- a/src/volume.h
+++ b/src/volume.h
@@ -29,7 +29,7 @@ void volume_finish(void);
int volume_level_get(void);
-bool volume_level_change(int change, bool rel);
+bool volume_level_change(int volume);
void read_sw_volume_state(FILE *fp);