sndio: Fix segmentation fault when audio card is removed
This can happen if you remove an external audio card or if you stop sndiod(8) while playing a song. sio_write() will retry internally if it fails with errno == EINTR so no need to handle that.
This commit is contained in:
parent
cb1082c58c
commit
d4f801a8e9
|
@ -17,7 +17,6 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <sndio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
@ -183,12 +182,12 @@ SndioOutput::Play(const void *chunk, size_t size, Error &error)
|
|||
|
||||
while (1) {
|
||||
n = sio_write(sio_hdl, chunk, size);
|
||||
if (n < 0) {
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
error.FormatErrno("Failed to write %zu bytes to sndio output", size);
|
||||
if (n == 0) {
|
||||
if (sio_eof(sio_hdl)) {
|
||||
error.Set(sndio_output_domain, -1, "sndio write failed");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return n;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue