diff --git a/Makefile b/Makefile index 18475d6..77fff73 100644 --- a/Makefile +++ b/Makefile @@ -51,7 +51,7 @@ EXTRA_OUTPUT_FILES := LIBRARY_DIRS := $(DEVKITPRO)/libctru $(DEVKITPRO)/portlibs/armv6k LIBRARIES := mpg123 opusfile opus ogg ctru m -BUILD_FLAGS := +BUILD_FLAGS := -Wall -Wextra RUN_FLAGS := VERSION_PARTS := $(subst ., ,$(shell git describe --tags --abbrev=0)) diff --git a/source/all.h b/source/all.h index 89c4901..b7ef44f 100644 --- a/source/all.h +++ b/source/all.h @@ -1,9 +1,6 @@ #include #include -/* Channel to play music on */ -#define CHANNEL 0x08 - /* Adds extra debugging text */ //#define DEBUG @@ -14,13 +11,3 @@ #define delete(ptr) \ free((void*) ptr); ptr = NULL - -struct decoder_fn -{ - int (* init)(const char* file); - uint32_t (* rate)(void); - uint8_t (* channels)(void); - int buffSize; - uint64_t (* decode)(void*); - void (* exit)(void); -}; diff --git a/source/flac.c b/source/flac.c index 6368fea..49f922c 100644 --- a/source/flac.c +++ b/source/flac.c @@ -3,11 +3,11 @@ #define DR_FLAC_IMPLEMENTATION #include <./dr_libs/dr_flac.h> -#include "all.h" #include "flac.h" +#include "playback.h" static drflac* pFlac; -static const int buffSize = 16 * 1024; +static const size_t buffSize = 16 * 1024; /** * Set decoder parameters for flac. diff --git a/source/flac.h b/source/flac.h index dc734c9..5da31ec 100644 --- a/source/flac.h +++ b/source/flac.h @@ -1,3 +1,5 @@ +#include "playback.h" + /** * Set decoder parameters for flac. * diff --git a/source/mp3.c b/source/mp3.c index 3cc1f3a..2535a22 100644 --- a/source/mp3.c +++ b/source/mp3.c @@ -4,10 +4,10 @@ #include #include -#include "all.h" #include "mp3.h" +#include "playback.h" -static int* buffSize; +static size_t* buffSize; static mpg123_handle *mh = NULL; static uint32_t rate; static uint8_t channels; diff --git a/source/mp3.h b/source/mp3.h index 06218ca..223440a 100644 --- a/source/mp3.h +++ b/source/mp3.h @@ -1,3 +1,5 @@ +#include "playback.h" + /** * Set decoder parameters for MP3. * diff --git a/source/opus.c b/source/opus.c index 8e98d88..2285f9d 100644 --- a/source/opus.c +++ b/source/opus.c @@ -2,12 +2,12 @@ #include #include -#include "all.h" #include "opus.h" +#include "playback.h" static OggOpusFile* opusFile; static const OpusHead* opusHead; -static const int buffSize = 32 * 1024; +static const size_t buffSize = 32 * 1024; /** * Set decoder parameters for Opus. diff --git a/source/opus.h b/source/opus.h index 98e2c09..4e88f02 100644 --- a/source/opus.h +++ b/source/opus.h @@ -1,4 +1,5 @@ #include +#include "playback.h" void setOpus(struct decoder_fn* decoder); diff --git a/source/playback.c b/source/playback.c index 8a81b34..109b6d6 100644 --- a/source/playback.c +++ b/source/playback.c @@ -1,4 +1,5 @@ #include <3ds.h> +#include #include #include @@ -49,7 +50,7 @@ bool isPlaying(void) static int getFileType(const char *file) { FILE* ftest = fopen(file, "rb"); - int fileSig = 0; + uint32_t fileSig; enum file_types file_type = FILE_TYPE_ERROR; /* Failure opening file */ @@ -83,7 +84,7 @@ static int getFileType(const char *file) break; // "OggS" - case 0x5367674f: + case 0x5367674F: if(isOpus(file) == 0) file_type = FILE_TYPE_OPUS; else @@ -161,7 +162,7 @@ void playFile(void* infoIn) goto err; } - if(R_FAILED(ndspInit())) + if(ndspInit() < 0) { errno = NDSP_INIT_FAIL; goto err; diff --git a/source/playback.h b/source/playback.h index 4779f58..60f0d24 100644 --- a/source/playback.h +++ b/source/playback.h @@ -1,6 +1,9 @@ #ifndef ctrmus_playback_h #define ctrmus_playback_h +/* Channel to play music on */ +#define CHANNEL 0x08 + enum file_types { FILE_TYPE_ERROR = -1, @@ -11,6 +14,16 @@ enum file_types FILE_TYPE_MP3 }; +struct decoder_fn +{ + int (* init)(const char* file); + uint32_t (* rate)(void); + uint8_t (* channels)(void); + size_t buffSize; + uint64_t (* decode)(void*); + void (* exit)(void); +}; + struct playbackInfo_t { char* file; diff --git a/source/wav.c b/source/wav.c index e27f9dc..c21f700 100644 --- a/source/wav.c +++ b/source/wav.c @@ -3,10 +3,10 @@ #include #include -#include "all.h" #include "wav.h" +#include "playback.h" -static const int buffSize = 16 * 1024; +static const size_t buffSize = 16 * 1024; static FILE* pWav = NULL; static char header[45]; static uint8_t channels; diff --git a/source/wav.h b/source/wav.h index 5971c21..6814a94 100644 --- a/source/wav.h +++ b/source/wav.h @@ -1,3 +1,5 @@ +#include "playback.h" + /** * Set decoder parameters for WAV. *