diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/audio.c | 22 | ||||
-rw-r--r-- | src/audio.h | 2 | ||||
-rw-r--r-- | src/main.c | 1 | ||||
-rw-r--r-- | src/playerData.c | 21 | ||||
-rw-r--r-- | src/playerData.h | 8 |
5 files changed, 14 insertions, 40 deletions
diff --git a/src/audio.c b/src/audio.c index 3c5ef4478..50b54cb7d 100644 --- a/src/audio.c +++ b/src/audio.c @@ -37,14 +37,16 @@ static AudioFormat *audio_configFormat; static AudioOutput *audioOutputArray; static unsigned int audioOutputArraySize; -#define DEVICE_OFF 0x00 -#define DEVICE_ENABLE 0x01 /* currently off, but to be turned on */ -#define DEVICE_ON 0x03 -#define DEVICE_DISABLE 0x04 /* currently on, but to be turned off */ +enum ad_state { + DEVICE_OFF = 0x00, + DEVICE_ENABLE = 0x01, /* currently off, but to be turned on */ + DEVICE_ON = 0x03, + DEVICE_DISABLE = 0x04 /* currently on, but to be turned off */ +}; /* the audioEnabledArray should be stuck into shared memory, and then disable and enable in playAudio() routine */ -static mpd_uint8 *audioDeviceStates; +static enum ad_state *audioDeviceStates; static mpd_uint8 audioOpened; @@ -52,7 +54,7 @@ static size_t audioBufferSize; static char *audioBuffer; static size_t audioBufferPos; -unsigned int audio_device_count(void) +static unsigned int audio_output_count(void) { unsigned int nr = 0; ConfigParam *param = NULL; @@ -103,8 +105,9 @@ void initAudioDriver(void) loadAudioDrivers(); - audioOutputArraySize = audio_device_count(); - audioDeviceStates = (getPlayerData())->audioDeviceStates; + audioOutputArraySize = audio_output_count(); + audioDeviceStates = xmalloc(sizeof(enum ad_state) * + audioOutputArraySize); audioOutputArray = xmalloc(sizeof(AudioOutput) * audioOutputArraySize); for (i = 0; i < audioOutputArraySize; i++) @@ -273,6 +276,8 @@ static void syncAudioDeviceStates(void) for (i = 0; i < audioOutputArraySize; ++i) { audioOutput = &audioOutputArray[i]; switch (audioDeviceStates[i]) { + case DEVICE_OFF: + break; case DEVICE_ON: /* This will reopen only if the audio format changed */ if (openAudioOutput(audioOutput, &audio_format) < 0) @@ -286,7 +291,6 @@ static void syncAudioDeviceStates(void) dropBufferedAudioOutput(audioOutput); closeAudioOutput(audioOutput); audioDeviceStates[i] = DEVICE_OFF; - break; } } } diff --git a/src/audio.h b/src/audio.h index 71d79ec84..eab83916a 100644 --- a/src/audio.h +++ b/src/audio.h @@ -31,8 +31,6 @@ typedef struct _AudioFormat { volatile mpd_sint8 bits; } AudioFormat; -unsigned int audio_device_count(void); - static inline double audioFormatSizeToTime(const AudioFormat * af) { return 8.0 / af->bits / af->channels / af->sampleRate; diff --git a/src/main.c b/src/main.c index 6bfc22d7d..a838d0349 100644 --- a/src/main.c +++ b/src/main.c @@ -464,7 +464,6 @@ int main(int argc, char *argv[]) finishInputPlugins(); cleanUpPidFile(); finishConf(); - freePlayerData(); close_log_files(); return EXIT_SUCCESS; diff --git a/src/playerData.c b/src/playerData.c index 103ec2980..3934d0c6f 100644 --- a/src/playerData.c +++ b/src/playerData.c @@ -21,12 +21,10 @@ #include "log.h" #include "utils.h" -unsigned int buffered_before_play; - #define DEFAULT_BUFFER_SIZE 2048 #define DEFAULT_BUFFER_BEFORE_PLAY 10 -static PlayerData playerData_pd; +unsigned int buffered_before_play; PlayerControl pc; DecoderControl dc; OutputBuffer ob; @@ -39,7 +37,6 @@ void initPlayerData(void) size_t bufferSize = DEFAULT_BUFFER_SIZE; unsigned int buffered_chunks; ConfigParam *param; - size_t device_array_size = audio_device_count() * sizeof(mpd_sint8); param = getConfigParam(CONF_AUDIO_BUFFER_SIZE); @@ -75,8 +72,6 @@ void initPlayerData(void) buffered_before_play = buffered_chunks; } - playerData_pd.audioDeviceStates = xmalloc(device_array_size); - ob_init(buffered_chunks); notify_init(&pc.notify); @@ -92,18 +87,4 @@ void initPlayerData(void) dc.error = DECODE_ERROR_NOERROR; } -PlayerData *getPlayerData(void) -{ - return &playerData_pd; -} - -void freePlayerData(void) -{ - /* We don't want to release this memory until we know our player and - * decoder have exited. Otherwise, their signal handlers will want to - * access playerData_pd and we need to keep it available for them */ - waitpid(-1, NULL, 0); - ob_free(); - free(playerData_pd.audioDeviceStates); -} diff --git a/src/playerData.h b/src/playerData.h index fccc758da..cf7f72cf0 100644 --- a/src/playerData.h +++ b/src/playerData.h @@ -30,14 +30,6 @@ extern PlayerControl pc; extern DecoderControl dc; extern OutputBuffer ob; -typedef struct _PlayerData { - mpd_uint8 *audioDeviceStates; -} PlayerData; - void initPlayerData(void); -PlayerData *getPlayerData(void); - -void freePlayerData(void); - #endif |