diff options
author | Max Kellermann <max@duempel.org> | 2009-10-21 22:37:28 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-10-21 22:37:28 +0200 |
commit | 2c05430002c66f69c498eec40b961d4eabef66c2 (patch) | |
tree | f7e51c0943d5df0993382315f2baada763f34083 /src/output | |
parent | 643650dba75becfe572c1b334d1276a1b3f66d41 (diff) | |
download | mpd-2c05430002c66f69c498eec40b961d4eabef66c2.tar.gz mpd-2c05430002c66f69c498eec40b961d4eabef66c2.tar.xz mpd-2c05430002c66f69c498eec40b961d4eabef66c2.zip |
output: convert config_audio_format to an audio_format struct
This allows more sophisticated audio format selection.
Diffstat (limited to '')
-rw-r--r-- | src/output_init.c | 13 | ||||
-rw-r--r-- | src/output_internal.h | 11 | ||||
-rw-r--r-- | src/output_thread.c | 6 |
3 files changed, 16 insertions, 14 deletions
diff --git a/src/output_init.c b/src/output_init.c index f394066ef..f097f2c2d 100644 --- a/src/output_init.c +++ b/src/output_init.c @@ -154,14 +154,14 @@ audio_output_init(struct audio_output *ao, const struct config_param *param, p = config_get_block_string(param, AUDIO_OUTPUT_FORMAT, NULL); - ao->config_audio_format = p != NULL; if (p != NULL) { bool success = - audio_format_parse(&ao->out_audio_format, + audio_format_parse(&ao->config_audio_format, p, error_r); if (!success) return false; - } + } else + audio_format_clear(&ao->config_audio_format); } else { g_warning("No \"%s\" defined in config file\n", CONF_AUDIO_OUTPUT); @@ -174,7 +174,8 @@ audio_output_init(struct audio_output *ao, const struct config_param *param, plugin->name); ao->name = "default detected output"; - ao->config_audio_format = false; + + audio_format_clear(&ao->config_audio_format); } ao->plugin = plugin; @@ -194,8 +195,8 @@ audio_output_init(struct audio_output *ao, const struct config_param *param, ao->mutex = g_mutex_new(); ao->data = ao_plugin_init(plugin, - ao->config_audio_format - ? &ao->out_audio_format : NULL, + audio_format_defined(&ao->config_audio_format) + ? &ao->config_audio_format : NULL, param, error_r); if (ao->data == NULL) return false; diff --git a/src/output_internal.h b/src/output_internal.h index 4eb77cc49..f27a10ec7 100644 --- a/src/output_internal.h +++ b/src/output_internal.h @@ -66,12 +66,6 @@ struct audio_output { struct mixer *mixer; /** - * 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? */ bool enabled; @@ -100,6 +94,11 @@ struct audio_output { GTimer *fail_timer; /** + * The configured audio format. + */ + struct audio_format config_audio_format; + + /** * The audio_format in which audio data is received from the * player thread (which in turn receives it from the decoder). */ diff --git a/src/output_thread.c b/src/output_thread.c index 11dea0845..dd97d88b0 100644 --- a/src/output_thread.c +++ b/src/output_thread.c @@ -67,7 +67,9 @@ ao_open(struct audio_output *ao) return; } - if (!ao->config_audio_format) + if (audio_format_defined(&ao->config_audio_format)) + ao->out_audio_format = ao->config_audio_format; + else ao->out_audio_format = *filter_audio_format; success = ao_plugin_open(ao->plugin, ao->data, @@ -164,7 +166,7 @@ ao_reopen_filter(struct audio_output *ao) static void ao_reopen(struct audio_output *ao) { - if (!ao->config_audio_format) { + if (!audio_format_defined(&ao->config_audio_format)) { if (ao->open) { const struct music_pipe *mp = ao->pipe; ao_close(ao); |