aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-09-07 13:51:50 +0200
committerMax Kellermann <max@duempel.org>2008-09-07 13:51:50 +0200
commit4ddc0a48e2e53acc58990ec72e907a136e51d77e (patch)
treea92187be3b042e2a89923d767e85d5bb99b09739 /src
parentf7e414d9347aaf2397f883181c8bdb6959380143 (diff)
downloadmpd-4ddc0a48e2e53acc58990ec72e907a136e51d77e.tar.gz
mpd-4ddc0a48e2e53acc58990ec72e907a136e51d77e.tar.xz
mpd-4ddc0a48e2e53acc58990ec72e907a136e51d77e.zip
audio: don't pass "fd" to {en,dis}ableAudioDevice()
No protocol code in the audio output library.
Diffstat (limited to '')
-rw-r--r--src/audio.c17
-rw-r--r--src/audio.h4
-rw-r--r--src/command.c18
3 files changed, 21 insertions, 18 deletions
diff --git a/src/audio.c b/src/audio.c
index b539d6f7c..cea5a5a93 100644
--- a/src/audio.c
+++ b/src/audio.c
@@ -19,9 +19,7 @@
#include "audio.h"
#include "audioOutput.h"
#include "log.h"
-#include "command.h"
#include "path.h"
-#include "ack.h"
#include "myfprintf.h"
#include "os_compat.h"
@@ -428,13 +426,10 @@ void sendMetadataToAudioDevice(const struct tag *tag)
}
}
-int enableAudioDevice(int fd, unsigned int device)
+int enableAudioDevice(unsigned int device)
{
- if (device >= audioOutputArraySize) {
- commandError(fd, ACK_ERROR_ARG, "audio output device id %i "
- "doesn't exist\n", device);
+ if (device >= audioOutputArraySize)
return -1;
- }
if (!(audioDeviceStates[device] & 0x01))
audioDeviceStates[device] = DEVICE_ENABLE;
@@ -442,13 +437,11 @@ int enableAudioDevice(int fd, unsigned int device)
return 0;
}
-int disableAudioDevice(int fd, unsigned int device)
+int disableAudioDevice(unsigned int device)
{
- if (device >= audioOutputArraySize) {
- commandError(fd, ACK_ERROR_ARG, "audio output device id %i "
- "doesn't exist\n", device);
+ if (device >= audioOutputArraySize)
return -1;
- }
+
if (audioDeviceStates[device] & 0x01)
audioDeviceStates[device] = DEVICE_DISABLE;
diff --git a/src/audio.h b/src/audio.h
index 0703e402b..a261f6a1a 100644
--- a/src/audio.h
+++ b/src/audio.h
@@ -60,9 +60,9 @@ void sendMetadataToAudioDevice(const struct tag *tag);
/* these functions are called in the main parent process while the child
process is busy playing to the audio */
-int enableAudioDevice(int fd, unsigned int device);
+int enableAudioDevice(unsigned int device);
-int disableAudioDevice(int fd, unsigned int device);
+int disableAudioDevice(unsigned int device);
void printAudioDevices(int fd);
diff --git a/src/command.c b/src/command.c
index c1422d2c0..9b579e37d 100644
--- a/src/command.c
+++ b/src/command.c
@@ -1177,21 +1177,31 @@ static int handleCrossfade(int fd, mpd_unused int *permission,
static int handleEnableDevice(int fd, mpd_unused int *permission,
mpd_unused int argc, char *argv[])
{
- int device;
+ int device, ret;
if (check_int(fd, &device, argv[1], check_non_negative, argv[1]) < 0)
return -1;
- return enableAudioDevice(fd, device);
+
+ ret = enableAudioDevice(device);
+ if (ret == -1)
+ commandError(fd, ACK_ERROR_NO_EXIST, "No such audio output");
+
+ return ret;
}
static int handleDisableDevice(int fd, mpd_unused int *permission,
mpd_unused int argc, char *argv[])
{
- int device;
+ int device, ret;
if (check_int(fd, &device, argv[1], check_non_negative, argv[1]) < 0)
return -1;
- return disableAudioDevice(fd, device);
+
+ ret = disableAudioDevice(device);
+ if (ret == -1)
+ commandError(fd, ACK_ERROR_NO_EXIST, "No such audio output");
+
+ return ret;
}
static int handleDevices(int fd, mpd_unused int *permission,