Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
ef6c500e
Commit
ef6c500e
authored
Jun 04, 2004
by
Warren Dukes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean up ACK error coding a little bit
git-svn-id:
https://svn.musicpd.org/mpd/trunk@1321
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
dafe92a9
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
83 additions
and
111 deletions
+83
-111
command.c
src/command.c
+23
-36
command.h
src/command.h
+5
-4
directory.c
src/directory.c
+8
-9
interface.c
src/interface.c
+6
-8
player.c
src/player.c
+1
-2
playlist.c
src/playlist.c
+31
-39
tables.c
src/tables.c
+4
-5
volume.c
src/volume.c
+5
-8
No files found.
src/command.c
View file @
ef6c500e
...
@@ -151,7 +151,7 @@ int handlePlay(FILE * fp, unsigned int * permission, int argArrayLength,
...
@@ -151,7 +151,7 @@ int handlePlay(FILE * fp, unsigned int * permission, int argArrayLength,
if
(
argArrayLength
==
2
)
{
if
(
argArrayLength
==
2
)
{
song
=
strtol
(
argArray
[
1
],
&
test
,
10
);
song
=
strtol
(
argArray
[
1
],
&
test
,
10
);
if
(
*
test
!=
'\0'
)
{
if
(
*
test
!=
'\0'
)
{
myfprintf
(
fp
,
"%s need a positive integer
\n
"
,
COMMAND_RESPOND_ERROR
);
commandError
(
fp
,
"need a positive integer"
);
return
-
1
;
return
-
1
;
}
}
}
}
...
@@ -171,8 +171,7 @@ int handlePause(FILE * fp, unsigned int * permission,
...
@@ -171,8 +171,7 @@ int handlePause(FILE * fp, unsigned int * permission,
char
*
test
;
char
*
test
;
int
pause
=
strtol
(
argArray
[
1
],
&
test
,
10
);
int
pause
=
strtol
(
argArray
[
1
],
&
test
,
10
);
if
(
*
test
!=
'\0'
||
(
pause
!=
0
&&
pause
!=
1
))
{
if
(
*
test
!=
'\0'
||
(
pause
!=
0
&&
pause
!=
1
))
{
myfprintf
(
fp
,
"%s \%s
\"
is not 0 or 1
\n
"
,
commandError
(
fp
,
"\%s
\"
is not 0 or 1"
,
argArray
[
1
]);
COMMAND_RESPOND_ERROR
,
pause
);
return
-
1
;
return
-
1
;
}
}
return
playerSetPause
(
fp
,
pause
);
return
playerSetPause
(
fp
,
pause
);
...
@@ -263,7 +262,7 @@ int handleDelete(FILE * fp, unsigned int * permission, int argArrayLength,
...
@@ -263,7 +262,7 @@ int handleDelete(FILE * fp, unsigned int * permission, int argArrayLength,
song
=
strtol
(
argArray
[
1
],
&
test
,
10
);
song
=
strtol
(
argArray
[
1
],
&
test
,
10
);
if
(
*
test
!=
'\0'
)
{
if
(
*
test
!=
'\0'
)
{
myfprintf
(
fp
,
"%s need a positive integer
\n
"
,
COMMAND_RESPOND_ERROR
);
commandError
(
fp
,
"need a positive integer"
);
return
-
1
;
return
-
1
;
}
}
return
deleteFromPlaylist
(
fp
,
song
);
return
deleteFromPlaylist
(
fp
,
song
);
...
@@ -327,7 +326,7 @@ int handlePlaylistInfo(FILE * fp, unsigned int * permission,
...
@@ -327,7 +326,7 @@ int handlePlaylistInfo(FILE * fp, unsigned int * permission,
if
(
argArrayLength
==
2
)
{
if
(
argArrayLength
==
2
)
{
song
=
strtol
(
argArray
[
1
],
&
test
,
10
);
song
=
strtol
(
argArray
[
1
],
&
test
,
10
);
if
(
*
test
!=
'\0'
)
{
if
(
*
test
!=
'\0'
)
{
myfprintf
(
fp
,
"%s need a positive integer
\n
"
,
COMMAND_RESPOND_ERROR
);
commandError
(
fp
,
"%s need a positive integer"
);
return
-
1
;
return
-
1
;
}
}
}
}
...
@@ -416,7 +415,7 @@ int handleVolume(FILE * fp, unsigned int * permission, int argArrayLength,
...
@@ -416,7 +415,7 @@ int handleVolume(FILE * fp, unsigned int * permission, int argArrayLength,
change
=
strtol
(
argArray
[
1
],
&
test
,
10
);
change
=
strtol
(
argArray
[
1
],
&
test
,
10
);
if
(
*
test
!=
'\0'
)
{
if
(
*
test
!=
'\0'
)
{
myfprintf
(
fp
,
"%s need an integer
\n
"
,
COMMAND_RESPOND_ERROR
);
commandError
(
fp
,
"need an integer"
);
return
-
1
;
return
-
1
;
}
}
return
changeVolumeLevel
(
fp
,
change
,
1
);
return
changeVolumeLevel
(
fp
,
change
,
1
);
...
@@ -430,7 +429,7 @@ int handleSetVol(FILE * fp, unsigned int * permission, int argArrayLength,
...
@@ -430,7 +429,7 @@ int handleSetVol(FILE * fp, unsigned int * permission, int argArrayLength,
level
=
strtol
(
argArray
[
1
],
&
test
,
10
);
level
=
strtol
(
argArray
[
1
],
&
test
,
10
);
if
(
*
test
!=
'\0'
)
{
if
(
*
test
!=
'\0'
)
{
myfprintf
(
fp
,
"%s need an integer
\n
"
,
COMMAND_RESPOND_ERROR
);
commandError
(
fp
,
"need an integer"
);
return
-
1
;
return
-
1
;
}
}
return
changeVolumeLevel
(
fp
,
level
,
0
);
return
changeVolumeLevel
(
fp
,
level
,
0
);
...
@@ -444,7 +443,7 @@ int handleRepeat(FILE * fp, unsigned int * permission, int argArrayLength,
...
@@ -444,7 +443,7 @@ int handleRepeat(FILE * fp, unsigned int * permission, int argArrayLength,
status
=
strtol
(
argArray
[
1
],
&
test
,
10
);
status
=
strtol
(
argArray
[
1
],
&
test
,
10
);
if
(
*
test
!=
'\0'
)
{
if
(
*
test
!=
'\0'
)
{
myfprintf
(
fp
,
"%s need an integer
\n
"
,
COMMAND_RESPOND_ERROR
);
commandError
(
fp
,
"need an integer"
);
return
-
1
;
return
-
1
;
}
}
return
setPlaylistRepeatStatus
(
fp
,
status
);
return
setPlaylistRepeatStatus
(
fp
,
status
);
...
@@ -458,7 +457,7 @@ int handleRandom(FILE * fp, unsigned int * permission, int argArrayLength,
...
@@ -458,7 +457,7 @@ int handleRandom(FILE * fp, unsigned int * permission, int argArrayLength,
status
=
strtol
(
argArray
[
1
],
&
test
,
10
);
status
=
strtol
(
argArray
[
1
],
&
test
,
10
);
if
(
*
test
!=
'\0'
)
{
if
(
*
test
!=
'\0'
)
{
myfprintf
(
fp
,
"%s need an integer
\n
"
,
COMMAND_RESPOND_ERROR
);
commandError
(
fp
,
"need an integer"
);
return
-
1
;
return
-
1
;
}
}
return
setPlaylistRandomStatus
(
fp
,
status
);
return
setPlaylistRandomStatus
(
fp
,
status
);
...
@@ -495,14 +494,12 @@ int handleMove(FILE * fp, unsigned int * permission, int argArrayLength,
...
@@ -495,14 +494,12 @@ int handleMove(FILE * fp, unsigned int * permission, int argArrayLength,
from
=
strtol
(
argArray
[
1
],
&
test
,
10
);
from
=
strtol
(
argArray
[
1
],
&
test
,
10
);
if
(
*
test
!=
'\0'
)
{
if
(
*
test
!=
'\0'
)
{
myfprintf
(
fp
,
"%s
\"
%s
\"
is not a integer
\n
"
,
commandError
(
fp
,
"
\"
%s
\"
is not a integer"
,
argArray
[
1
]);
COMMAND_RESPOND_ERROR
,
argArray
[
1
]);
return
-
1
;
return
-
1
;
}
}
to
=
strtol
(
argArray
[
2
],
&
test
,
10
);
to
=
strtol
(
argArray
[
2
],
&
test
,
10
);
if
(
*
test
!=
'\0'
)
{
if
(
*
test
!=
'\0'
)
{
myfprintf
(
fp
,
"%s
\"
%s
\"
is not a integer
\n
"
,
commandError
(
fp
,
"
\"
%s
\"
is not a integer"
,
argArray
[
2
]);
COMMAND_RESPOND_ERROR
,
argArray
[
2
]);
return
-
1
;
return
-
1
;
}
}
return
moveSongInPlaylist
(
fp
,
from
,
to
);
return
moveSongInPlaylist
(
fp
,
from
,
to
);
...
@@ -517,14 +514,12 @@ int handleSwap(FILE * fp, unsigned int * permission, int argArrayLength,
...
@@ -517,14 +514,12 @@ int handleSwap(FILE * fp, unsigned int * permission, int argArrayLength,
song1
=
strtol
(
argArray
[
1
],
&
test
,
10
);
song1
=
strtol
(
argArray
[
1
],
&
test
,
10
);
if
(
*
test
!=
'\0'
)
{
if
(
*
test
!=
'\0'
)
{
myfprintf
(
fp
,
"%s
\"
%s
\"
is not a integer
\n
"
,
commandError
(
fp
,
"
\"
%s
\"
is not a integer"
,
argArray
[
1
]);
COMMAND_RESPOND_ERROR
,
argArray
[
1
]);
return
-
1
;
return
-
1
;
}
}
song2
=
strtol
(
argArray
[
2
],
&
test
,
10
);
song2
=
strtol
(
argArray
[
2
],
&
test
,
10
);
if
(
*
test
!=
'\0'
)
{
if
(
*
test
!=
'\0'
)
{
myfprintf
(
fp
,
"%s
\"
%s
\"
is not a integer
\n
"
,
commandError
(
fp
,
"
\"
%s
\"
is not a integer"
,
argArray
[
2
]);
COMMAND_RESPOND_ERROR
,
argArray
[
2
]);
return
-
1
;
return
-
1
;
}
}
return
swapSongsInPlaylist
(
fp
,
song1
,
song2
);
return
swapSongsInPlaylist
(
fp
,
song1
,
song2
);
...
@@ -539,14 +534,12 @@ int handleSeek(FILE * fp, unsigned int * permission, int argArrayLength,
...
@@ -539,14 +534,12 @@ int handleSeek(FILE * fp, unsigned int * permission, int argArrayLength,
song
=
strtol
(
argArray
[
1
],
&
test
,
10
);
song
=
strtol
(
argArray
[
1
],
&
test
,
10
);
if
(
*
test
!=
'\0'
)
{
if
(
*
test
!=
'\0'
)
{
myfprintf
(
fp
,
"%s
\"
%s
\"
is not a integer
\n
"
,
commandError
(
fp
,
"
\"
%s
\"
is not a integer"
,
argArray
[
1
]);
COMMAND_RESPOND_ERROR
,
argArray
[
1
]);
return
-
1
;
return
-
1
;
}
}
time
=
strtol
(
argArray
[
2
],
&
test
,
10
);
time
=
strtol
(
argArray
[
2
],
&
test
,
10
);
if
(
*
test
!=
'\0'
)
{
if
(
*
test
!=
'\0'
)
{
myfprintf
(
fp
,
"%s
\"
%s
\"
is not a integer
\n
"
,
commandError
(
fp
,
"
\"
%s
\"
is not a integer"
,
argArray
[
2
]);
COMMAND_RESPOND_ERROR
,
argArray
[
2
]);
return
-
1
;
return
-
1
;
}
}
return
seekSongInPlaylist
(
fp
,
song
,
time
);
return
seekSongInPlaylist
(
fp
,
song
,
time
);
...
@@ -571,7 +564,7 @@ int handlePassword(FILE * fp, unsigned int * permission, int argArrayLength,
...
@@ -571,7 +564,7 @@ int handlePassword(FILE * fp, unsigned int * permission, int argArrayLength,
char
**
argArray
)
char
**
argArray
)
{
{
if
(
getPermissionFromPassword
(
argArray
[
1
],
permission
)
<
0
)
{
if
(
getPermissionFromPassword
(
argArray
[
1
],
permission
)
<
0
)
{
myfprintf
(
fp
,
"%s incorrect password
\n
"
,
COMMAND_RESPOND_ERROR
);
commandError
(
fp
,
"incorrect password"
);
return
-
1
;
return
-
1
;
}
}
...
@@ -586,8 +579,7 @@ int handleCrossfade(FILE * fp, unsigned int * permission, int argArrayLength,
...
@@ -586,8 +579,7 @@ int handleCrossfade(FILE * fp, unsigned int * permission, int argArrayLength,
time
=
strtol
(
argArray
[
1
],
&
test
,
10
);
time
=
strtol
(
argArray
[
1
],
&
test
,
10
);
if
(
*
test
!=
'\0'
||
time
<
0
)
{
if
(
*
test
!=
'\0'
||
time
<
0
)
{
myfprintf
(
fp
,
"%s
\"
%s
\"
is not a integer >= 0
\n
"
,
commandError
(
fp
,
"
\"
%s
\"
is not a integer >= 0"
,
argArray
[
1
]);
COMMAND_RESPOND_ERROR
,
argArray
[
1
]);
return
-
1
;
return
-
1
;
}
}
...
@@ -652,8 +644,7 @@ int checkArgcAndPermission(CommandEntry * cmd, FILE *fp,
...
@@ -652,8 +644,7 @@ int checkArgcAndPermission(CommandEntry * cmd, FILE *fp,
if
(
cmd
->
reqPermission
!=
(
permission
&
cmd
->
reqPermission
))
{
if
(
cmd
->
reqPermission
!=
(
permission
&
cmd
->
reqPermission
))
{
if
(
fp
)
{
if
(
fp
)
{
myfprintf
(
fp
,
"%s You don't have permission for "
commandError
(
fp
,
"you don't have permission for
\"
%s
\"
"
,
"
\"
%s
\"\n
"
,
COMMAND_RESPOND_ERROR
,
cmd
->
cmd
);
cmd
->
cmd
);
}
}
return
-
1
;
return
-
1
;
...
@@ -663,23 +654,22 @@ int checkArgcAndPermission(CommandEntry * cmd, FILE *fp,
...
@@ -663,23 +654,22 @@ int checkArgcAndPermission(CommandEntry * cmd, FILE *fp,
if
(
min
==
max
&&
max
!=
argc
)
{
if
(
min
==
max
&&
max
!=
argc
)
{
if
(
fp
)
{
if
(
fp
)
{
myfprintf
(
fp
,
"%s Wrong number of arguments for "
commandError
(
fp
,
"wrong number of arguments for
\"
%s
\"
"
,
"
\"
%s
\"\n
"
,
COMMAND_RESPOND_ERROR
,
argArray
[
0
]);
argArray
[
0
]);
}
}
return
-
1
;
return
-
1
;
}
}
else
if
(
argc
<
min
)
{
else
if
(
argc
<
min
)
{
if
(
fp
)
{
if
(
fp
)
{
myfprintf
(
fp
,
"%s too few arguments for
\"
%s
\"\n
"
,
commandError
(
fp
,
"too few arguments for
\"
%s
\"
"
,
COMMAND_RESPOND_ERROR
,
argArray
[
0
]);
argArray
[
0
]);
}
}
return
-
1
;
return
-
1
;
}
}
else
if
(
argc
>
max
&&
max
/* != 0 */
)
{
else
if
(
argc
>
max
&&
max
/* != 0 */
)
{
if
(
fp
)
{
if
(
fp
)
{
myfprintf
(
fp
,
"%s too many arguments for
\"
%s
\"\n
"
,
commandError
(
fp
,
"too many arguments for
\"
%s
\"
"
,
COMMAND_RESPOND_ERROR
,
argArray
[
0
]);
argArray
[
0
]);
}
}
return
-
1
;
return
-
1
;
}
}
...
@@ -694,10 +684,7 @@ CommandEntry * getCommandEntryAndCheckArgcAndPermission(FILE * fp,
...
@@ -694,10 +684,7 @@ CommandEntry * getCommandEntryAndCheckArgcAndPermission(FILE * fp,
if
(
argArrayLength
==
0
)
return
NULL
;
if
(
argArrayLength
==
0
)
return
NULL
;
if
(
!
findInList
(
commandList
,
argArray
[
0
],(
void
*
)
&
cmd
))
{
if
(
!
findInList
(
commandList
,
argArray
[
0
],(
void
*
)
&
cmd
))
{
if
(
fp
)
{
if
(
fp
)
commandError
(
fp
,
"unknown command
\"
%s
\"
"
,
argArray
[
0
]);
myfprintf
(
fp
,
"%s Unknown command
\"
%s
\"\n
"
,
COMMAND_RESPOND_ERROR
,
argArray
[
0
]);
}
return
NULL
;
return
NULL
;
}
}
...
...
src/command.h
View file @
ef6c500e
...
@@ -22,15 +22,13 @@
...
@@ -22,15 +22,13 @@
#include "../config.h"
#include "../config.h"
#include "list.h"
#include "list.h"
#include "myfprintf.h"
#include <stdio.h>
#include <stdio.h>
#define COMMAND_RETURN_KILL 10
#define COMMAND_RETURN_KILL 10
#define COMMAND_RETURN_CLOSE 20
#define COMMAND_RETURN_CLOSE 20
#define COMMAND_RESPOND_ERROR "ACK"
#define COMMAND_RESPOND_OK "OK"
int
proccessListOfCommands
(
FILE
*
fp
,
int
*
permission
,
int
*
expired
,
int
proccessListOfCommands
(
FILE
*
fp
,
int
*
permission
,
int
*
expired
,
List
*
list
);
List
*
list
);
...
@@ -40,5 +38,8 @@ void initCommands();
...
@@ -40,5 +38,8 @@ void initCommands();
void
finishCommands
();
void
finishCommands
();
#define commandSuccess(fp) myfprintf(fp, "OK\n")
#define commandError(fp, format, ... ) myfprintf(fp, "ACK " format "\n", ##__VA_ARGS__)
#endif
#endif
/* vim:set shiftwidth=4 tabstop=8 expandtab: */
src/directory.c
View file @
ef6c500e
...
@@ -166,7 +166,7 @@ void readDirectoryDBIfUpdateIsFinished() {
...
@@ -166,7 +166,7 @@ void readDirectoryDBIfUpdateIsFinished() {
int
updateInit
(
FILE
*
fp
,
List
*
pathList
)
{
int
updateInit
(
FILE
*
fp
,
List
*
pathList
)
{
if
(
directory_updatePid
>
0
)
{
if
(
directory_updatePid
>
0
)
{
myfprintf
(
fp
,
"%s already updating
\n
"
,
COMMAND_RESPOND_ERROR
);
commandError
(
fp
,
"already updating"
);
return
-
1
;
return
-
1
;
}
}
...
@@ -223,8 +223,7 @@ int updateInit(FILE * fp, List * pathList) {
...
@@ -223,8 +223,7 @@ int updateInit(FILE * fp, List * pathList) {
else
if
(
directory_updatePid
<
0
)
{
else
if
(
directory_updatePid
<
0
)
{
unblockSignals
();
unblockSignals
();
ERROR
(
"updateInit: Problems forking()'ing
\n
"
);
ERROR
(
"updateInit: Problems forking()'ing
\n
"
);
myfprintf
(
fp
,
"%s problems trying to update
\n
"
,
commandError
(
fp
,
"problems trying to update"
);
COMMAND_RESPOND_ERROR
);
directory_updatePid
=
0
;
directory_updatePid
=
0
;
return
-
1
;
return
-
1
;
}
}
...
@@ -745,7 +744,7 @@ int printDirectoryInfo(FILE * fp, char * name) {
...
@@ -745,7 +744,7 @@ int printDirectoryInfo(FILE * fp, char * name) {
Directory
*
directory
;
Directory
*
directory
;
if
((
directory
=
getDirectory
(
name
))
==
NULL
)
{
if
((
directory
=
getDirectory
(
name
))
==
NULL
)
{
myfprintf
(
fp
,
"%s: directory not found
\n
"
,
COMMAND_RESPOND_ERROR
);
commandError
(
fp
,
"directory not found"
);
return
-
1
;
return
-
1
;
}
}
...
@@ -988,13 +987,13 @@ int updateMp3Directory(FILE * fp) {
...
@@ -988,13 +987,13 @@ int updateMp3Directory(FILE * fp) {
break
;
break
;
default:
default:
ERROR
(
"problems updating music db
\n
"
);
ERROR
(
"problems updating music db
\n
"
);
myfprintf
(
fp
,
"%s problems updating music db
\n
"
,
COMMAND_RESPOND_ERROR
);
commandError
(
fp
,
"problems updating music db"
);
return
-
1
;
return
-
1
;
}
}
if
(
writeDirectoryDB
()
<
0
)
{
if
(
writeDirectoryDB
()
<
0
)
{
ERROR
(
"problems writing music db file,
\"
%s
\"\n
"
,
directory_db
);
ERROR
(
"problems writing music db file,
\"
%s
\"\n
"
,
directory_db
);
myfprintf
(
fp
,
"%s problems writing music db
\n
"
,
COMMAND_RESPOND_ERROR
);
commandError
(
fp
,
"problems writing music db"
);
return
-
1
;
return
-
1
;
}
}
...
@@ -1048,7 +1047,7 @@ int traverseAllIn(FILE * fp, char * name,
...
@@ -1048,7 +1047,7 @@ int traverseAllIn(FILE * fp, char * name,
if
((
song
=
getSongFromDB
(
name
))
&&
forEachSong
)
{
if
((
song
=
getSongFromDB
(
name
))
&&
forEachSong
)
{
return
forEachSong
(
fp
,
song
,
data
);
return
forEachSong
(
fp
,
song
,
data
);
}
}
myfprintf
(
fp
,
"%s: directory or file not found
\n
"
,
COMMAND_RESPOND_ERROR
);
commandError
(
fp
,
"directory or file not found"
);
return
-
1
;
return
-
1
;
}
}
...
@@ -1130,7 +1129,7 @@ int searchForSongsIn(FILE * fp, char * name, char * item, char * string) {
...
@@ -1130,7 +1129,7 @@ int searchForSongsIn(FILE * fp, char * name, char * item, char * string) {
ret
=
traverseAllIn
(
fp
,
name
,
searchForFilenameInDirectory
,
NULL
,
ret
=
traverseAllIn
(
fp
,
name
,
searchForFilenameInDirectory
,
NULL
,
(
void
*
)
dup
);
(
void
*
)
dup
);
}
}
else
myfprintf
(
fp
,
"%s unknown table
\n
"
,
COMMAND_RESPOND_ERROR
);
else
commandError
(
fp
,
"unknown table"
);
free
(
dup
);
free
(
dup
);
...
@@ -1167,7 +1166,7 @@ int findSongsIn(FILE * fp, char * name, char * item, char * string) {
...
@@ -1167,7 +1166,7 @@ int findSongsIn(FILE * fp, char * name, char * item, char * string) {
(
void
*
)
string
);
(
void
*
)
string
);
}
}
myfprintf
(
fp
,
"%s unknown table
\n
"
,
COMMAND_RESPOND_ERROR
);
commandError
(
fp
,
"unknown table"
);
return
-
1
;
return
-
1
;
}
}
...
...
src/interface.c
View file @
ef6c500e
...
@@ -41,7 +41,7 @@
...
@@ -41,7 +41,7 @@
#include <errno.h>
#include <errno.h>
#include <signal.h>
#include <signal.h>
#define GREETING "MPD"
#define GREETING "
OK
MPD"
#define INTERFACE_MAX_BUFFER_LENGTH MAXPATHLEN+1024
#define INTERFACE_MAX_BUFFER_LENGTH MAXPATHLEN+1024
#define INTERFACE_LIST_MODE_BEGIN "command_list_begin"
#define INTERFACE_LIST_MODE_BEGIN "command_list_begin"
...
@@ -120,8 +120,7 @@ void openInterface(Interface * interface, int fd) {
...
@@ -120,8 +120,7 @@ void openInterface(Interface * interface, int fd) {
#endif
#endif
interface
->
outBuffer
=
malloc
(
interface
->
outBufSize
);
interface
->
outBuffer
=
malloc
(
interface
->
outBufSize
);
myfprintf
(
interface
->
fp
,
"%s %s %s
\n
"
,
COMMAND_RESPOND_OK
,
GREETING
,
myfprintf
(
interface
->
fp
,
"%s %s
\n
"
,
GREETING
,
VERSION
);
VERSION
);
printInterfaceOutBuffer
(
interface
);
printInterfaceOutBuffer
(
interface
);
}
}
...
@@ -237,9 +236,7 @@ int interfaceReadInput(Interface * interface) {
...
@@ -237,9 +236,7 @@ int interfaceReadInput(Interface * interface) {
interface
->
num
,
interface
->
num
,
ret
);
ret
);
if
(
ret
==
0
)
{
if
(
ret
==
0
)
{
myfprintf
(
interface
->
fp
,
commandSuccess
(
interface
->
fp
);
"%s
\n
"
,
COMMAND_RESPOND_OK
);
}
}
else
if
(
ret
==
COMMAND_RETURN_CLOSE
||
else
if
(
ret
==
COMMAND_RETURN_CLOSE
||
interface
->
expired
)
{
interface
->
expired
)
{
...
@@ -291,7 +288,8 @@ int interfaceReadInput(Interface * interface) {
...
@@ -291,7 +288,8 @@ int interfaceReadInput(Interface * interface) {
INTERFACE_LIST_MODE_END
)
INTERFACE_LIST_MODE_END
)
==
0
)
==
0
)
{
{
myfprintf
(
interface
->
fp
,
"%s not in command list mode
\n
"
,
COMMAND_RESPOND_ERROR
);
commandError
(
interface
->
fp
,
"not in command list mode"
);
ret
=
-
1
;
ret
=
-
1
;
}
}
else
{
else
{
...
@@ -304,7 +302,7 @@ int interfaceReadInput(Interface * interface) {
...
@@ -304,7 +302,7 @@ int interfaceReadInput(Interface * interface) {
DEBUG
(
"interface %i: command returned %i
\n
"
,
interface
->
num
,
ret
);
DEBUG
(
"interface %i: command returned %i
\n
"
,
interface
->
num
,
ret
);
}
}
if
(
ret
==
0
)
{
if
(
ret
==
0
)
{
myfprintf
(
interface
->
fp
,
"%s
\n
"
,
COMMAND_RESPOND_OK
);
commandSuccess
(
interface
->
fp
);
}
}
else
if
(
ret
==
COMMAND_RETURN_CLOSE
||
else
if
(
ret
==
COMMAND_RETURN_CLOSE
||
interface
->
expired
)
{
interface
->
expired
)
{
...
...
src/player.c
View file @
ef6c500e
...
@@ -386,8 +386,7 @@ int playerSeek(FILE * fp, Song * song, float time) {
...
@@ -386,8 +386,7 @@ int playerSeek(FILE * fp, Song * song, float time) {
PlayerControl
*
pc
=
&
(
getPlayerData
()
->
playerControl
);
PlayerControl
*
pc
=
&
(
getPlayerData
()
->
playerControl
);
if
(
pc
->
state
==
PLAYER_STATE_STOP
)
{
if
(
pc
->
state
==
PLAYER_STATE_STOP
)
{
myfprintf
(
fp
,
"%s player not currently playing
\n
"
,
commandError
(
fp
,
"player not currently playing"
);
COMMAND_RESPOND_ERROR
);
return
-
1
;
return
-
1
;
}
}
...
...
src/playlist.c
View file @
ef6c500e
...
@@ -375,7 +375,7 @@ int playlistInfo(FILE * fp,int song) {
...
@@ -375,7 +375,7 @@ int playlistInfo(FILE * fp,int song) {
end
=
song
+
1
;
end
=
song
+
1
;
}
}
if
(
song
>=
playlist
.
length
)
{
if
(
song
>=
playlist
.
length
)
{
myfprintf
(
fp
,
"%s song doesn't exist
\n
"
,
COMMAND_RESPOND_ERROR
);
commandError
(
fp
,
"song doesn't exist"
);
return
-
1
;
return
-
1
;
}
}
...
@@ -486,9 +486,8 @@ int addToPlaylist(FILE * fp, char * url) {
...
@@ -486,9 +486,8 @@ int addToPlaylist(FILE * fp, char * url) {
{
{
}
}
else
{
else
{
myfprintf
(
fp
,
"%s
\"
%s
\"
is not in the music db or is"
commandError
(
fp
,
"
\"
%s
\"
is not in the music db or is"
"not a valid url
\n
"
,
"not a valid url
\n
"
,
url
);
COMMAND_RESPOND_ERROR
,
url
);
return
-
1
;
return
-
1
;
}
}
...
@@ -497,7 +496,7 @@ int addToPlaylist(FILE * fp, char * url) {
...
@@ -497,7 +496,7 @@ int addToPlaylist(FILE * fp, char * url) {
int
addSongToPlaylist
(
FILE
*
fp
,
Song
*
song
)
{
int
addSongToPlaylist
(
FILE
*
fp
,
Song
*
song
)
{
if
(
playlist
.
length
==
playlist_max_length
)
{
if
(
playlist
.
length
==
playlist_max_length
)
{
myfprintf
(
fp
,
"%s playlist is at the max size
\n
"
,
COMMAND_RESPOND_ERROR
);
commandError
(
fp
,
"playlist is at the max size"
);
return
-
1
;
return
-
1
;
}
}
...
@@ -536,13 +535,11 @@ int swapSongsInPlaylist(FILE * fp, int song1, int song2) {
...
@@ -536,13 +535,11 @@ int swapSongsInPlaylist(FILE * fp, int song1, int song2) {
int
currentSong
=
-
1
;
int
currentSong
=
-
1
;
if
(
song1
<
0
||
song1
>=
playlist
.
length
)
{
if
(
song1
<
0
||
song1
>=
playlist
.
length
)
{
myfprintf
(
fp
,
"%s
\"
%i
\"
is not in the playlist
\n
"
,
commandError
(
fp
,
"
\"
%i
\"
is not in the playlist"
,
song1
);
COMMAND_RESPOND_ERROR
,
song1
);
return
-
1
;
return
-
1
;
}
}
if
(
song2
<
0
||
song2
>=
playlist
.
length
)
{
if
(
song2
<
0
||
song2
>=
playlist
.
length
)
{
myfprintf
(
fp
,
"%s
\"
%i
\"
is not in the playlist
\n
"
,
commandError
(
fp
,
"
\"
%i
\"
is not in the playlist"
,
song2
);
COMMAND_RESPOND_ERROR
,
song2
);
return
-
1
;
return
-
1
;
}
}
...
@@ -589,11 +586,11 @@ int deleteFromPlaylist(FILE * fp, int song) {
...
@@ -589,11 +586,11 @@ int deleteFromPlaylist(FILE * fp, int song) {
int
songOrder
;
int
songOrder
;
if
(
song
<
0
)
{
if
(
song
<
0
)
{
myfprintf
(
fp
,
"%s need a positive integer
\n
"
,
COMMAND_RESPOND_ERROR
);
commandError
(
fp
,
"need a positive integer"
);
return
-
1
;
return
-
1
;
}
}
if
(
song
>=
playlist
.
length
)
{
if
(
song
>=
playlist
.
length
)
{
myfprintf
(
fp
,
"%s song doesn't exist
\n
"
,
COMMAND_RESPOND_ERROR
);
commandError
(
fp
,
"song doesn't exist"
);
return
-
1
;
return
-
1
;
}
}
...
@@ -717,17 +714,17 @@ int playPlaylist(FILE * fp, int song, int stopOnError) {
...
@@ -717,17 +714,17 @@ int playPlaylist(FILE * fp, int song, int stopOnError) {
}
}
}
}
else
if
(
song
<
0
)
{
else
if
(
song
<
0
)
{
myfprintf
(
fp
,
"%s need integer >= -1
\n
"
,
COMMAND_RESPOND_ERROR
);
commandError
(
fp
,
"need integer >= -1"
);
playlist_state
=
PLAYLIST_STATE_STOP
;
playlist_state
=
PLAYLIST_STATE_STOP
;
return
-
1
;
return
-
1
;
}
}
if
(
!
playlist
.
length
)
{
if
(
!
playlist
.
length
)
{
myfprintf
(
fp
,
"%s playlist is empty
\n
"
,
COMMAND_RESPOND_ERROR
);
commandError
(
fp
,
"playlist is empty"
);
playlist_state
=
PLAYLIST_STATE_STOP
;
playlist_state
=
PLAYLIST_STATE_STOP
;
return
-
1
;
return
-
1
;
}
}
else
if
(
song
>=
playlist
.
length
)
{
else
if
(
song
>=
playlist
.
length
)
{
myfprintf
(
fp
,
"%s song doesn't exist
\n
"
,
COMMAND_RESPOND_ERROR
);
commandError
(
fp
,
"song doesn't exist"
);
playlist_state
=
PLAYLIST_STATE_STOP
;
playlist_state
=
PLAYLIST_STATE_STOP
;
return
-
1
;
return
-
1
;
}
}
...
@@ -848,7 +845,7 @@ int getPlaylistRandomStatus() {
...
@@ -848,7 +845,7 @@ int getPlaylistRandomStatus() {
int
setPlaylistRepeatStatus
(
FILE
*
fp
,
int
status
)
{
int
setPlaylistRepeatStatus
(
FILE
*
fp
,
int
status
)
{
if
(
status
!=
0
&&
status
!=
1
)
{
if
(
status
!=
0
&&
status
!=
1
)
{
myfprintf
(
fp
,
"%s
\"
%i
\"
is not 0 or 1
\n
"
,
COMMAND_RESPOND_ERROR
,
status
);
commandError
(
fp
,
"
\"
%i
\"
is not 0 or 1"
,
status
);
return
-
1
;
return
-
1
;
}
}
...
@@ -872,14 +869,12 @@ int moveSongInPlaylist(FILE * fp, int from, int to) {
...
@@ -872,14 +869,12 @@ int moveSongInPlaylist(FILE * fp, int from, int to) {
int
currentSong
=
-
1
;
int
currentSong
=
-
1
;
if
(
from
<
0
||
from
>=
playlist
.
length
)
{
if
(
from
<
0
||
from
>=
playlist
.
length
)
{
myfprintf
(
fp
,
"%s
\"
%i
\"
is not a song in the playlist
\n
"
,
commandError
(
fp
,
"
\"
%i
\"
is not a song in the playlist"
,
from
);
COMMAND_RESPOND_ERROR
,
from
);
return
-
1
;
return
-
1
;
}
}
if
(
to
<
0
||
to
>=
playlist
.
length
)
{
if
(
to
<
0
||
to
>=
playlist
.
length
)
{
myfprintf
(
fp
,
"%s
\"
%i
\"
is not a song in the playlist
\n
"
,
commandError
(
fp
,
"
\"
%i
\"
is not a song in the playlist"
,
to
);
COMMAND_RESPOND_ERROR
,
to
);
return
-
1
;
return
-
1
;
}
}
...
@@ -985,7 +980,7 @@ int setPlaylistRandomStatus(FILE * fp, int status) {
...
@@ -985,7 +980,7 @@ int setPlaylistRandomStatus(FILE * fp, int status) {
int
statusWas
=
playlist
.
random
;
int
statusWas
=
playlist
.
random
;
if
(
status
!=
0
&&
status
!=
1
)
{
if
(
status
!=
0
&&
status
!=
1
)
{
myfprintf
(
fp
,
"%s
\"
%i
\"
is not 0 or 1
\n
"
,
COMMAND_RESPOND_ERROR
,
status
);
commandError
(
fp
,
"
\"
%i
\"
is not 0 or 1"
,
status
);
return
-
1
;
return
-
1
;
}
}
...
@@ -1079,13 +1074,12 @@ int deletePlaylist(FILE * fp, char * utf8file) {
...
@@ -1079,13 +1074,12 @@ int deletePlaylist(FILE * fp, char * utf8file) {
if
((
actualFile
=
rpp2app
(
rfile
))
&&
isPlaylist
(
actualFile
))
free
(
rfile
);
if
((
actualFile
=
rpp2app
(
rfile
))
&&
isPlaylist
(
actualFile
))
free
(
rfile
);
else
{
else
{
free
(
rfile
);
free
(
rfile
);
myfprintf
(
fp
,
"%s playlist
\"
%s
\"
not found
\n
"
,
commandError
(
fp
,
"playlist
\"
%s
\"
not found"
,
utf8file
);
COMMAND_RESPOND_ERROR
,
utf8file
);
return
-
1
;
return
-
1
;
}
}
if
(
unlink
(
actualFile
)
<
0
)
{
if
(
unlink
(
actualFile
)
<
0
)
{
myfprintf
(
fp
,
"%s problems deleting file
\n
"
,
COMMAND_RESPOND_ERROR
);
commandError
(
fp
,
"problems deleting file"
);
return
-
1
;
return
-
1
;
}
}
...
@@ -1101,9 +1095,8 @@ int savePlaylist(FILE * fp, char * utf8file) {
...
@@ -1101,9 +1095,8 @@ int savePlaylist(FILE * fp, char * utf8file) {
char
*
actualFile
;
char
*
actualFile
;
if
(
strstr
(
utf8file
,
"/"
))
{
if
(
strstr
(
utf8file
,
"/"
))
{
myfprintf
(
fp
,
"%s cannot save
\"
%s
\"
, saving playlists to "
commandError
(
fp
,
"cannot save
\"
%s
\"
, saving playlists to "
"subdirectories is not supported
\n
"
,
"subdirectories is not supported"
,
utf8file
);
COMMAND_RESPOND_ERROR
,
utf8file
);
return
-
1
;
return
-
1
;
}
}
...
@@ -1123,13 +1116,14 @@ int savePlaylist(FILE * fp, char * utf8file) {
...
@@ -1123,13 +1116,14 @@ int savePlaylist(FILE * fp, char * utf8file) {
free
(
rfile
);
free
(
rfile
);
if
(
0
==
stat
(
actualFile
,
&
st
))
{
if
(
0
==
stat
(
actualFile
,
&
st
))
{
myfprintf
(
fp
,
"%s A file or directory already exists with the name
\"
%s
\"\n
"
,
COMMAND_RESPOND_ERROR
,
utf8file
);
myfprintf
(
fp
,
"a file or directory already exists with the name"
"
\"
%s
\"
"
,
utf8file
);
return
-
1
;
return
-
1
;
}
}
while
(
!
(
fileP
=
fopen
(
actualFile
,
"w"
))
&&
errno
==
EINTR
);
while
(
!
(
fileP
=
fopen
(
actualFile
,
"w"
))
&&
errno
==
EINTR
);
if
(
fileP
==
NULL
)
{
if
(
fileP
==
NULL
)
{
myfprintf
(
fp
,
"%s Problems opening file
\n
"
,
COMMAND_RESPOND_ERROR
);
commandError
(
fp
,
"problems opening file"
);
return
-
1
;
return
-
1
;
}
}
...
@@ -1171,15 +1165,13 @@ int loadPlaylist(FILE * fp, char * utf8file) {
...
@@ -1171,15 +1165,13 @@ int loadPlaylist(FILE * fp, char * utf8file) {
if
((
actualFile
=
rpp2app
(
rfile
))
&&
isPlaylist
(
actualFile
))
free
(
rfile
);
if
((
actualFile
=
rpp2app
(
rfile
))
&&
isPlaylist
(
actualFile
))
free
(
rfile
);
else
{
else
{
free
(
rfile
);
free
(
rfile
);
myfprintf
(
fp
,
"%s playlist
\"
%s
\"
not found
\n
"
,
commandError
(
fp
,
"playlist
\"
%s
\"
not found"
,
utf8file
);
COMMAND_RESPOND_ERROR
,
utf8file
);
return
-
1
;
return
-
1
;
}
}
while
(
!
(
fileP
=
fopen
(
actualFile
,
"r"
))
&&
errno
==
EINTR
);
while
(
!
(
fileP
=
fopen
(
actualFile
,
"r"
))
&&
errno
==
EINTR
);
if
(
fileP
==
NULL
)
{
if
(
fileP
==
NULL
)
{
myfprintf
(
fp
,
"%s Problems opening file
\"
%s
\"\n
"
,
commandError
(
fp
,
"problems opening file
\"
%s
\"
"
,
utf8file
);
COMMAND_RESPOND_ERROR
,
utf8file
);
return
-
1
;
return
-
1
;
}
}
...
@@ -1197,7 +1189,8 @@ int loadPlaylist(FILE * fp, char * utf8file) {
...
@@ -1197,7 +1189,8 @@ int loadPlaylist(FILE * fp, char * utf8file) {
strncat
(
s
,
"/"
,
MAXPATHLEN
-
parentlen
);
strncat
(
s
,
"/"
,
MAXPATHLEN
-
parentlen
);
strncat
(
s
,
temp
,
MAXPATHLEN
-
parentlen
-
1
);
strncat
(
s
,
temp
,
MAXPATHLEN
-
parentlen
-
1
);
if
(
strlen
(
s
)
>=
MAXPATHLEN
)
{
if
(
strlen
(
s
)
>=
MAXPATHLEN
)
{
myfprintf
(
fp
,
"%s
\"
%s
\"
too long
\n
"
,
COMMAND_RESPOND_ERROR
,
temp
);
commandError
(
fp
,
"
\"
%s
\"
too long"
,
temp
);
free
(
temp
);
free
(
temp
);
while
(
fclose
(
fileP
)
&&
errno
==
EINTR
);
while
(
fclose
(
fileP
)
&&
errno
==
EINTR
);
if
(
erroredFile
)
free
(
erroredFile
);
if
(
erroredFile
)
free
(
erroredFile
);
...
@@ -1222,7 +1215,7 @@ int loadPlaylist(FILE * fp, char * utf8file) {
...
@@ -1222,7 +1215,7 @@ int loadPlaylist(FILE * fp, char * utf8file) {
}
}
else
if
(
slength
==
MAXPATHLEN
)
{
else
if
(
slength
==
MAXPATHLEN
)
{
s
[
slength
]
=
'\0'
;
s
[
slength
]
=
'\0'
;
myfprintf
(
fp
,
"%s
\"
%s
\"
too long
\n
"
,
COMMAND_RESPOND_ERROR
,
s
);
commandError
(
fp
,
"
\"
%s
\"
too long"
,
s
);
while
(
fclose
(
fileP
)
&&
errno
==
EINTR
);
while
(
fclose
(
fileP
)
&&
errno
==
EINTR
);
if
(
erroredFile
)
free
(
erroredFile
);
if
(
erroredFile
)
free
(
erroredFile
);
return
-
1
;
return
-
1
;
...
@@ -1233,8 +1226,7 @@ int loadPlaylist(FILE * fp, char * utf8file) {
...
@@ -1233,8 +1226,7 @@ int loadPlaylist(FILE * fp, char * utf8file) {
while
(
fclose
(
fileP
)
&&
errno
==
EINTR
);
while
(
fclose
(
fileP
)
&&
errno
==
EINTR
);
if
(
erroredFile
)
{
if
(
erroredFile
)
{
myfprintf
(
fp
,
"%s can't add file
\"
%s
\"\n
"
,
COMMAND_RESPOND_ERROR
,
commandError
(
fp
,
"can't add file
\"
%s
\"
"
,
erroredFile
);
erroredFile
);
free
(
erroredFile
);
free
(
erroredFile
);
return
-
1
;
return
-
1
;
}
}
...
@@ -1262,15 +1254,15 @@ int seekSongInPlaylist(FILE * fp, int song, float time) {
...
@@ -1262,15 +1254,15 @@ int seekSongInPlaylist(FILE * fp, int song, float time) {
int
i
=
song
;
int
i
=
song
;
if
(
song
<
0
)
{
if
(
song
<
0
)
{
myfprintf
(
fp
,
"%s need integer >= -1
\n
"
,
COMMAND_RESPOND_ERROR
);
commandError
(
fp
,
"need integer >= -1"
);
return
-
1
;
return
-
1
;
}
}
if
(
!
playlist
.
length
)
{
if
(
!
playlist
.
length
)
{
myfprintf
(
fp
,
"%s playlist is empty
\n
"
,
COMMAND_RESPOND_ERROR
);
commandError
(
fp
,
"playlist is empty"
);
return
-
1
;
return
-
1
;
}
}
else
if
(
song
>=
playlist
.
length
)
{
else
if
(
song
>=
playlist
.
length
)
{
myfprintf
(
fp
,
"%s song doesn't exist
\n
"
,
COMMAND_RESPOND_ERROR
);
commandError
(
fp
,
"song doesn't exist"
);
return
-
1
;
return
-
1
;
}
}
...
...
src/tables.c
View file @
ef6c500e
...
@@ -172,8 +172,7 @@ int printAllAlbums(FILE * fp, char * artist) {
...
@@ -172,8 +172,7 @@ int printAllAlbums(FILE * fp, char * artist) {
}
}
}
}
else
{
else
{
myfprintf
(
fp
,
"%s artist
\"
%s
\"
not found
\n
"
,
commandError
(
fp
,
"artist
\"
%s
\"
not found"
,
artist
);
COMMAND_RESPOND_ERROR
,
artist
);
return
-
1
;
return
-
1
;
}
}
}
}
...
@@ -184,7 +183,7 @@ int printAllAlbums(FILE * fp, char * artist) {
...
@@ -184,7 +183,7 @@ int printAllAlbums(FILE * fp, char * artist) {
int
printAllKeysOfTable
(
FILE
*
fp
,
char
*
table
,
char
*
arg1
)
{
int
printAllKeysOfTable
(
FILE
*
fp
,
char
*
table
,
char
*
arg1
)
{
if
(
strcmp
(
table
,
TABLES_ARTIST
)
==
0
)
{
if
(
strcmp
(
table
,
TABLES_ARTIST
)
==
0
)
{
if
(
arg1
!=
NULL
)
{
if
(
arg1
!=
NULL
)
{
myfprintf
(
fp
,
"%s %s table takes no args
\n
"
,
COMMAND_RESPOND_ERROR
,
table
);
commandError
(
fp
,
"%s table takes no args"
,
table
);
return
-
1
;
return
-
1
;
}
}
return
printAllArtists
(
fp
);
return
printAllArtists
(
fp
);
...
@@ -193,8 +192,8 @@ int printAllKeysOfTable(FILE * fp, char * table, char * arg1) {
...
@@ -193,8 +192,8 @@ int printAllKeysOfTable(FILE * fp, char * table, char * arg1) {
return
printAllAlbums
(
fp
,
arg1
);
return
printAllAlbums
(
fp
,
arg1
);
}
}
else
{
else
{
myfprintf
(
fp
,
"%s table
\"
%s
\"
does not exist or not available for listing
\n
"
,
COMMAND_RESPOND_ERROR
,
table
);
commandError
(
fp
,
"table
\"
%s
\"
does not exist or not available "
"for listing"
,
table
);
return
-
1
;
return
-
1
;
}
}
}
}
/* vim:set shiftwidth=4 tabstop=8 expandtab: */
src/volume.c
View file @
ef6c500e
...
@@ -144,8 +144,7 @@ int changeOssVolumeLevel(FILE * fp, int change, int rel) {
...
@@ -144,8 +144,7 @@ int changeOssVolumeLevel(FILE * fp, int change, int rel) {
if
(
rel
)
{
if
(
rel
)
{
if
((
current
=
getOssVolumeLevel
())
<
0
)
{
if
((
current
=
getOssVolumeLevel
())
<
0
)
{
myfprintf
(
fp
,
"%s problem getting current volume
\n
"
,
commandError
(
fp
,
"problem getting current volume"
);
COMMAND_RESPOND_ERROR
);
return
-
1
;
return
-
1
;
}
}
...
@@ -159,7 +158,7 @@ int changeOssVolumeLevel(FILE * fp, int change, int rel) {
...
@@ -159,7 +158,7 @@ int changeOssVolumeLevel(FILE * fp, int change, int rel) {
level
=
(
new
<<
8
)
+
new
;
level
=
(
new
<<
8
)
+
new
;
if
(
ioctl
(
volume_ossFd
,
MIXER_WRITE
(
volume_ossControl
),
&
level
)
<
0
)
{
if
(
ioctl
(
volume_ossFd
,
MIXER_WRITE
(
volume_ossControl
),
&
level
)
<
0
)
{
myfprintf
(
fp
,
"%s problems setting volume
\n
"
,
COMMAND_RESPOND_ERROR
);
commandError
(
fp
,
"problems setting volume"
);
return
-
1
;
return
-
1
;
}
}
...
@@ -271,8 +270,7 @@ int changeAlsaVolumeLevel(FILE * fp, int change, int rel) {
...
@@ -271,8 +270,7 @@ int changeAlsaVolumeLevel(FILE * fp, int change, int rel) {
if
((
err
=
snd_mixer_selem_get_playback_volume
(
volume_alsaElem
,
if
((
err
=
snd_mixer_selem_get_playback_volume
(
volume_alsaElem
,
SND_MIXER_SCHN_FRONT_LEFT
,
&
level
))
<
0
)
{
SND_MIXER_SCHN_FRONT_LEFT
,
&
level
))
<
0
)
{
myfprintf
(
fp
,
"%s problems getting volume
\n
"
,
commandError
(
fp
,
"problems getting volume"
);
COMMAND_RESPOND_ERROR
);
ERROR
(
"problems getting alsa volume: %s
\n
"
,
snd_strerror
(
err
));
ERROR
(
"problems getting alsa volume: %s
\n
"
,
snd_strerror
(
err
));
return
-
1
;
return
-
1
;
}
}
...
@@ -298,8 +296,7 @@ int changeAlsaVolumeLevel(FILE * fp, int change, int rel) {
...
@@ -298,8 +296,7 @@ int changeAlsaVolumeLevel(FILE * fp, int change, int rel) {
if
((
err
=
snd_mixer_selem_set_playback_volume_all
(
if
((
err
=
snd_mixer_selem_set_playback_volume_all
(
volume_alsaElem
,
level
))
<
0
)
{
volume_alsaElem
,
level
))
<
0
)
{
myfprintf
(
fp
,
"%s problems setting volume
\n
"
,
commandError
(
fp
,
"problems setting volume"
);
COMMAND_RESPOND_ERROR
);
ERROR
(
"problems setting alsa volume: %s
\n
"
,
snd_strerror
(
err
));
ERROR
(
"problems setting alsa volume: %s
\n
"
,
snd_strerror
(
err
));
return
-
1
;
return
-
1
;
}
}
...
@@ -426,7 +423,7 @@ int changeVolumeLevel(FILE * fp, int change, int rel) {
...
@@ -426,7 +423,7 @@ int changeVolumeLevel(FILE * fp, int change, int rel) {
case
VOLUME_MIXER_TYPE_SOFTWARE
:
case
VOLUME_MIXER_TYPE_SOFTWARE
:
return
changeSoftwareVolume
(
fp
,
change
,
rel
);
return
changeSoftwareVolume
(
fp
,
change
,
rel
);
default:
default:
myfprintf
(
fp
,
"%s no volume support!
\n
"
,
COMMAND_RESPOND_ERROR
);
commandError
(
fp
,
"no volume support"
);
return
-
1
;
return
-
1
;
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment