output/MultipleOutputs: SetVolume() throws on error

This reveals more about the nature of an error instead of just
returning "problems setting volume".
This commit is contained in:
Max Kellermann
2022-07-08 10:46:15 +02:00
parent 9bdc75524b
commit 2d7181105d
6 changed files with 62 additions and 31 deletions

View File

@@ -333,15 +333,11 @@ handle_getvol(Client &client, Request, Response &r)
}
CommandResult
handle_setvol(Client &client, Request args, Response &r)
handle_setvol(Client &client, Request args, Response &)
{
unsigned level = args.ParseUnsigned(0, 100);
if (!volume_level_change(client.GetPartition().outputs, level)) {
r.Error(ACK_ERROR_SYSTEM, "problems setting volume");
return CommandResult::ERROR;
}
volume_level_change(client.GetPartition().outputs, level);
return CommandResult::OK;
}
@@ -364,11 +360,8 @@ handle_volume(Client &client, Request args, Response &r)
else if (new_volume > 100)
new_volume = 100;
if (new_volume != old_volume &&
!volume_level_change(outputs, new_volume)) {
r.Error(ACK_ERROR_SYSTEM, "problems setting volume");
return CommandResult::ERROR;
}
if (new_volume != old_volume)
volume_level_change(outputs, new_volume);
return CommandResult::OK;
}