remove audioDeviceStates from playerData and getPlayerData
git-svn-id: https://svn.musicpd.org/mpd/trunk@7372 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
parent
6ac1d797af
commit
f57be50d73
22
src/audio.c
22
src/audio.c
@ -37,14 +37,16 @@ static AudioFormat *audio_configFormat;
|
|||||||
static AudioOutput *audioOutputArray;
|
static AudioOutput *audioOutputArray;
|
||||||
static unsigned int audioOutputArraySize;
|
static unsigned int audioOutputArraySize;
|
||||||
|
|
||||||
#define DEVICE_OFF 0x00
|
enum ad_state {
|
||||||
#define DEVICE_ENABLE 0x01 /* currently off, but to be turned on */
|
DEVICE_OFF = 0x00,
|
||||||
#define DEVICE_ON 0x03
|
DEVICE_ENABLE = 0x01, /* currently off, but to be turned on */
|
||||||
#define DEVICE_DISABLE 0x04 /* currently on, but to be turned off */
|
DEVICE_ON = 0x03,
|
||||||
|
DEVICE_DISABLE = 0x04 /* currently on, but to be turned off */
|
||||||
|
};
|
||||||
|
|
||||||
/* the audioEnabledArray should be stuck into shared memory, and then disable
|
/* the audioEnabledArray should be stuck into shared memory, and then disable
|
||||||
and enable in playAudio() routine */
|
and enable in playAudio() routine */
|
||||||
static mpd_uint8 *audioDeviceStates;
|
static enum ad_state *audioDeviceStates;
|
||||||
|
|
||||||
static mpd_uint8 audioOpened;
|
static mpd_uint8 audioOpened;
|
||||||
|
|
||||||
@ -52,7 +54,7 @@ static size_t audioBufferSize;
|
|||||||
static char *audioBuffer;
|
static char *audioBuffer;
|
||||||
static size_t audioBufferPos;
|
static size_t audioBufferPos;
|
||||||
|
|
||||||
unsigned int audio_device_count(void)
|
static unsigned int audio_output_count(void)
|
||||||
{
|
{
|
||||||
unsigned int nr = 0;
|
unsigned int nr = 0;
|
||||||
ConfigParam *param = NULL;
|
ConfigParam *param = NULL;
|
||||||
@ -103,8 +105,9 @@ void initAudioDriver(void)
|
|||||||
|
|
||||||
loadAudioDrivers();
|
loadAudioDrivers();
|
||||||
|
|
||||||
audioOutputArraySize = audio_device_count();
|
audioOutputArraySize = audio_output_count();
|
||||||
audioDeviceStates = (getPlayerData())->audioDeviceStates;
|
audioDeviceStates = xmalloc(sizeof(enum ad_state) *
|
||||||
|
audioOutputArraySize);
|
||||||
audioOutputArray = xmalloc(sizeof(AudioOutput) * audioOutputArraySize);
|
audioOutputArray = xmalloc(sizeof(AudioOutput) * audioOutputArraySize);
|
||||||
|
|
||||||
for (i = 0; i < audioOutputArraySize; i++)
|
for (i = 0; i < audioOutputArraySize; i++)
|
||||||
@ -273,6 +276,8 @@ static void syncAudioDeviceStates(void)
|
|||||||
for (i = 0; i < audioOutputArraySize; ++i) {
|
for (i = 0; i < audioOutputArraySize; ++i) {
|
||||||
audioOutput = &audioOutputArray[i];
|
audioOutput = &audioOutputArray[i];
|
||||||
switch (audioDeviceStates[i]) {
|
switch (audioDeviceStates[i]) {
|
||||||
|
case DEVICE_OFF:
|
||||||
|
break;
|
||||||
case DEVICE_ON:
|
case DEVICE_ON:
|
||||||
/* This will reopen only if the audio format changed */
|
/* This will reopen only if the audio format changed */
|
||||||
if (openAudioOutput(audioOutput, &audio_format) < 0)
|
if (openAudioOutput(audioOutput, &audio_format) < 0)
|
||||||
@ -286,7 +291,6 @@ static void syncAudioDeviceStates(void)
|
|||||||
dropBufferedAudioOutput(audioOutput);
|
dropBufferedAudioOutput(audioOutput);
|
||||||
closeAudioOutput(audioOutput);
|
closeAudioOutput(audioOutput);
|
||||||
audioDeviceStates[i] = DEVICE_OFF;
|
audioDeviceStates[i] = DEVICE_OFF;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,8 +31,6 @@ typedef struct _AudioFormat {
|
|||||||
volatile mpd_sint8 bits;
|
volatile mpd_sint8 bits;
|
||||||
} AudioFormat;
|
} AudioFormat;
|
||||||
|
|
||||||
unsigned int audio_device_count(void);
|
|
||||||
|
|
||||||
static inline double audioFormatSizeToTime(const AudioFormat * af)
|
static inline double audioFormatSizeToTime(const AudioFormat * af)
|
||||||
{
|
{
|
||||||
return 8.0 / af->bits / af->channels / af->sampleRate;
|
return 8.0 / af->bits / af->channels / af->sampleRate;
|
||||||
|
@ -464,7 +464,6 @@ int main(int argc, char *argv[])
|
|||||||
finishInputPlugins();
|
finishInputPlugins();
|
||||||
cleanUpPidFile();
|
cleanUpPidFile();
|
||||||
finishConf();
|
finishConf();
|
||||||
freePlayerData();
|
|
||||||
|
|
||||||
close_log_files();
|
close_log_files();
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
@ -21,12 +21,10 @@
|
|||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
unsigned int buffered_before_play;
|
|
||||||
|
|
||||||
#define DEFAULT_BUFFER_SIZE 2048
|
#define DEFAULT_BUFFER_SIZE 2048
|
||||||
#define DEFAULT_BUFFER_BEFORE_PLAY 10
|
#define DEFAULT_BUFFER_BEFORE_PLAY 10
|
||||||
|
|
||||||
static PlayerData playerData_pd;
|
unsigned int buffered_before_play;
|
||||||
PlayerControl pc;
|
PlayerControl pc;
|
||||||
DecoderControl dc;
|
DecoderControl dc;
|
||||||
OutputBuffer ob;
|
OutputBuffer ob;
|
||||||
@ -39,7 +37,6 @@ void initPlayerData(void)
|
|||||||
size_t bufferSize = DEFAULT_BUFFER_SIZE;
|
size_t bufferSize = DEFAULT_BUFFER_SIZE;
|
||||||
unsigned int buffered_chunks;
|
unsigned int buffered_chunks;
|
||||||
ConfigParam *param;
|
ConfigParam *param;
|
||||||
size_t device_array_size = audio_device_count() * sizeof(mpd_sint8);
|
|
||||||
|
|
||||||
param = getConfigParam(CONF_AUDIO_BUFFER_SIZE);
|
param = getConfigParam(CONF_AUDIO_BUFFER_SIZE);
|
||||||
|
|
||||||
@ -75,8 +72,6 @@ void initPlayerData(void)
|
|||||||
buffered_before_play = buffered_chunks;
|
buffered_before_play = buffered_chunks;
|
||||||
}
|
}
|
||||||
|
|
||||||
playerData_pd.audioDeviceStates = xmalloc(device_array_size);
|
|
||||||
|
|
||||||
ob_init(buffered_chunks);
|
ob_init(buffered_chunks);
|
||||||
|
|
||||||
notify_init(&pc.notify);
|
notify_init(&pc.notify);
|
||||||
@ -92,18 +87,4 @@ void initPlayerData(void)
|
|||||||
dc.error = DECODE_ERROR_NOERROR;
|
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);
|
|
||||||
}
|
|
||||||
|
@ -30,14 +30,6 @@ extern PlayerControl pc;
|
|||||||
extern DecoderControl dc;
|
extern DecoderControl dc;
|
||||||
extern OutputBuffer ob;
|
extern OutputBuffer ob;
|
||||||
|
|
||||||
typedef struct _PlayerData {
|
|
||||||
mpd_uint8 *audioDeviceStates;
|
|
||||||
} PlayerData;
|
|
||||||
|
|
||||||
void initPlayerData(void);
|
void initPlayerData(void);
|
||||||
|
|
||||||
PlayerData *getPlayerData(void);
|
|
||||||
|
|
||||||
void freePlayerData(void);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user