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_thread.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 'src/output_thread.c')
-rw-r--r-- | src/output_thread.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/output_thread.c b/src/output_thread.c index 28a575a1b..5d468c573 100644 --- a/src/output_thread.c +++ b/src/output_thread.c @@ -23,6 +23,12 @@ #include <assert.h> +enum { + /** after a failure, wait this number of seconds before + automatically reopening the device */ + REOPEN_AFTER = 10, +}; + static void ao_command_finished(struct audio_output *ao) { assert(ao->command != AO_COMMAND_NONE); @@ -104,6 +110,8 @@ static void *audio_output_task(void *arg) assert(!ao->open); if (ao->result == true) ao->open = true; + else + ao->reopen_after = time(NULL) + REOPEN_AFTER; ao_command_finished(ao); break; |