summaryrefslogtreecommitdiffstats
path: root/sbc
diff options
context:
space:
mode:
authorBrad Midgley <bmidgley@xmission.com>2007-03-24 13:58:21 +0000
committerBrad Midgley <bmidgley@xmission.com>2007-03-24 13:58:21 +0000
commit0c96c8790268b67d973339ca4547c8021474bf1c (patch)
tree86d876c585c6e3c5cb444d5d4d34df6d6670180b /sbc
parent1d6beece31584c71a7ce730133923f2e1d0d3b7d (diff)
examine the result of write() ops, avoid warnings
Diffstat (limited to 'sbc')
-rw-r--r--sbc/sbcdec.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/sbc/sbcdec.c b/sbc/sbcdec.c
index 0617fe04..3435e8f8 100644
--- a/sbc/sbcdec.c
+++ b/sbc/sbcdec.c
@@ -46,7 +46,7 @@ static void decode(char *filename, char *audiodevice, int tofile)
struct stat st;
off_t filesize;
sbc_t sbc;
- int fd, ad, pos, streamlen, framelen, count, format = AFMT_S16_BE;
+ int fd, ad, pos, streamlen, framelen, count, format = AFMT_S16_BE, written;
if (stat(filename, &st) < 0) {
fprintf(stderr, "Can't get size of file %s: %s\n",
@@ -121,8 +121,8 @@ static void decode(char *filename, char *audiodevice, int tofile)
if (count + sbc.len > BUF_SIZE) {
// buffer is too full to stuff decoded audio in
// so it must be written to the device
- write(ad, buf, count);
- count = 0;
+ written = write(ad, buf, count);
+ if(written > 0) count -= written;
}
// sanity check
@@ -141,8 +141,10 @@ static void decode(char *filename, char *audiodevice, int tofile)
framelen = sbc_decode(&sbc, stream + pos, streamlen - pos);
}
- if (count > 0)
- write(ad, buf, count);
+ if (count > 0) {
+ written = write(ad, buf, count);
+ if(written > 0) count -= written;
+ }
close:
sbc_finish(&sbc);