audio: renamed the audio_format variables
Renamed audio_configFormat to configured_audio_format. Renamed audio_buffer.format to input_audio_format. Simplified its initialization in openAudioDevice().
This commit is contained in:
parent
336b193097
commit
80a2c937c4
30
src/audio.c
30
src/audio.c
@ -30,7 +30,8 @@
|
|||||||
#define AUDIO_DEVICE_STATE "audio_device_state:"
|
#define AUDIO_DEVICE_STATE "audio_device_state:"
|
||||||
#define AUDIO_BUFFER_SIZE 2*MPD_PATH_MAX
|
#define AUDIO_BUFFER_SIZE 2*MPD_PATH_MAX
|
||||||
|
|
||||||
static struct audio_format audio_configFormat;
|
static struct audio_format configured_audio_format;
|
||||||
|
static struct audio_format input_audio_format;
|
||||||
|
|
||||||
static struct audio_output *audioOutputArray;
|
static struct audio_output *audioOutputArray;
|
||||||
static unsigned int audioOutputArraySize;
|
static unsigned int audioOutputArraySize;
|
||||||
@ -43,10 +44,6 @@ static bool *audioDeviceStates;
|
|||||||
|
|
||||||
static uint8_t audioOpened;
|
static uint8_t audioOpened;
|
||||||
|
|
||||||
static struct {
|
|
||||||
struct audio_format format;
|
|
||||||
} audio_buffer;
|
|
||||||
|
|
||||||
static unsigned int audio_output_count(void)
|
static unsigned int audio_output_count(void)
|
||||||
{
|
{
|
||||||
unsigned int nr = 0;
|
unsigned int nr = 0;
|
||||||
@ -107,8 +104,8 @@ void initAudioDriver(void)
|
|||||||
void getOutputAudioFormat(const struct audio_format *inAudioFormat,
|
void getOutputAudioFormat(const struct audio_format *inAudioFormat,
|
||||||
struct audio_format *outAudioFormat)
|
struct audio_format *outAudioFormat)
|
||||||
{
|
{
|
||||||
*outAudioFormat = audio_format_defined(&audio_configFormat)
|
*outAudioFormat = audio_format_defined(&configured_audio_format)
|
||||||
? audio_configFormat
|
? configured_audio_format
|
||||||
: *inAudioFormat;
|
: *inAudioFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,7 +116,7 @@ void initAudioConfig(void)
|
|||||||
if (NULL == param || NULL == param->value)
|
if (NULL == param || NULL == param->value)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (0 != parseAudioConfig(&audio_configFormat, param->value)) {
|
if (0 != parseAudioConfig(&configured_audio_format, param->value)) {
|
||||||
FATAL("error parsing \"%s\" at line %i\n",
|
FATAL("error parsing \"%s\" at line %i\n",
|
||||||
CONF_AUDIO_OUTPUT_FORMAT, param->line);
|
CONF_AUDIO_OUTPUT_FORMAT, param->line);
|
||||||
}
|
}
|
||||||
@ -182,7 +179,7 @@ int parseAudioConfig(struct audio_format *audioFormat, char *conf)
|
|||||||
|
|
||||||
void finishAudioConfig(void)
|
void finishAudioConfig(void)
|
||||||
{
|
{
|
||||||
audio_format_clear(&audio_configFormat);
|
audio_format_clear(&configured_audio_format);
|
||||||
}
|
}
|
||||||
|
|
||||||
void finishAudioDriver(void)
|
void finishAudioDriver(void)
|
||||||
@ -203,7 +200,7 @@ isCurrentAudioFormat(const struct audio_format *audioFormat)
|
|||||||
{
|
{
|
||||||
assert(audioFormat != NULL);
|
assert(audioFormat != NULL);
|
||||||
|
|
||||||
return audio_format_equals(audioFormat, &audio_buffer.format);
|
return audio_format_equals(audioFormat, &input_audio_format);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void audio_output_wait(struct audio_output *ao)
|
static void audio_output_wait(struct audio_output *ao)
|
||||||
@ -236,13 +233,13 @@ static void syncAudioDeviceStates(void)
|
|||||||
struct audio_output *audioOutput;
|
struct audio_output *audioOutput;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
if (!audio_format_defined(&audio_buffer.format))
|
if (!audio_format_defined(&input_audio_format))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 0; i < audioOutputArraySize; ++i) {
|
for (i = 0; i < audioOutputArraySize; ++i) {
|
||||||
audioOutput = &audioOutputArray[i];
|
audioOutput = &audioOutputArray[i];
|
||||||
if (audioDeviceStates[i])
|
if (audioDeviceStates[i])
|
||||||
audio_output_open(audioOutput, &audio_buffer.format);
|
audio_output_open(audioOutput, &input_audio_format);
|
||||||
else if (audio_output_is_open(audioOutput)) {
|
else if (audio_output_is_open(audioOutput)) {
|
||||||
audio_output_cancel(audioOutput);
|
audio_output_cancel(audioOutput);
|
||||||
audio_output_wait(audioOutput);
|
audio_output_wait(audioOutput);
|
||||||
@ -304,11 +301,10 @@ int openAudioDevice(const struct audio_format *audioFormat)
|
|||||||
if (!audioOutputArray)
|
if (!audioOutputArray)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!audioOpened ||
|
if (audioFormat == NULL)
|
||||||
(audioFormat != NULL && !isCurrentAudioFormat(audioFormat))) {
|
audio_format_clear(&input_audio_format);
|
||||||
if (audioFormat != NULL)
|
else
|
||||||
audio_buffer.format = *audioFormat;
|
input_audio_format = *audioFormat;
|
||||||
}
|
|
||||||
|
|
||||||
syncAudioDeviceStates();
|
syncAudioDeviceStates();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user