From 0629f44713df6cab71e5a648b25a831016635a09 Mon Sep 17 00:00:00 2001 From: Petri Hintukainen Date: Mon, 16 Jan 2012 21:57:28 +0200 Subject: Check for failed write --- src/audio_out/audio_file_out.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/audio_out/audio_file_out.c b/src/audio_out/audio_file_out.c index 802461e0e..bc40d4efd 100644 --- a/src/audio_out/audio_file_out.c +++ b/src/audio_out/audio_file_out.c @@ -274,10 +274,20 @@ static void ao_file_close(ao_driver_t *this_gen) this->fname, this->bytes_written / 1024); if (lseek(this->fd, 40, SEEK_SET) != -1) { - write(this->fd, &len, 4); + if (write(this->fd, &len, 4) != 4) { + xprintf (this->xine, XINE_VERBOSITY_LOG, "audio_file_out: Failed to write header to file '%s': %s\n", + this->fname, strerror(errno)); + } + len = le2me_32(this->bytes_written + 0x24); - if (lseek(this->fd, 4, SEEK_SET) != -1) - write(this->fd, &len, 4); + if (lseek(this->fd, 4, SEEK_SET) != -1) { + if (write(this->fd, &len, 4) != 4) { + xprintf (this->xine, XINE_VERBOSITY_LOG, + "audio_file_out: Failed to write header to file '%s': %s\n", + this->fname, strerror(errno)); + } + } + } close(this->fd); -- cgit v1.2.3