audio: don't pass "fd" to {en,dis}ableAudioDevice()

No protocol code in the audio output library.
This commit is contained in:
Max Kellermann 2008-09-07 13:51:50 +02:00
parent f7e414d934
commit 4ddc0a48e2
3 changed files with 21 additions and 18 deletions

View File

@ -19,9 +19,7 @@
#include "audio.h" #include "audio.h"
#include "audioOutput.h" #include "audioOutput.h"
#include "log.h" #include "log.h"
#include "command.h"
#include "path.h" #include "path.h"
#include "ack.h"
#include "myfprintf.h" #include "myfprintf.h"
#include "os_compat.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) { if (device >= audioOutputArraySize)
commandError(fd, ACK_ERROR_ARG, "audio output device id %i "
"doesn't exist\n", device);
return -1; return -1;
}
if (!(audioDeviceStates[device] & 0x01)) if (!(audioDeviceStates[device] & 0x01))
audioDeviceStates[device] = DEVICE_ENABLE; audioDeviceStates[device] = DEVICE_ENABLE;
@ -442,13 +437,11 @@ int enableAudioDevice(int fd, unsigned int device)
return 0; return 0;
} }
int disableAudioDevice(int fd, unsigned int device) int disableAudioDevice(unsigned int device)
{ {
if (device >= audioOutputArraySize) { if (device >= audioOutputArraySize)
commandError(fd, ACK_ERROR_ARG, "audio output device id %i "
"doesn't exist\n", device);
return -1; return -1;
}
if (audioDeviceStates[device] & 0x01) if (audioDeviceStates[device] & 0x01)
audioDeviceStates[device] = DEVICE_DISABLE; audioDeviceStates[device] = DEVICE_DISABLE;

View File

@ -60,9 +60,9 @@ void sendMetadataToAudioDevice(const struct tag *tag);
/* these functions are called in the main parent process while the child /* these functions are called in the main parent process while the child
process is busy playing to the audio */ 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); void printAudioDevices(int fd);

View File

@ -1177,21 +1177,31 @@ static int handleCrossfade(int fd, mpd_unused int *permission,
static int handleEnableDevice(int fd, mpd_unused int *permission, static int handleEnableDevice(int fd, mpd_unused int *permission,
mpd_unused int argc, char *argv[]) mpd_unused int argc, char *argv[])
{ {
int device; int device, ret;
if (check_int(fd, &device, argv[1], check_non_negative, argv[1]) < 0) if (check_int(fd, &device, argv[1], check_non_negative, argv[1]) < 0)
return -1; 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, static int handleDisableDevice(int fd, mpd_unused int *permission,
mpd_unused int argc, char *argv[]) mpd_unused int argc, char *argv[])
{ {
int device; int device, ret;
if (check_int(fd, &device, argv[1], check_non_negative, argv[1]) < 0) if (check_int(fd, &device, argv[1], check_non_negative, argv[1]) < 0)
return -1; 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, static int handleDevices(int fd, mpd_unused int *permission,