output: convert audio_output.config_audio_format to boolean
The config_audio_format used to contain the configured audio format, which is copied to out_audio_format. Let's convert the former to a boolean, which indicates whether out_audio_format was already set. This simplifies some code and saves a few bytes.
This commit is contained in:
parent
67e65a7959
commit
e6c753a474
@ -78,16 +78,12 @@ audio_output_open(struct audio_output *ao,
|
|||||||
ao->in_audio_format = *audio_format;
|
ao->in_audio_format = *audio_format;
|
||||||
ao->chunk = NULL;
|
ao->chunk = NULL;
|
||||||
|
|
||||||
if (audio_format_defined(&ao->config_audio_format)) {
|
if (!ao->config_audio_format) {
|
||||||
/* copy config_audio_format to out_audio_format only if the
|
/* no audio format is configured: copy in->out, let
|
||||||
device is not yet open; if it is already open,
|
the output's open() method determine the effective
|
||||||
plugin->open() may have modified out_audio_format,
|
out_audio_format */
|
||||||
and the value is already ok */
|
|
||||||
if (!ao->open)
|
|
||||||
ao->out_audio_format =
|
|
||||||
ao->config_audio_format;
|
|
||||||
} else {
|
|
||||||
ao->out_audio_format = ao->in_audio_format;
|
ao->out_audio_format = ao->in_audio_format;
|
||||||
|
|
||||||
if (ao->open)
|
if (ao->open)
|
||||||
audio_output_close(ao);
|
audio_output_close(ao);
|
||||||
}
|
}
|
||||||
|
@ -112,15 +112,15 @@ audio_output_init(struct audio_output *ao, const struct config_param *param,
|
|||||||
|
|
||||||
pcm_convert_init(&ao->convert_state);
|
pcm_convert_init(&ao->convert_state);
|
||||||
|
|
||||||
if (format) {
|
ao->config_audio_format = format != NULL;
|
||||||
|
if (ao->config_audio_format) {
|
||||||
bool ret;
|
bool ret;
|
||||||
|
|
||||||
ret = audio_format_parse(&ao->config_audio_format, format,
|
ret = audio_format_parse(&ao->out_audio_format, format,
|
||||||
error);
|
error);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return false;
|
return false;
|
||||||
} else
|
}
|
||||||
audio_format_clear(&ao->config_audio_format);
|
|
||||||
|
|
||||||
ao->thread = NULL;
|
ao->thread = NULL;
|
||||||
notify_init(&ao->notify);
|
notify_init(&ao->notify);
|
||||||
@ -128,7 +128,8 @@ audio_output_init(struct audio_output *ao, const struct config_param *param,
|
|||||||
ao->mutex = g_mutex_new();
|
ao->mutex = g_mutex_new();
|
||||||
|
|
||||||
ao->data = ao_plugin_init(plugin,
|
ao->data = ao_plugin_init(plugin,
|
||||||
format ? &ao->config_audio_format : NULL,
|
ao->config_audio_format
|
||||||
|
? &ao->out_audio_format : NULL,
|
||||||
param, error);
|
param, error);
|
||||||
if (ao->data == NULL)
|
if (ao->data == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
@ -52,6 +52,12 @@ struct audio_output {
|
|||||||
*/
|
*/
|
||||||
void *data;
|
void *data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This flag is true, when the audio_format of this device is
|
||||||
|
* configured in mpd.conf.
|
||||||
|
*/
|
||||||
|
bool config_audio_format;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Has the user enabled this device?
|
* Has the user enabled this device?
|
||||||
*/
|
*/
|
||||||
@ -83,12 +89,6 @@ struct audio_output {
|
|||||||
*/
|
*/
|
||||||
struct audio_format out_audio_format;
|
struct audio_format out_audio_format;
|
||||||
|
|
||||||
/**
|
|
||||||
* The audio_format which was configured. Only set if
|
|
||||||
* convertAudioFormat is true.
|
|
||||||
*/
|
|
||||||
struct audio_format config_audio_format;
|
|
||||||
|
|
||||||
struct pcm_convert_state convert_state;
|
struct pcm_convert_state convert_state;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user