diff options
author | Max Kellermann <max@duempel.org> | 2008-10-29 22:32:50 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-10-29 22:32:50 +0100 |
commit | 7da0e005f34bd8ce305b8ece7a33a8405bbaba87 (patch) | |
tree | f363b239548d64895fcd0a5603fca951d4738eec /src/output_control.c | |
parent | 0eae1c55adefc3e7509b2ef40f4da8baa3fe24ef (diff) | |
download | mpd-7da0e005f34bd8ce305b8ece7a33a8405bbaba87.tar.gz mpd-7da0e005f34bd8ce305b8ece7a33a8405bbaba87.tar.xz mpd-7da0e005f34bd8ce305b8ece7a33a8405bbaba87.zip |
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.
Diffstat (limited to '')
-rw-r--r-- | src/output_control.c | 9 |
1 files changed, 6 insertions, 3 deletions
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); } |