aboutsummaryrefslogtreecommitdiffstats
path: root/wavreader.c
diff options
context:
space:
mode:
authorMartin Storsjo <martin@martin.st>2014-02-07 14:50:13 +0200
committerMartin Storsjo <martin@martin.st>2014-06-23 10:45:50 +0300
commite7348e7a5d94648130e9baa4f1bfaf3d65316133 (patch)
tree89f26330c0f8f46708699ae87b72bc55ae3947d0 /wavreader.c
parent1652691ee9ebb7e789be895f6a9dae66ae9c137d (diff)
downloadfdk-aac-e7348e7a5d94648130e9baa4f1bfaf3d65316133.tar.gz
fdk-aac-e7348e7a5d94648130e9baa4f1bfaf3d65316133.tar.bz2
fdk-aac-e7348e7a5d94648130e9baa4f1bfaf3d65316133.zip
Support streamed wav files with a 0 bytes data chunk
Diffstat (limited to 'wavreader.c')
-rw-r--r--wavreader.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/wavreader.c b/wavreader.c
index f672001..a8b4d0e 100644
--- a/wavreader.c
+++ b/wavreader.c
@@ -34,6 +34,8 @@ struct wav_reader {
int channels;
int byte_rate;
int block_align;
+
+ int streamed;
};
static uint32_t read_tag(struct wav_reader* wr) {
@@ -113,6 +115,10 @@ void* wav_read_open(const char *filename) {
} else if (subtag == TAG('d', 'a', 't', 'a')) {
data_pos = ftell(wr->wav);
wr->data_length = sublength;
+ if (!wr->data_length) {
+ wr->streamed = 1;
+ return wr;
+ }
fseek(wr->wav, sublength, SEEK_CUR);
} else {
fseek(wr->wav, sublength, SEEK_CUR);
@@ -154,7 +160,7 @@ int wav_read_data(void* obj, unsigned char* data, unsigned int length) {
int n;
if (wr->wav == NULL)
return -1;
- if (length > wr->data_length)
+ if (length > wr->data_length && !wr->streamed)
length = wr->data_length;
n = fread(data, 1, length, wr->wav);
wr->data_length -= length;