From 65c79c1c437b26887e8f320c4fcb82ec4fe42a74 Mon Sep 17 00:00:00 2001 From: rnlf Date: Sun, 22 Jan 2017 20:46:17 +0100 Subject: [PATCH] Cleanup of wavefile loader --- src/wavefile.c | 12 ++++++++++++ src/wavefile.h | 12 +++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/wavefile.c b/src/wavefile.c index 34e7375..ef1e4b2 100644 --- a/src/wavefile.c +++ b/src/wavefile.c @@ -1,3 +1,10 @@ +/** + * Copyright (c) 2017 rnlf + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the MIT license. See LICENSE for details. + */ + #include #include "filesystem.h" #include "wavefile.h" @@ -33,6 +40,11 @@ char const* wavefile_load(source_t *source, char const *filename) { char const *err = 0; uint8_t *waveData = filesystem_read(filename, &fileSize); + if(waveData == NULL) { + err = "Could not read WAV file"; + goto fail; + } + waveheader_t const* header = (waveheader_t const*)waveData; if(header->chunkId != RIFF_CHUNK_ID diff --git a/src/wavefile.h b/src/wavefile.h index e8db8d5..f462a27 100644 --- a/src/wavefile.h +++ b/src/wavefile.h @@ -1,5 +1,15 @@ -#pragma once +/** + * Copyright (c) 2017 rnlf + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the MIT license. See LICENSE for details. + */ + +#ifndef WAVEFILE_H +#define WAVEFILE_H #include "source.h" char const* wavefile_load(source_t *source, char const *filename); + +#endif