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:
parent
58c5bee9f0
commit
2f76db4c78
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user