aboutsummaryrefslogtreecommitdiffstats
path: root/wavreader.c
diff options
context:
space:
mode:
authorMartin Storsjo <martin@martin.st>2014-02-07 14:59:20 +0200
committerMartin Storsjo <martin@martin.st>2014-06-23 10:45:50 +0300
commit43cb942cd46729003405f7a6f3e5eaf6a7b95d84 (patch)
treeee7a7e4c25f501038dc87b6b98d4d6efb8e863d3 /wavreader.c
parentcb19aa7c129d3635b5a918e5744c283eb5fb17f7 (diff)
downloadfdk-aac-43cb942cd46729003405f7a6f3e5eaf6a7b95d84.tar.gz
fdk-aac-43cb942cd46729003405f7a6f3e5eaf6a7b95d84.tar.bz2
fdk-aac-43cb942cd46729003405f7a6f3e5eaf6a7b95d84.zip
Use skip instead of fseek
fseek(SEEK_CUR) doesn't work for nonseekable streams (such as pipes). Only do this for skipping past small chunks; don't use it for skipping past the actual data for non-streamed input.
Diffstat (limited to 'wavreader.c')
-rw-r--r--wavreader.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/wavreader.c b/wavreader.c
index 194046b..76443e0 100644
--- a/wavreader.c
+++ b/wavreader.c
@@ -63,6 +63,12 @@ static uint16_t read_int16(struct wav_reader* wr) {
return value;
}
+static void skip(FILE *f, int n) {
+ int i;
+ for (i = 0; i < n; i++)
+ fgetc(f);
+}
+
void* wav_read_open(const char *filename) {
struct wav_reader* wr = (struct wav_reader*) malloc(sizeof(*wr));
long data_pos = 0;
@@ -118,7 +124,7 @@ void* wav_read_open(const char *filename) {
wr->byte_rate = read_int32(wr);
wr->block_align = read_int16(wr);
wr->bits_per_sample = read_int16(wr);
- fseek(wr->wav, sublength - 16, SEEK_CUR);
+ skip(wr->wav, sublength - 16);
} else if (subtag == TAG('d', 'a', 't', 'a')) {
data_pos = ftell(wr->wav);
wr->data_length = sublength;
@@ -128,7 +134,7 @@ void* wav_read_open(const char *filename) {
}
fseek(wr->wav, sublength, SEEK_CUR);
} else {
- fseek(wr->wav, sublength, SEEK_CUR);
+ skip(wr->wav, sublength);
}
length -= sublength;
}