mirror of https://github.com/mstorsjo/fdk-aac.git
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.
This commit is contained in:
parent
cb19aa7c12
commit
43cb942cd4
10
wavreader.c
10
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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue