diff options
author | Max Kellermann <max@duempel.org> | 2008-10-29 20:40:33 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-10-29 20:40:33 +0100 |
commit | 2f76db4c7842ffdb989d2081b0835a83a3219f35 (patch) | |
tree | 19c7099501b78a2901a185f23dbb271d8a703f42 | |
parent | 58c5bee9f0bcb46da7d113b66a4e1e2d7add9837 (diff) | |
download | mpd-2f76db4c7842ffdb989d2081b0835a83a3219f35.tar.gz mpd-2f76db4c7842ffdb989d2081b0835a83a3219f35.tar.xz mpd-2f76db4c7842ffdb989d2081b0835a83a3219f35.zip |
output: close device on play error
When an output plugin fails to play a chunk, close it. This replaces
various manual close() calls in nearly all plugins.
Diffstat (limited to '')
-rw-r--r-- | src/output/alsa_plugin.c | 1 | ||||
-rw-r--r-- | src/output/ao_plugin.c | 1 | ||||
-rw-r--r-- | src/output/fifo_plugin.c | 1 | ||||
-rw-r--r-- | src/output/mvp_plugin.c | 1 | ||||
-rw-r--r-- | src/output/oss_plugin.c | 1 | ||||
-rw-r--r-- | src/output/shout_plugin.c | 9 | ||||
-rw-r--r-- | src/output_thread.c | 5 |
7 files changed, 7 insertions, 12 deletions
diff --git a/src/output/alsa_plugin.c b/src/output/alsa_plugin.c index 2d4f9c239..4802778dc 100644 --- a/src/output/alsa_plugin.c +++ b/src/output/alsa_plugin.c @@ -412,7 +412,6 @@ alsa_playAudio(void *data, const char *playChunk, size_t size) ERROR("closing ALSA device \"%s\" due to write " "error: %s\n", ad->device, snd_strerror(-errno)); - alsa_closeDevice(ad); return false; } continue; diff --git a/src/output/ao_plugin.c b/src/output/ao_plugin.c index d2c7dab6e..20e8cfd58 100644 --- a/src/output/ao_plugin.c +++ b/src/output/ao_plugin.c @@ -224,7 +224,6 @@ audioOutputAo_play(void *data, const char *playChunk, size_t size) if (ao_play_deconst(ad->device, playChunk, chunk_size) == 0) { audioOutputAo_error(); ERROR("closing audio device due to write error\n"); - audioOutputAo_closeDevice(ad); return false; } diff --git a/src/output/fifo_plugin.c b/src/output/fifo_plugin.c index fe85d6644..4645948e2 100644 --- a/src/output/fifo_plugin.c +++ b/src/output/fifo_plugin.c @@ -259,7 +259,6 @@ fifo_playAudio(void *data, const char *playChunk, size_t size) ERROR("Closing FIFO output \"%s\" due to write error: " "%s\n", fd->path, strerror(errno)); - fifo_closeDevice(fd); return false; } diff --git a/src/output/mvp_plugin.c b/src/output/mvp_plugin.c index 9a56e7943..61b45ba0f 100644 --- a/src/output/mvp_plugin.c +++ b/src/output/mvp_plugin.c @@ -253,7 +253,6 @@ mvp_playAudio(void *data, const char *playChunk, size_t size) continue; ERROR("closing mvp PCM device due to write error: " "%s\n", strerror(errno)); - mvp_closeDevice(md); return false; } playChunk += ret; diff --git a/src/output/oss_plugin.c b/src/output/oss_plugin.c index 26bc1b3aa..71262fefb 100644 --- a/src/output/oss_plugin.c +++ b/src/output/oss_plugin.c @@ -549,7 +549,6 @@ oss_playAudio(void *data, const char *playChunk, size_t size) continue; ERROR("closing oss device \"%s\" due to write error: " "%s\n", od->device, strerror(errno)); - oss_closeDevice(od); return false; } playChunk += ret; diff --git a/src/output/shout_plugin.c b/src/output/shout_plugin.c index 7bd806d36..00ce02590 100644 --- a/src/output/shout_plugin.c +++ b/src/output/shout_plugin.c @@ -525,7 +525,6 @@ my_shout_play(void *data, const char *chunk, size_t size) if (!sd->opened) { status = open_shout_conn(sd); if (status < 0) { - my_shout_close_device(sd); return false; } else if (status > 0) { timer_sync(sd->timer); @@ -533,15 +532,11 @@ my_shout_play(void *data, const char *chunk, size_t size) } } - if (sd->encoder->encode_func(sd, chunk, size)) { - my_shout_close_device(sd); + if (sd->encoder->encode_func(sd, chunk, size)) return false; - } - if (write_page(sd) < 0) { - my_shout_close_device(sd); + if (write_page(sd) < 0) return false; - } return true; } diff --git a/src/output_thread.c b/src/output_thread.c index f03520013..825dfa5f5 100644 --- a/src/output_thread.c +++ b/src/output_thread.c @@ -62,6 +62,11 @@ static void ao_play(struct audio_output *ao) convertAudioFormat(ao, &data, &size); ao->result = ao->plugin->play(ao->data, data, size); + if (!ao->result) { + ao->plugin->close(ao->data); + ao->open = false; + } + ao_command_finished(ao); } |