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.
This commit is contained in:
Max Kellermann 2008-10-29 20:40:33 +01:00
parent 58c5bee9f0
commit 2f76db4c78
7 changed files with 7 additions and 12 deletions

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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;

View File

@ -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;
}

View File

@ -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);
}