From 7da0e005f34bd8ce305b8ece7a33a8405bbaba87 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 29 Oct 2008 22:32:50 +0100 Subject: output: delay reopen after device failure When one of several output devices failed, MPD tried to reopen it quite often, wasting a lot of resources. This patch adds a delay: wait 10 seconds before retrying. This might be changed to exponential delays later, but for now, it makes the problem go away. --- src/output_control.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/output_control.c') diff --git a/src/output_control.c b/src/output_control.c index 142ac765e..c4c9510dc 100644 --- a/src/output_control.c +++ b/src/output_control.c @@ -57,6 +57,8 @@ audio_output_open(struct audio_output *audioOutput, { bool ret = true; + audioOutput->reopen_after = 0; + if (audioOutput->open && audio_format_equals(audioFormat, &audioOutput->inAudioFormat)) { return true; @@ -93,9 +95,10 @@ void audio_output_update(struct audio_output *ao, const struct audio_format *audio_format) { - if (ao->enabled) - audio_output_open(ao, audio_format); - else if (audio_output_is_open(ao)) + if (ao->enabled) { + if (ao->reopen_after == 0 || time(NULL) > ao->reopen_after) + audio_output_open(ao, audio_format); + } else if (audio_output_is_open(ao)) audio_output_close(ao); } -- cgit v1.2.3