From f15d879e37985224aa4780a9de6b81d2df781ed6 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 14 Mar 2009 11:10:21 +0100 Subject: volume: use bool instead of int Return true/false on success/failure, instead of 0/-1. Pass true/false instead of 1/0 for the "rel" boolean parameter. --- src/command.c | 22 ++++++++++++++-------- src/volume.c | 12 ++++++------ src/volume.h | 3 ++- 3 files changed, 22 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/command.c b/src/command.c index 1a019b830..535c3638c 100644 --- a/src/command.c +++ b/src/command.c @@ -1039,33 +1039,39 @@ handle_listall(struct client *client, G_GNUC_UNUSED int argc, char *argv[]) static enum command_return handle_volume(struct client *client, G_GNUC_UNUSED int argc, char *argv[]) { - int change, ret; + int change; + bool success; if (!check_int(client, &change, argv[1], need_integer)) return COMMAND_RETURN_ERROR; - ret = volume_level_change(change, 1); - if (ret == -1) + success = volume_level_change(change, true); + if (!success) { command_error(client, ACK_ERROR_SYSTEM, "problems setting volume"); + return COMMAND_RETURN_ERROR; + } - return ret; + return COMMAND_RETURN_OK; } static enum command_return handle_setvol(struct client *client, G_GNUC_UNUSED int argc, char *argv[]) { - int level, ret; + int level; + bool success; if (!check_int(client, &level, argv[1], need_integer)) return COMMAND_RETURN_ERROR; - ret = volume_level_change(level, 0); - if (ret == -1) + success = volume_level_change(level, 0); + if (!success) { command_error(client, ACK_ERROR_SYSTEM, "problems setting volume"); + return COMMAND_RETURN_ERROR; + } - return ret; + return COMMAND_RETURN_OK; } static enum command_return diff --git a/src/volume.c b/src/volume.c index 5ce842251..8e97280a4 100644 --- a/src/volume.c +++ b/src/volume.c @@ -215,7 +215,7 @@ int volume_level_get(void) return -1; } -static int software_volume_change(int change, int rel) +static bool software_volume_change(int change, bool rel) { int new = change; @@ -240,10 +240,10 @@ static int software_volume_change(int change, int rel) setPlayerSoftwareVolume(new); - return 0; + return true; } -static int hardware_volume_change(int change, int rel) +static bool hardware_volume_change(int change, bool rel) { int device, count; @@ -254,10 +254,10 @@ static int hardware_volume_change(int change, int rel) for (device=0; device #include #define VOLUME_MIXER_OSS "oss" @@ -34,7 +35,7 @@ void volume_finish(void); int volume_level_get(void); -int volume_level_change(int change, int rel); +bool volume_level_change(int change, bool rel); void read_sw_volume_state(FILE *fp); -- cgit v1.2.3