aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-07-06 10:01:02 +0200
committerMax Kellermann <max@duempel.org>2009-07-06 10:01:02 +0200
commit78fa3f06f9fadcc274c0a0042d28d59c88bff152 (patch)
tree75a02c2926fb72fff0b5832dbdfd4430d8a25e87
parent1350cd0e42d1860af1149db3e3b4eb3b944779fe (diff)
downloadmpd-78fa3f06f9fadcc274c0a0042d28d59c88bff152.tar.gz
mpd-78fa3f06f9fadcc274c0a0042d28d59c88bff152.tar.xz
mpd-78fa3f06f9fadcc274c0a0042d28d59c88bff152.zip
output: added command REOPEN
REOPEN is called when the input audio format changes. The output thread may be reconfigure the PCM converter.
-rw-r--r--src/output_control.c15
-rw-r--r--src/output_internal.h7
-rw-r--r--src/output_thread.c25
3 files changed, 33 insertions, 14 deletions
diff --git a/src/output_control.c b/src/output_control.c
index eac9bdfcb..2c193c30f 100644
--- a/src/output_control.c
+++ b/src/output_control.c
@@ -82,26 +82,13 @@ audio_output_open(struct audio_output *ao,
ao->in_audio_format = *audio_format;
ao->chunk = NULL;
- if (!ao->config_audio_format) {
- if (ao->open)
- audio_output_close(ao);
-
- /* no audio format is configured: copy in->out, let
- the output's open() method determine the effective
- out_audio_format */
- ao->out_audio_format = ao->in_audio_format;
- }
-
ao->pipe = mp;
if (ao->thread == NULL)
audio_output_thread_start(ao);
+ ao_command(ao, ao->open ? AO_COMMAND_REOPEN : AO_COMMAND_OPEN);
open = ao->open;
- if (!open) {
- ao_command(ao, AO_COMMAND_OPEN);
- open = ao->open;
- }
if (open && ao->mixer != NULL)
mixer_open(ao->mixer);
diff --git a/src/output_internal.h b/src/output_internal.h
index 362d24947..5f7a24060 100644
--- a/src/output_internal.h
+++ b/src/output_internal.h
@@ -29,6 +29,13 @@
enum audio_output_command {
AO_COMMAND_NONE = 0,
AO_COMMAND_OPEN,
+
+ /**
+ * This command is invoked when the input audio format
+ * changes.
+ */
+ AO_COMMAND_REOPEN,
+
AO_COMMAND_CLOSE,
AO_COMMAND_PAUSE,
AO_COMMAND_CANCEL,
diff --git a/src/output_thread.c b/src/output_thread.c
index 6f9e9586a..b3c134413 100644
--- a/src/output_thread.c
+++ b/src/output_thread.c
@@ -105,6 +105,26 @@ ao_close(struct audio_output *ao)
g_debug("closed plugin=%s name=\"%s\"", ao->plugin->name, ao->name);
}
+static void
+ao_reopen(struct audio_output *ao)
+{
+ if (!ao->config_audio_format) {
+ if (ao->open) {
+ const struct music_pipe *mp = ao->pipe;
+ ao_close(ao);
+ ao->pipe = mp;
+ }
+
+ /* no audio format is configured: copy in->out, let
+ the output's open() method determine the effective
+ out_audio_format */
+ ao->out_audio_format = ao->in_audio_format;
+ }
+
+ if (!ao->open)
+ ao_open(ao);
+}
+
static bool
ao_play_chunk(struct audio_output *ao, const struct music_chunk *chunk)
{
@@ -237,6 +257,11 @@ static gpointer audio_output_task(gpointer arg)
ao_command_finished(ao);
break;
+ case AO_COMMAND_REOPEN:
+ ao_reopen(ao);
+ ao_command_finished(ao);
+ break;
+
case AO_COMMAND_CLOSE:
assert(ao->open);
assert(ao->pipe != NULL);