volume, mixer: removed the "relative" parameter
Since the "volume" command has been removed, nobody uses relative volumes anymore.
This commit is contained in:
parent
206392ad1a
commit
90472526e0
|
@ -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");
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
44
src/volume.c
44
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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue