aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-06-04 02:51:54 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-06-04 02:51:54 +0000
commit630d33b234dc116ca175c847abf4ca38e64d52fe (patch)
tree4929ccaf4efa5f1b82b13792d6cc3fe24420062b
parentf958e0a4c5bb7241b2ec443a402d10c29abfc08f (diff)
downloadmpd-630d33b234dc116ca175c847abf4ca38e64d52fe.tar.gz
mpd-630d33b234dc116ca175c847abf4ca38e64d52fe.tar.xz
mpd-630d33b234dc116ca175c847abf4ca38e64d52fe.zip
finish ack error codes
git-svn-id: https://svn.musicpd.org/mpd/trunk@1325 09075e82-0dd4-0310-85a5-a0d7c8717e4f
-rw-r--r--TODO4
-rw-r--r--src/command.c59
-rw-r--r--src/command.h13
-rw-r--r--src/directory.c34
-rw-r--r--src/directory.h2
-rw-r--r--src/interface.c1
-rw-r--r--src/main.c2
-rw-r--r--src/player.c3
-rw-r--r--src/playlist.c62
-rw-r--r--src/tables.c8
-rw-r--r--src/volume.c13
11 files changed, 121 insertions, 80 deletions
diff --git a/TODO b/TODO
index 64c5bbbad..ca080fd04 100644
--- a/TODO
+++ b/TODO
@@ -1,8 +1,6 @@
1) put some sort of error reporting for streaming/inputStream!
-2) ACK error codes
-
-3) Fix charset errors so they don't goto stderr/out
+2) Fix charset errors so they don't goto stderr/out
Post-1.0
diff --git a/src/command.c b/src/command.c
index b83daa8eb..1252886d8 100644
--- a/src/command.c
+++ b/src/command.c
@@ -154,7 +154,8 @@ int handlePlay(FILE * fp, unsigned int * permission, int argArrayLength,
if(argArrayLength==2) {
song = strtol(argArray[1],&test,10);
if(*test!='\0') {
- commandError(fp, "need a positive integer");
+ commandError(fp, ACK_ERROR_ARG,
+ "need a positive integer");
return -1;
}
}
@@ -174,7 +175,7 @@ int handlePause(FILE * fp, unsigned int * permission,
char * test;
int pause = strtol(argArray[1],&test,10);
if(*test!='\0' || (pause!=0 && pause!=1)) {
- commandError(fp, "\%s\" is not 0 or 1", argArray[1]);
+ commandError(fp, ACK_ERROR_ARG, "\%s\" is not 0 or 1", argArray[1]);
return -1;
}
return playerSetPause(fp,pause);
@@ -265,7 +266,8 @@ int handleDelete(FILE * fp, unsigned int * permission, int argArrayLength,
song = strtol(argArray[1],&test,10);
if(*test!='\0') {
- commandError(fp, "need a positive integer");
+ commandError(fp, ACK_ERROR_ARG,
+ "need a positive integer");
return -1;
}
return deleteFromPlaylist(fp,song);
@@ -329,7 +331,8 @@ int handlePlaylistInfo(FILE * fp, unsigned int * permission,
if(argArrayLength == 2) {
song = strtol(argArray[1],&test,10);
if(*test!='\0') {
- commandError(fp, "%s need a positive integer");
+ commandError(fp, ACK_ERROR_ARG,
+ "%s need a positive integer");
return -1;
}
}
@@ -418,7 +421,7 @@ int handleVolume(FILE * fp, unsigned int * permission, int argArrayLength,
change = strtol(argArray[1],&test,10);
if(*test!='\0') {
- commandError(fp, "need an integer");
+ commandError(fp, ACK_ERROR_ARG, "need an integer");
return -1;
}
return changeVolumeLevel(fp,change,1);
@@ -432,7 +435,7 @@ int handleSetVol(FILE * fp, unsigned int * permission, int argArrayLength,
level = strtol(argArray[1],&test,10);
if(*test!='\0') {
- commandError(fp, "need an integer");
+ commandError(fp, ACK_ERROR_ARG, "need an integer");
return -1;
}
return changeVolumeLevel(fp,level,0);
@@ -446,7 +449,7 @@ int handleRepeat(FILE * fp, unsigned int * permission, int argArrayLength,
status = strtol(argArray[1],&test,10);
if(*test!='\0') {
- commandError(fp, "need an integer");
+ commandError(fp, ACK_ERROR_ARG, "need an integer");
return -1;
}
return setPlaylistRepeatStatus(fp,status);
@@ -460,7 +463,7 @@ int handleRandom(FILE * fp, unsigned int * permission, int argArrayLength,
status = strtol(argArray[1],&test,10);
if(*test!='\0') {
- commandError(fp, "need an integer");
+ commandError(fp, ACK_ERROR_ARG, "need an integer");
return -1;
}
return setPlaylistRandomStatus(fp,status);
@@ -497,12 +500,14 @@ int handleMove(FILE * fp, unsigned int * permission, int argArrayLength,
from = strtol(argArray[1],&test,10);
if(*test!='\0') {
- commandError(fp, "\"%s\" is not a integer", argArray[1]);
+ commandError(fp, ACK_ERROR_ARG,
+ "\"%s\" is not a integer", argArray[1]);
return -1;
}
to = strtol(argArray[2],&test,10);
if(*test!='\0') {
- commandError(fp, "\"%s\" is not a integer", argArray[2]);
+ commandError(fp, ACK_ERROR_ARG,
+ "\"%s\" is not a integer", argArray[2]);
return -1;
}
return moveSongInPlaylist(fp,from,to);
@@ -517,12 +522,14 @@ int handleSwap(FILE * fp, unsigned int * permission, int argArrayLength,
song1 = strtol(argArray[1],&test,10);
if(*test!='\0') {
- commandError(fp, "\"%s\" is not a integer", argArray[1]);
+ commandError(fp, ACK_ERROR_ARG,
+ "\"%s\" is not a integer", argArray[1]);
return -1;
}
song2 = strtol(argArray[2],&test,10);
if(*test!='\0') {
- commandError(fp, "\"%s\" is not a integer", argArray[2]);
+ commandError(fp, ACK_ERROR_ARG, "\"%s\" is not a integer",
+ argArray[2]);
return -1;
}
return swapSongsInPlaylist(fp,song1,song2);
@@ -537,12 +544,14 @@ int handleSeek(FILE * fp, unsigned int * permission, int argArrayLength,
song = strtol(argArray[1],&test,10);
if(*test!='\0') {
- commandError(fp, "\"%s\" is not a integer", argArray[1]);
+ commandError(fp, ACK_ERROR_ARG,
+ "\"%s\" is not a integer", argArray[1]);
return -1;
}
time = strtol(argArray[2],&test,10);
if(*test!='\0') {
- commandError(fp, "\"%s\" is not a integer", argArray[2]);
+ commandError(fp, ACK_ERROR_ARG,
+ "\"%s\" is not a integer", argArray[2]);
return -1;
}
return seekSongInPlaylist(fp,song,time);
@@ -567,7 +576,7 @@ int handlePassword(FILE * fp, unsigned int * permission, int argArrayLength,
char ** argArray)
{
if(getPermissionFromPassword(argArray[1],permission)<0) {
- commandError(fp, "incorrect password");
+ commandError(fp, ACK_ERROR_PASSWORD, "incorrect password");
return -1;
}
@@ -582,7 +591,8 @@ int handleCrossfade(FILE * fp, unsigned int * permission, int argArrayLength,
time = strtol(argArray[1],&test,10);
if(*test!='\0' || time<0) {
- commandError(fp, "\"%s\" is not a integer >= 0", argArray[1]);
+ commandError(fp, ACK_ERROR_ARG,
+ "\"%s\" is not a integer >= 0", argArray[1]);
return -1;
}
@@ -647,7 +657,8 @@ int checkArgcAndPermission(CommandEntry * cmd, FILE *fp,
if (cmd->reqPermission != (permission & cmd->reqPermission)) {
if(fp) {
- commandError(fp, "you don't have permission for \"%s\"",
+ commandError(fp, ACK_ERROR_PERMISSION,
+ "you don't have permission for \"%s\"",
cmd->cmd);
}
return -1;
@@ -657,21 +668,24 @@ int checkArgcAndPermission(CommandEntry * cmd, FILE *fp,
if (min == max && max != argc) {
if(fp) {
- commandError(fp, "wrong number of arguments for \"%s\"",
+ commandError(fp, ACK_ERROR_ARG,
+ "wrong number of arguments for \"%s\"",
argArray[0]);
}
return -1;
}
else if (argc < min) {
if(fp) {
- commandError(fp, "too few arguments for \"%s\"",
+ commandError(fp, ACK_ERROR_ARG,
+ "too few arguments for \"%s\"",
argArray[0]);
}
return -1;
}
else if (argc > max && max /* != 0 */) {
if(fp) {
- commandError(fp, "too many arguments for \"%s\"",
+ commandError(fp, ACK_ERROR_ARG,
+ "too many arguments for \"%s\"",
argArray[0]);
}
return -1;
@@ -690,7 +704,10 @@ CommandEntry * getCommandEntryAndCheckArgcAndPermission(FILE * fp,
if(argArrayLength == 0) return NULL;
if(!findInList(commandList, argArray[0],(void *)&cmd)) {
- if(fp) commandError(fp, "unknown command \"%s\"", argArray[0]);
+ if(fp) {
+ commandError(fp, ACK_ERROR_UNKNOWN,
+ "unknown command \"%s\"", argArray[0]);
+ }
return NULL;
}
diff --git a/src/command.h b/src/command.h
index 8e2b90711..08263ef97 100644
--- a/src/command.h
+++ b/src/command.h
@@ -23,6 +23,8 @@
#include "list.h"
#include "myfprintf.h"
+#include "log.h"
+#include "ack.h"
#include <stdio.h>
@@ -43,17 +45,18 @@ void finishCommands();
#define commandSuccess(fp) myfprintf(fp, "OK\n")
-#define commandError(fp, format, ... ) \
+#define commandError(fp, error, format, ... ) \
{\
if(current_command) { \
- myfprintf(fp, "ACK [%s:%i] " format "\n", \
+ myfprintf(fp, "ACK [%s:%i:%i] " format "\n", \
current_command, command_listNum, \
- ##__VA_ARGS__); \
+ (int)error, ##__VA_ARGS__); \
current_command = NULL; \
} \
else { \
- myfprintf(fp, "ACK [:%i] " format "\n", \
- command_listNum, ##__VA_ARGS__); \
+ myfprintf(fp, "ACK [:%i:%i] " format "\n", \
+ command_listNum, (int)error, \
+ ##__VA_ARGS__); \
} \
}
diff --git a/src/directory.c b/src/directory.c
index f73a4f14c..653cdb15f 100644
--- a/src/directory.c
+++ b/src/directory.c
@@ -166,7 +166,7 @@ void readDirectoryDBIfUpdateIsFinished() {
int updateInit(FILE * fp, List * pathList) {
if(directory_updatePid > 0) {
- commandError(fp, "already updating");
+ commandError(fp, ACK_ERROR_UPDATE_ALREADY, "already updating");
return -1;
}
@@ -223,7 +223,8 @@ int updateInit(FILE * fp, List * pathList) {
else if(directory_updatePid < 0) {
unblockSignals();
ERROR("updateInit: Problems forking()'ing\n");
- commandError(fp, "problems trying to update");
+ commandError(fp, ACK_ERROR_SYSTEM,
+ "problems trying to update");
directory_updatePid = 0;
return -1;
}
@@ -744,7 +745,7 @@ int printDirectoryInfo(FILE * fp, char * name) {
Directory * directory;
if((directory = getDirectory(name))==NULL) {
- commandError(fp, "directory not found");
+ commandError(fp, ACK_ERROR_NO_EXIST, "directory not found");
return -1;
}
@@ -977,27 +978,25 @@ int readDirectoryDB() {
return 0;
}
-int updateMp3Directory(FILE * fp) {
+void updateMp3Directory() {
switch(updateDirectory(mp3rootDirectory)) {
case 0:
/* nothing updated */
- return 0;
+ return;
case 1:
+ if(writeDirectoryDB()<0) {
+ ERROR("problems writing music db file, \"%s\"\n",
+ directory_db);
+ exit(EXIT_FAILURE);
+ }
/* something was updated and db should be written */
break;
default:
ERROR("problems updating music db\n");
- commandError(fp, "problems updating music db");
- return -1;
+ exit(EXIT_FAILURE);
}
- if(writeDirectoryDB()<0) {
- ERROR("problems writing music db file, \"%s\"\n",directory_db);
- commandError(fp, "problems writing music db");
- return -1;
- }
-
- return 0;
+ return;
}
int traverseAllInSubDirectory(FILE * fp, Directory * directory,
@@ -1047,7 +1046,8 @@ int traverseAllIn(FILE * fp, char * name,
if((song = getSongFromDB(name)) && forEachSong) {
return forEachSong(fp, song, data);
}
- commandError(fp, "directory or file not found");
+ commandError(fp, ACK_ERROR_NO_EXIST,
+ "directory or file not found");
return -1;
}
@@ -1129,7 +1129,7 @@ int searchForSongsIn(FILE * fp, char * name, char * item, char * string) {
ret = traverseAllIn(fp,name,searchForFilenameInDirectory,NULL,
(void *)dup);
}
- else commandError(fp, "unknown table");
+ else commandError(fp, ACK_ERROR_ARG, "unknown table");
free(dup);
@@ -1166,7 +1166,7 @@ int findSongsIn(FILE * fp, char * name, char * item, char * string) {
(void *)string);
}
- commandError(fp, "unknown table");
+ commandError(fp, ACK_ERROR_ARG, "unknown table");
return -1;
}
diff --git a/src/directory.h b/src/directory.h
index eb9c6fcc7..a23c6f0c3 100644
--- a/src/directory.h
+++ b/src/directory.h
@@ -49,7 +49,7 @@ int writeDirectoryDB();
int readDirectoryDB();
-int updateMp3Directory(FILE * fp);
+void updateMp3Directory();
int printAllIn(FILE * fp, char * name);
diff --git a/src/interface.c b/src/interface.c
index 4abbc8c4f..651a84380 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -289,6 +289,7 @@ int interfaceReadInput(Interface * interface) {
==0)
{
commandError(interface->fp,
+ ACK_ERROR_NOT_LIST,
"not in command list mode");
ret = -1;
}
diff --git a/src/main.c b/src/main.c
index 894b1552e..13eb689fb 100644
--- a/src/main.c
+++ b/src/main.c
@@ -324,7 +324,7 @@ void openDB(Options * options, char * argv0) {
if(options->createDB) exit(EXIT_SUCCESS);
}
if(options->updateDB) {
- if(updateMp3Directory(stderr)<0) exit(EXIT_FAILURE);
+ updateMp3Directory();
exit(EXIT_SUCCESS);
}
}
diff --git a/src/player.c b/src/player.c
index b4b4e8b74..cda88fff4 100644
--- a/src/player.c
+++ b/src/player.c
@@ -386,7 +386,8 @@ int playerSeek(FILE * fp, Song * song, float time) {
PlayerControl * pc = &(getPlayerData()->playerControl);
if(pc->state==PLAYER_STATE_STOP) {
- commandError(fp, "player not currently playing");
+ commandError(fp, ACK_ERROR_PLAYER_SYNC,
+ "player not currently playing");
return -1;
}
diff --git a/src/playlist.c b/src/playlist.c
index 9c8755216..2e5e20668 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -375,7 +375,8 @@ int playlistInfo(FILE * fp,int song) {
end = song+1;
}
if(song>=playlist.length) {
- commandError(fp, "song doesn't exist: \"%i\"", song);
+ commandError(fp, ACK_ERROR_NO_EXIST,
+ "song doesn't exist: \"%i\"", song);
return -1;
}
@@ -486,7 +487,8 @@ int addToPlaylist(FILE * fp, char * url) {
{
}
else {
- commandError(fp, "\"%s\" is not in the music db or is"
+ commandError(fp, ACK_ERROR_NO_EXIST,
+ "\"%s\" is not in the music db or is"
"not a valid url\n", url);
return -1;
}
@@ -496,7 +498,8 @@ int addToPlaylist(FILE * fp, char * url) {
int addSongToPlaylist(FILE * fp, Song * song) {
if(playlist.length==playlist_max_length) {
- commandError(fp, "playlist is at the max size");
+ commandError(fp, ACK_ERROR_PLAYLIST_MAX,
+ "playlist is at the max size");
return -1;
}
@@ -535,11 +538,13 @@ int swapSongsInPlaylist(FILE * fp, int song1, int song2) {
int currentSong = -1;
if(song1<0 || song1>=playlist.length) {
- commandError(fp, "song doesn't exist: \"%i\"", song1);
+ commandError(fp, ACK_ERROR_NO_EXIST,
+ "song doesn't exist: \"%i\"", song1);
return -1;
}
if(song2<0 || song2>=playlist.length) {
- commandError(fp, "song doesn't exist: \"%i\"", song2);
+ commandError(fp, ACK_ERROR_NO_EXIST,
+ "song doesn't exist: \"%i\"", song2);
return -1;
}
@@ -586,7 +591,8 @@ int deleteFromPlaylist(FILE * fp, int song) {
int songOrder;
if(song<0 || song>=playlist.length) {
- commandError(fp, "song doesn't exist: \"%i\"", song);
+ commandError(fp, ACK_ERROR_NO_EXIST,
+ "song doesn't exist: \"%i\"", song);
return -1;
}
@@ -710,7 +716,8 @@ int playPlaylist(FILE * fp, int song, int stopOnError) {
}
}
else if(song<0 || song>=playlist.length) {
- commandError(fp, "song doesn't exist: \"%i\"", song);
+ commandError(fp, ACK_ERROR_NO_EXIST,
+ "song doesn't exist: \"%i\"", song);
playlist_state = PLAYLIST_STATE_STOP;
return -1;
}
@@ -831,7 +838,7 @@ int getPlaylistRandomStatus() {
int setPlaylistRepeatStatus(FILE * fp, int status) {
if(status!=0 && status!=1) {
- commandError(fp, "\"%i\" is not 0 or 1", status);
+ commandError(fp, ACK_ERROR_ARG, "\"%i\" is not 0 or 1", status);
return -1;
}
@@ -855,12 +862,14 @@ int moveSongInPlaylist(FILE * fp, int from, int to) {
int currentSong = -1;
if(from<0 || from>=playlist.length) {
- commandError(fp, "song doesn't exist: \"%i\"", from);
+ commandError(fp, ACK_ERROR_NO_EXIST,
+ "song doesn't exist: \"%i\"", from);
return -1;
}
if(to<0 || to>=playlist.length) {
- commandError(fp, "song doesn't exist: \"%i\"", to);
+ commandError(fp, ACK_ERROR_NO_EXIST,
+ "song doesn't exist: \"%i\"", to);
return -1;
}
@@ -966,7 +975,7 @@ int setPlaylistRandomStatus(FILE * fp, int status) {
int statusWas = playlist.random;
if(status!=0 && status!=1) {
- commandError(fp, "\"%i\" is not 0 or 1", status);
+ commandError(fp, ACK_ERROR_ARG, "\"%i\" is not 0 or 1", status);
return -1;
}
@@ -1060,12 +1069,14 @@ int deletePlaylist(FILE * fp, char * utf8file) {
if((actualFile = rpp2app(rfile)) && isPlaylist(actualFile)) free(rfile);
else {
free(rfile);
- commandError(fp, "playlist \"%s\" not found", utf8file);
+ commandError(fp, ACK_ERROR_NO_EXIST,
+ "playlist \"%s\" not found", utf8file);
return -1;
}
if(unlink(actualFile)<0) {
- commandError(fp, "problems deleting file");
+ commandError(fp, ACK_ERROR_SYSTEM,
+ "problems deleting file");
return -1;
}
@@ -1081,7 +1092,8 @@ int savePlaylist(FILE * fp, char * utf8file) {
char * actualFile;
if(strstr(utf8file,"/")) {
- commandError(fp, "cannot save \"%s\", saving playlists to "
+ commandError(fp, ACK_ERROR_ARG,
+ "cannot save \"%s\", saving playlists to "
"subdirectories is not supported", utf8file);
return -1;
}
@@ -1109,7 +1121,7 @@ int savePlaylist(FILE * fp, char * utf8file) {
while(!(fileP = fopen(actualFile,"w")) && errno==EINTR);
if(fileP==NULL) {
- commandError(fp, "problems opening file");
+ commandError(fp, ACK_ERROR_SYSTEM, "problems opening file");
return -1;
}
@@ -1151,13 +1163,15 @@ int loadPlaylist(FILE * fp, char * utf8file) {
if((actualFile = rpp2app(rfile)) && isPlaylist(actualFile)) free(rfile);
else {
free(rfile);
- commandError(fp, "playlist \"%s\" not found", utf8file);
+ commandError(fp, ACK_ERROR_NO_EXIST,
+ "playlist \"%s\" not found", utf8file);
return -1;
}
while(!(fileP = fopen(actualFile,"r")) && errno==EINTR);
if(fileP==NULL) {
- commandError(fp, "problems opening file \"%s\"", utf8file);
+ commandError(fp, ACK_ERROR_SYSTEM,
+ "problems opening file \"%s\"", utf8file);
return -1;
}
@@ -1175,7 +1189,9 @@ int loadPlaylist(FILE * fp, char * utf8file) {
strncat(s,"/",MAXPATHLEN-parentlen);
strncat(s,temp,MAXPATHLEN-parentlen-1);
if(strlen(s)>=MAXPATHLEN) {
- commandError(fp, "\"%s\" too long",
+ commandError(fp,
+ ACK_ERROR_PLAYLIST_LOAD,
+ "\"%s\" too long",
temp);
free(temp);
while(fclose(fileP) && errno==EINTR);
@@ -1201,7 +1217,8 @@ int loadPlaylist(FILE * fp, char * utf8file) {
}
else if(slength==MAXPATHLEN) {
s[slength] = '\0';
- commandError(fp, "\"%s\" too long", s);
+ commandError(fp, ACK_ERROR_PLAYLIST_LOAD,
+ "\"%s\" too long", s);
while(fclose(fileP) && errno==EINTR);
if(erroredFile) free(erroredFile);
return -1;
@@ -1212,7 +1229,8 @@ int loadPlaylist(FILE * fp, char * utf8file) {
while(fclose(fileP) && errno==EINTR);
if(erroredFile) {
- commandError(fp, "can't add file \"%s\"", erroredFile);
+ commandError(fp, ACK_ERROR_PLAYLIST_LOAD,
+ "can't add file \"%s\"", erroredFile);
free(erroredFile);
return -1;
}
@@ -1240,7 +1258,8 @@ int seekSongInPlaylist(FILE * fp, int song, float time) {
int i = song;
if(song<0 || song>=playlist.length) {
- commandError(fp, "song doesn't exist: \"%i\"", song);
+ commandError(fp, ACK_ERROR_NO_EXIST,
+ "song doesn't exist: \"%i\"", song);
return -1;
}
@@ -1265,4 +1284,3 @@ int seekSongInPlaylist(FILE * fp, int song, float time) {
return playerSeek(fp, playlist.songs[playlist.order[i]], time);
}
-/* vim:set shiftwidth=4 tabstop=8 expandtab: */
diff --git a/src/tables.c b/src/tables.c
index 0270319f4..a29f60163 100644
--- a/src/tables.c
+++ b/src/tables.c
@@ -172,7 +172,8 @@ int printAllAlbums(FILE * fp, char * artist) {
}
}
else {
- commandError(fp, "artist \"%s\" not found", artist);
+ commandError(fp, ACK_ERROR_NO_EXIST,
+ "artist \"%s\" not found", artist);
return -1;
}
}
@@ -183,7 +184,8 @@ int printAllAlbums(FILE * fp, char * artist) {
int printAllKeysOfTable(FILE * fp, char * table, char * arg1) {
if(strcmp(table,TABLES_ARTIST)==0) {
if(arg1!=NULL) {
- commandError(fp, "%s table takes no args", table);
+ commandError(fp, ACK_ERROR_ARG,
+ "%s table takes no args", table);
return -1;
}
return printAllArtists(fp);
@@ -192,7 +194,7 @@ int printAllKeysOfTable(FILE * fp, char * table, char * arg1) {
return printAllAlbums(fp,arg1);
}
else {
- commandError(fp, "table \"%s\" does not exist", table);
+ commandError(fp, ACK_ERROR_ARG, "unknown table", table);
return -1;
}
}
diff --git a/src/volume.c b/src/volume.c
index bf367ab75..42f72ba48 100644
--- a/src/volume.c
+++ b/src/volume.c
@@ -144,7 +144,8 @@ int changeOssVolumeLevel(FILE * fp, int change, int rel) {
if (rel) {
if((current = getOssVolumeLevel()) < 0) {
- commandError(fp, "problem getting current volume");
+ commandError(fp, ACK_ERROR_SYSTEM,
+ "problem getting current volume");
return -1;
}
@@ -158,7 +159,7 @@ int changeOssVolumeLevel(FILE * fp, int change, int rel) {
level = (new << 8) + new;
if(ioctl(volume_ossFd,MIXER_WRITE(volume_ossControl),&level) < 0) {
- commandError(fp, "problems setting volume");
+ commandError(fp, ACK_ERROR_SYSTEM, "problems setting volume");
return -1;
}
@@ -270,7 +271,7 @@ int changeAlsaVolumeLevel(FILE * fp, int change, int rel) {
if((err = snd_mixer_selem_get_playback_volume(volume_alsaElem,
SND_MIXER_SCHN_FRONT_LEFT,&level))<0) {
- commandError(fp, "problems getting volume");
+ commandError(fp, ACK_ERROR_SYSTEM, "problems getting volume");
ERROR("problems getting alsa volume: %s\n",snd_strerror(err));
return -1;
}
@@ -296,7 +297,7 @@ int changeAlsaVolumeLevel(FILE * fp, int change, int rel) {
if((err = snd_mixer_selem_set_playback_volume_all(
volume_alsaElem,level))<0) {
- commandError(fp, "problems setting volume");
+ commandError(fp, ACK_ERROR_SYSTEM, "problems setting volume");
ERROR("problems setting alsa volume: %s\n",snd_strerror(err));
return -1;
}
@@ -423,8 +424,8 @@ int changeVolumeLevel(FILE * fp, int change, int rel) {
case VOLUME_MIXER_TYPE_SOFTWARE:
return changeSoftwareVolume(fp,change,rel);
default:
- commandError(fp, "no volume support");
- return -1;
+ return 0;
+ break;
}
}
/* vim:set shiftwidth=4 tabstop=8 expandtab: */