From 11d7bede77a49d6130f4ed7507c6c149ae35395c Mon Sep 17 00:00:00 2001 From: Mahyar Koshkouei Date: Mon, 14 Aug 2017 21:50:54 +0100 Subject: [PATCH] Initial testing support Added the ability to compile a subset of functions in to a test executable for Linux. To be used in the future for testing. Removed unnecessary includes. Tested working by compiling test executable for GNU/Linux and for the 3DS. The 3dsx was tested in citra. Signed-off-by: Mahyar Koshkouei --- Makefile.linux | 63 +++++++++++++++++++++++++++++++++++++++++++++++ source/flac.c | 2 -- source/mp3.c | 1 - source/mp3.h | 1 + source/opus.c | 1 - source/playback.h | 2 ++ source/test.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++ source/vorbis.c | 1 - source/wav.c | 1 - source/wav.h | 1 + 10 files changed, 130 insertions(+), 6 deletions(-) create mode 100644 Makefile.linux create mode 100644 source/test.c diff --git a/Makefile.linux b/Makefile.linux new file mode 100644 index 0000000..c85abfa --- /dev/null +++ b/Makefile.linux @@ -0,0 +1,63 @@ +# Makefile to produce test build of ctrmus for Linux +# +# make -f Makefile.linux + +ifeq ($(OS),Windows_NT) + HOST_OS := windows + ifeq ($(PROCESSOR_ARCHITECTURE),AMD64) + HOST_ARCH := x86_64 + else + HOST_ARCH := i686 + endif +else + UNAME_M := $(shell uname -m) + ifeq ($(UNAME_M),$(filter $(UNAME_M),x86_64 amd64)) + HOST_ARCH := x86_64 + else ifeq ($(UNAME_M),$(filter $(UNAME_M),i386 i686)) + HOST_ARCH := i686 + else + $(error "Unsupported host architecture.") + endif +endif + +IDIR =./source +CC=gcc +CFLAGS=-I./include/ +LIBS=-lmpg123 -lvorbisidec -lopusfile -lopus -logg -lm + +ODIR=./build/$(HOST_ARCH) +SDIR=./source + +_DEPS = all.h \ + flac.h \ + mp3.h \ + opus.h \ + vorbis.h \ + wav.h + +DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS)) + +_OBJ = flac.o \ + mp3.o \ + opus.o \ + test.o \ + vorbis.o \ + wav.o + +OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ)) + +all: directory test + +directory: + mkdir -p $(ODIR) + +$(ODIR)/%.o: $(SDIR)/%.c $(DEPS) + $(CC) -c -o $@ $< $(CFLAGS) + +test: $(OBJ) + gcc -o $@ $^ $(CFLAGS) $(LIBS) + +.PHONY: clean directory + +clean: + rm -f $(ODIR)/*.o *~ core $(INCDIR)/*~ diff --git a/source/flac.c b/source/flac.c index 7c5b933..035dff6 100644 --- a/source/flac.c +++ b/source/flac.c @@ -1,5 +1,3 @@ -#include <3ds.h> - #define DR_FLAC_IMPLEMENTATION #include <./dr_libs/dr_flac.h> diff --git a/source/mp3.c b/source/mp3.c index 388490a..e4e736e 100644 --- a/source/mp3.c +++ b/source/mp3.c @@ -1,4 +1,3 @@ -#include <3ds.h> #include #include #include diff --git a/source/mp3.h b/source/mp3.h index 223440a..1dde750 100644 --- a/source/mp3.h +++ b/source/mp3.h @@ -1,3 +1,4 @@ +#include #include "playback.h" /** diff --git a/source/opus.c b/source/opus.c index 58789b9..0dc18e2 100644 --- a/source/opus.c +++ b/source/opus.c @@ -1,4 +1,3 @@ -#include <3ds.h> #include #include diff --git a/source/playback.h b/source/playback.h index ba0b4ca..da94ac8 100644 --- a/source/playback.h +++ b/source/playback.h @@ -1,3 +1,5 @@ +#include + #ifndef ctrmus_playback_h #define ctrmus_playback_h diff --git a/source/test.c b/source/test.c new file mode 100644 index 0000000..0463949 --- /dev/null +++ b/source/test.c @@ -0,0 +1,63 @@ +#if defined __gnu_linux__ +#include +#include + +#include "flac.h" +#include "mp3.h" +#include "opus.h" +#include "playback.h" +#include "vorbis.h" +#include "wav.h" +#include "playback.h" + +/** + * Test the various decoder modules in ctrmus. + */ +int main(int argc, char *argv[]) +{ + struct decoder_fn decoder; + + if(argc != 2) + { + puts("FILE is required."); + printf("%s FILE\n", argv[0]); + return 0; + } +#if 0 + switch(getFileType(argv[1])) + { + case FILE_TYPE_WAV: + setWav(&decoder); + break; + + case FILE_TYPE_FLAC: + setFlac(&decoder); + break; + + case FILE_TYPE_OPUS: + setOpus(&decoder); + break; + + case FILE_TYPE_MP3: + setMp3(&decoder); + break; + + case FILE_TYPE_VORBIS: + setVorbis(&decoder); + break; + + default: + goto err; + } +#endif + + return 0; + +err: + puts("Error"); + return -1; +} + +#else +#pragma message ( "Test ignored for 3DS build." ) +#endif diff --git a/source/vorbis.c b/source/vorbis.c index 2fb6a35..124affa 100644 --- a/source/vorbis.c +++ b/source/vorbis.c @@ -1,4 +1,3 @@ -#include <3ds.h> #include #include #include diff --git a/source/wav.c b/source/wav.c index c21f700..8dfe4d5 100644 --- a/source/wav.c +++ b/source/wav.c @@ -1,4 +1,3 @@ -#include <3ds.h> #include #include #include diff --git a/source/wav.h b/source/wav.h index 6814a94..f898aa0 100644 --- a/source/wav.h +++ b/source/wav.h @@ -1,3 +1,4 @@ +#include #include "playback.h" /**