diff options
-rw-r--r-- | apps/codecs/libffmpegFLAC/main.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/apps/codecs/libffmpegFLAC/main.c b/apps/codecs/libffmpegFLAC/main.c index 4a989a4dd0..058c581aea 100644 --- a/apps/codecs/libffmpegFLAC/main.c +++ b/apps/codecs/libffmpegFLAC/main.c | |||
@@ -33,6 +33,7 @@ | |||
33 | 33 | ||
34 | #include <stdio.h> | 34 | #include <stdio.h> |
35 | #include <string.h> | 35 | #include <string.h> |
36 | #include <stdlib.h> | ||
36 | #include <inttypes.h> | 37 | #include <inttypes.h> |
37 | #include <stdbool.h> | 38 | #include <stdbool.h> |
38 | #include <fcntl.h> | 39 | #include <fcntl.h> |
@@ -63,7 +64,10 @@ int open_wav(char* filename) { | |||
63 | 64 | ||
64 | fd=open(filename,O_CREAT|O_WRONLY|O_TRUNC,S_IRUSR|S_IWUSR); | 65 | fd=open(filename,O_CREAT|O_WRONLY|O_TRUNC,S_IRUSR|S_IWUSR); |
65 | if (fd >= 0) { | 66 | if (fd >= 0) { |
66 | write(fd,wav_header,sizeof(wav_header)); | 67 | if (write(fd,wav_header,sizeof(wav_header)) < sizeof(wav_header)) { |
68 | fprintf(stderr,"[ERR} Failed to write wav header\n"); | ||
69 | exit(1); | ||
70 | } | ||
67 | } | 71 | } |
68 | return(fd); | 72 | return(fd); |
69 | } | 73 | } |
@@ -114,7 +118,10 @@ void close_wav(int fd, FLACContext* fc) { | |||
114 | wav_header[43]=(x&0xff000000)>>24; | 118 | wav_header[43]=(x&0xff000000)>>24; |
115 | 119 | ||
116 | lseek(fd,0,SEEK_SET); | 120 | lseek(fd,0,SEEK_SET); |
117 | write(fd,wav_header,sizeof(wav_header)); | 121 | if (write(fd,wav_header,sizeof(wav_header)) < sizeof(wav_header)) { |
122 | fprintf(stderr,"[ERR} Failed to write wav header\n"); | ||
123 | exit(1); | ||
124 | } | ||
118 | close(fd); | 125 | close(fd); |
119 | } | 126 | } |
120 | 127 | ||
@@ -295,7 +302,11 @@ int main(int argc, char* argv[]) { | |||
295 | if (fc.bps==24) *(p++)=(decoded1[i]&0xff0000)>>16; | 302 | if (fc.bps==24) *(p++)=(decoded1[i]&0xff0000)>>16; |
296 | } | 303 | } |
297 | } | 304 | } |
298 | write(fdout,wavbuf,fc.blocksize*fc.channels*(fc.bps/8)); | 305 | n = fc.blocksize*fc.channels*(fc.bps/8); |
306 | if (write(fdout,wavbuf,n) < n) { | ||
307 | fprintf(stderr,"[ERR] Write failed\n"); | ||
308 | exit(1); | ||
309 | } | ||
299 | 310 | ||
300 | memmove(buf,&buf[consumed],bytesleft-consumed); | 311 | memmove(buf,&buf[consumed],bytesleft-consumed); |
301 | bytesleft-=consumed; | 312 | bytesleft-=consumed; |