diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/audio.h | 6 | ||||
-rw-r--r-- | src/audioOutputs/audioOutput_shout.c | 8 | ||||
-rw-r--r-- | src/command.c | 36 |
3 files changed, 49 insertions, 1 deletions
diff --git a/src/audio.h b/src/audio.h index 73ad73336..791b7889f 100644 --- a/src/audio.h +++ b/src/audio.h @@ -65,4 +65,10 @@ int isCurrentAudioFormat(AudioFormat * audioFormat); void sendMetadataToAudioDevice(MpdTag * tag); +/* these functions are called in the main parent process while the child + process is busy playing to the audio */ +int enableAudioDevice(FILE * fp, int device); + +int disableAudioDevice(FILE * fp, int device); + #endif diff --git a/src/audioOutputs/audioOutput_shout.c b/src/audioOutputs/audioOutput_shout.c index 12ef8c968..414fcdfde 100644 --- a/src/audioOutputs/audioOutput_shout.c +++ b/src/audioOutputs/audioOutput_shout.c @@ -289,6 +289,10 @@ static void myShout_finishDriver(AudioOutput * audioOutput) { } static void myShout_closeDevice(AudioOutput * audioOutput) { + ShoutData * sd = (ShoutData *)audioOutput->data; + + myShout_closeShoutConn(sd); + audioOutput->open = 0; } @@ -376,7 +380,9 @@ static int myShout_openShoutConn(AudioOutput * audioOutput) { ShoutData * sd = (ShoutData *)audioOutput->data; time_t t = time(NULL); - if(t - sd->lastAttempt < CONN_ATTEMPT_INTERVAL) { + if(sd->connAttempts!= 0 && + (t - sd->lastAttempt) < CONN_ATTEMPT_INTERVAL) + { return -1; } diff --git a/src/command.c b/src/command.c index 2155485a1..a98c1cf1f 100644 --- a/src/command.c +++ b/src/command.c @@ -82,6 +82,8 @@ #define COMMAND_URL_HANDLERS "urlhandlers" #define COMMAND_PLCHANGES "plchanges" #define COMMAND_CURRENTSONG "currentsong" +#define COMMAND_ENABLE_DEV "enable_device" +#define COMMAND_DISABLE_DEV "disable_device" #define COMMAND_STATUS_VOLUME "volume" #define COMMAND_STATUS_STATE "state" @@ -756,6 +758,38 @@ int handleCrossfade(FILE * fp, unsigned int * permission, int argArrayLength, return 0; } +int handleEnableDevice(FILE * fp, unsigned int * permission, int argArrayLength, + char ** argArray) +{ + int device; + char * test; + + device = strtol(argArray[1],&test,10); + if(*test!='\0' || device<0) { + commandError(fp, ACK_ERROR_ARG, + "\"%s\" is not a integer >= 0", argArray[1]); + return -1; + } + + return enableAudioDevice(fp, device); +} + +int handleDisableDevice(FILE * fp, unsigned int * permission, + int argArrayLength, char ** argArray) +{ + int device; + char * test; + + device = strtol(argArray[1],&test,10); + if(*test!='\0' || device<0) { + commandError(fp, ACK_ERROR_ARG, + "\"%s\" is not a integer >= 0", argArray[1]); + return -1; + } + + return disableAudioDevice(fp, device); +} + void initCommands() { commandList = makeList(free); @@ -804,6 +838,8 @@ void initCommands() { addCommand(COMMAND_CROSSFADE ,PERMISSION_CONTROL, 1, 1,handleCrossfade,NULL); addCommand(COMMAND_URL_HANDLERS,PERMISSION_READ, 0, 0,handleUrlHandlers,NULL); addCommand(COMMAND_PLCHANGES ,PERMISSION_READ, 1, 1,handlePlaylistChanges,NULL); + addCommand(COMMAND_ENABLE_DEV ,PERMISSION_ADMIN, 1, 1,handleEnableDevice,NULL); + addCommand(COMMAND_DISABLE_DEV ,PERMISSION_ADMIN, 1, 1,handleDisableDevice,NULL); sortList(commandList); } |