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("closing ALSA device \"%s\" due to write "
|
||||||
"error: %s\n", ad->device,
|
"error: %s\n", ad->device,
|
||||||
snd_strerror(-errno));
|
snd_strerror(-errno));
|
||||||
alsa_closeDevice(ad);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
continue;
|
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) {
|
if (ao_play_deconst(ad->device, playChunk, chunk_size) == 0) {
|
||||||
audioOutputAo_error();
|
audioOutputAo_error();
|
||||||
ERROR("closing audio device due to write error\n");
|
ERROR("closing audio device due to write error\n");
|
||||||
audioOutputAo_closeDevice(ad);
|
|
||||||
return false;
|
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: "
|
ERROR("Closing FIFO output \"%s\" due to write error: "
|
||||||
"%s\n", fd->path, strerror(errno));
|
"%s\n", fd->path, strerror(errno));
|
||||||
fifo_closeDevice(fd);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,7 +253,6 @@ mvp_playAudio(void *data, const char *playChunk, size_t size)
|
|||||||
continue;
|
continue;
|
||||||
ERROR("closing mvp PCM device due to write error: "
|
ERROR("closing mvp PCM device due to write error: "
|
||||||
"%s\n", strerror(errno));
|
"%s\n", strerror(errno));
|
||||||
mvp_closeDevice(md);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
playChunk += ret;
|
playChunk += ret;
|
||||||
|
@ -549,7 +549,6 @@ oss_playAudio(void *data, const char *playChunk, size_t size)
|
|||||||
continue;
|
continue;
|
||||||
ERROR("closing oss device \"%s\" due to write error: "
|
ERROR("closing oss device \"%s\" due to write error: "
|
||||||
"%s\n", od->device, strerror(errno));
|
"%s\n", od->device, strerror(errno));
|
||||||
oss_closeDevice(od);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
playChunk += ret;
|
playChunk += ret;
|
||||||
|
@ -525,7 +525,6 @@ my_shout_play(void *data, const char *chunk, size_t size)
|
|||||||
if (!sd->opened) {
|
if (!sd->opened) {
|
||||||
status = open_shout_conn(sd);
|
status = open_shout_conn(sd);
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
my_shout_close_device(sd);
|
|
||||||
return false;
|
return false;
|
||||||
} else if (status > 0) {
|
} else if (status > 0) {
|
||||||
timer_sync(sd->timer);
|
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)) {
|
if (sd->encoder->encode_func(sd, chunk, size))
|
||||||
my_shout_close_device(sd);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
if (write_page(sd) < 0) {
|
if (write_page(sd) < 0)
|
||||||
my_shout_close_device(sd);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,11 @@ static void ao_play(struct audio_output *ao)
|
|||||||
convertAudioFormat(ao, &data, &size);
|
convertAudioFormat(ao, &data, &size);
|
||||||
|
|
||||||
ao->result = ao->plugin->play(ao->data, 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);
|
ao_command_finished(ao);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user