From 50ffa87bed3e44764c5bad114b3b871289c7c95e Mon Sep 17 00:00:00 2001 From: falkTX Date: Thu, 7 Mar 2013 12:13:07 +0000 Subject: [PATCH] Add minor checks to audiofile --- source/backend/native/audiofile.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/source/backend/native/audiofile.c b/source/backend/native/audiofile.c index c4c91d1a6..c3b88051e 100644 --- a/source/backend/native/audiofile.c +++ b/source/backend/native/audiofile.c @@ -81,6 +81,12 @@ void zeroFloat(float* data, unsigned size) void audiofile_read_poll(AudioFileInstance* const handlePtr) { + if (handlePtr == NULL) + { + fprintf(stderr, "R: invalid instance\n"); + return; + } + if (handlePtr->fileNfo.frames == 0) { //fprintf(stderr, "R: no song loaded\n"); @@ -95,6 +101,8 @@ void audiofile_read_poll(AudioFileInstance* const handlePtr) { if (handlePtr->loopMode) { + //fprintf(stderr, "R: DEBUG read loop, lastFrame:%i, maxFrame:%i\n", handlePtr->lastFrame, handlePtr->maxFrame); + if (handlePtr->maxFrame >= handlePtr->pool.size) { readFrame %= handlePtr->maxFrame; @@ -221,7 +229,10 @@ void audiofile_load_filename(AudioFileInstance* const handlePtr, const char* con { ad_dump_nfo(99, &handlePtr->fileNfo); - if (handlePtr->fileNfo.channels == 1 || handlePtr->fileNfo.channels == 2) + if (handlePtr->fileNfo.frames == 0) + fprintf(stderr, "L: filename \"%s\" has 0 frames\n", filename); + + if ((handlePtr->fileNfo.channels == 1 || handlePtr->fileNfo.channels == 2) && handlePtr->fileNfo.frames > 0) { handlePtr->maxFrame = handlePtr->fileNfo.frames; audiofile_read_poll(handlePtr);