diff --git a/FLAC.dsw b/FLAC.dsw index 7796aadb..f3466521 100644 --- a/FLAC.dsw +++ b/FLAC.dsw @@ -84,6 +84,9 @@ Package=<4> Project_Dep_Name utf8_static End Project Dependency Begin Project Dependency + Project_Dep_Name test_grabbag + End Project Dependency + Begin Project Dependency Project_Dep_Name test_libFLAC End Project Dependency Begin Project Dependency @@ -153,6 +156,9 @@ Package=<4> Project_Dep_Name utf8_static End Project Dependency Begin Project Dependency + Project_Dep_Name test_grabbag + End Project Dependency + Begin Project Dependency Project_Dep_Name test_libFLAC End Project Dependency Begin Project Dependency @@ -447,6 +453,21 @@ Package=<4> ############################################################################### +Project: "test_grabbag"=.\src\test_grabbag\test_grabbag.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name grabbag_static + End Project Dependency +}}} + +############################################################################### + Project: "test_libFLAC"=.\src\test_libFLAC\test_libFLAC.dsp - Package Owner=<4> Package=<5> diff --git a/Makefile.lite b/Makefile.lite index 10d305f6..7a19a4b7 100644 --- a/Makefile.lite +++ b/Makefile.lite @@ -29,8 +29,8 @@ topdir = . -.PHONY: doc libFLAC libFLAC++ libOggFLAC libOggFLAC++ share plugin_common plugin_xmms flac metaflac test_libFLAC test_libFLAC++ test_libOggFLAC test_libOggFLAC++ test_streams -all: doc libFLAC libFLAC++ libOggFLAC libOggFLAC++ share plugin_common plugin_xmms flac metaflac test_libFLAC test_libFLAC++ test_libOggFLAC test_libOggFLAC++ test_streams +.PHONY: doc libFLAC libFLAC++ libOggFLAC libOggFLAC++ share plugin_common plugin_xmms flac metaflac test_grabbag test_libFLAC test_libFLAC++ test_libOggFLAC test_libOggFLAC++ test_streams +all: doc libFLAC libFLAC++ libOggFLAC libOggFLAC++ share plugin_common plugin_xmms flac metaflac test_grabbag test_libFLAC test_libFLAC++ test_libOggFLAC test_libOggFLAC++ test_streams DEFAULT_CONFIG = release @@ -75,6 +75,9 @@ plugin_xmms: libFLAC plugin_common test_streams: libFLAC (cd src/$@ ; $(MAKE) -f Makefile.lite $(CONFIG)) +test_grabbag: grabbag + (cd src/$@ ; $(MAKE) -f Makefile.lite $(CONFIG)) + test_libFLAC: libFLAC (cd src/$@ ; $(MAKE) -f Makefile.lite $(CONFIG)) @@ -101,6 +104,7 @@ clean: -(cd src/metaflac ; $(MAKE) -f Makefile.lite clean) -(cd src/plugin_common ; $(MAKE) -f Makefile.lite clean) -(cd src/plugin_xmms ; $(MAKE) -f Makefile.lite clean) + -(cd src/test_grabbag ; $(MAKE) -f Makefile.lite clean) -(cd src/test_libFLAC ; $(MAKE) -f Makefile.lite clean) -(cd src/test_libFLAC++ ; $(MAKE) -f Makefile.lite clean) -(cd src/test_libOggFLAC ; $(MAKE) -f Makefile.lite clean) diff --git a/src/Makefile.am b/src/Makefile.am index 8ed36bc0..d43ac530 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -36,6 +36,7 @@ SUBDIRS = \ $(XMMS_DIRS) \ plugin_winamp2 \ plugin_winamp3 \ + test_grabbag \ test_libFLAC \ test_libFLAC++ \ $(OGGFLAC_TEST_DIRS) \ diff --git a/src/Makefile.vc b/src/Makefile.vc index d4462cd6..8256dee5 100644 --- a/src/Makefile.vc +++ b/src/Makefile.vc @@ -33,6 +33,9 @@ all: cd monkeys_audio_utilities nmake /f Makefile.vc cd .. + cd test_grabbag + nmake /f Makefile.vc + cd .. cd test_libFLAC nmake /f Makefile.vc cd .. @@ -80,6 +83,9 @@ clean: cd monkeys_audio_utilities nmake /f Makefile.vc clean cd .. + cd test_grabbag + nmake /f Makefile.vc clean + cd .. cd test_libFLAC nmake /f Makefile.vc clean cd .. diff --git a/src/test_grabbag/Makefile.am b/src/test_grabbag/Makefile.am new file mode 100644 index 00000000..4f01f584 --- /dev/null +++ b/src/test_grabbag/Makefile.am @@ -0,0 +1,22 @@ +# FLAC - Free Lossless Audio Codec +# Copyright (C) 2002 Josh Coalson +# +# This program is part of FLAC; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +SUBDIRS = cuesheet + +EXTRA_DIST = \ + Makefile.lite \ + Makefile.vc diff --git a/src/test_grabbag/Makefile.lite b/src/test_grabbag/Makefile.lite new file mode 100644 index 00000000..c6609fd3 --- /dev/null +++ b/src/test_grabbag/Makefile.lite @@ -0,0 +1,35 @@ +# test_grabbag - Simple testers for the grabbag library +# Copyright (C) 2002 Josh Coalson +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +.PHONY: cuesheet +all: cuesheet + +DEFAULT_CONFIG = release + +CONFIG = $(DEFAULT_CONFIG) + +debug : CONFIG = debug +release : CONFIG = release + +debug : all +release : all + +cuesheet: + (cd $@ ; $(MAKE) -f Makefile.lite $(CONFIG)) + +clean: + -(cd cuesheet ; $(MAKE) -f Makefile.lite clean) diff --git a/src/test_grabbag/Makefile.vc b/src/test_grabbag/Makefile.vc new file mode 100644 index 00000000..b972a528 --- /dev/null +++ b/src/test_grabbag/Makefile.vc @@ -0,0 +1,13 @@ +!include + +# It's less hassle to spell it all out that to figure out how to do it right with nmake: + +all: + cd cuesheet + nmake /f Makefile.vc + cd .. + +clean: + cd cuesheet + nmake /f Makefile.vc clean + cd .. diff --git a/src/test_grabbag/cuesheet/Makefile.am b/src/test_grabbag/cuesheet/Makefile.am new file mode 100644 index 00000000..7bdcde47 --- /dev/null +++ b/src/test_grabbag/cuesheet/Makefile.am @@ -0,0 +1,33 @@ +# test_cuesheet - Simple tester for cuesheet routines in grabbag +# Copyright (C) 2002 Josh Coalson +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +EXTRA_DIST = \ + Makefile.lite \ + Makefile.vc \ + test_cuesheet.dsp + +CFLAGS = @CFLAGS@ + +noinst_PROGRAMS = test_cuesheet +test_cuesheet_SOURCES = \ + main.c +test_cuesheet_LDADD = \ + $(top_builddir)/src/share/grabbag/libgrabbag.a \ + $(top_builddir)/src/libFLAC/libFLAC.la \ + -lm + +CLEANFILES = $(wildcard *.raw) diff --git a/src/test_grabbag/cuesheet/Makefile.lite b/src/test_grabbag/cuesheet/Makefile.lite new file mode 100644 index 00000000..ba27ef7f --- /dev/null +++ b/src/test_grabbag/cuesheet/Makefile.lite @@ -0,0 +1,32 @@ +# test_cuesheet - Simple tester for cuesheet routines in grabbag +# Copyright (C) 2002 Josh Coalson +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# +# GNU makefile +# + +topdir = ../../.. + +PROGRAM_NAME = test_cuesheet +INCLUDES = -I./include -I$(topdir)/include +LIBS = -lgrabbag -lFLAC -lm +SRCS_C = \ + main.c + +include $(topdir)/build/exe.mk + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/src/test_grabbag/cuesheet/Makefile.vc b/src/test_grabbag/cuesheet/Makefile.vc new file mode 100644 index 00000000..b54dd8f7 --- /dev/null +++ b/src/test_grabbag/cuesheet/Makefile.vc @@ -0,0 +1,40 @@ +# test_cuesheet - Simple tester for cuesheet routines in grabbag +# Copyright (C) 2002 Josh Coalson +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +!include + +!IFDEF DEBUG +.c.obj: + $(cc) -DFLAC__NO_DLL $(cdebug) $(cflags) /I "..\..\..\include" /I ".\include" -DSTRICT -YX /Od /D "_DEBUG" $< +!else +.c.obj: + $(cc) -DFLAC__NO_DLL /O2 $(crelease) $(cflags) /I "..\..\..\include" /I ".\include" -DSTRICT -YX -DNODEBUG $< +!endif + +C_FILES= \ + main.c + +OBJS= $(C_FILES:.c=.obj) + +all: test_cuesheet.exe + +test_cuesheet.exe: $(OBJS) + link.exe /libpath:"..\..\..\obj\debug\lib" -out:../../../obj/debug/bin/$*.exe $(OBJS) grabbag_static.lib libFLAC_static.lib + +clean: + -del *.obj *.pch + -del ..\..\..\obj\debug\bin\test_cuesheet.exe diff --git a/src/test_grabbag/cuesheet/main.c b/src/test_grabbag/cuesheet/main.c new file mode 100644 index 00000000..5dcd54c5 --- /dev/null +++ b/src/test_grabbag/cuesheet/main.c @@ -0,0 +1,123 @@ +/* test_cuesheet - Simple tester for cuesheet routines in grabbag + * Copyright (C) 2002 Josh Coalson + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include +#include +#include +#include "FLAC/assert.h" +#include "FLAC/metadata.h" +#include "share/grabbag.h" + +static int do_cuesheet(const char *infilename, FLAC__bool is_cdda, FLAC__uint64 lead_out_offset) +{ + FILE *fin, *fout; + const char *error_message; + char tmpfilename[4096]; + unsigned last_line_read; + FLAC__StreamMetadata *cuesheet; + + FLAC__ASSERT(strlen(infilename) + 2 < sizeof(tmpfilename)); + + /* + * pass 1 + */ + if(0 == strcmp(infilename, "-")) { + fin = stdin; + } + else if(0 == (fin = fopen(infilename, "r"))) { + fprintf(stderr, "can't open file %s for reading\n", infilename); + return 255; + } + if(0 != (cuesheet = grabbag__cuesheet_parse(fin, &error_message, &last_line_read, is_cdda, lead_out_offset))) { + if(fin != stdin) + fclose(fin); + } + else { + printf("pass1: parse error, line %u: \"%s\"\n", last_line_read, error_message); + if(fin != stdin) + fclose(fin); + return 1; + } + if(!FLAC__metadata_object_cuesheet_is_legal(cuesheet, is_cdda, &error_message)) { + printf("pass1: illegal cuesheet: \"%s\"\n", error_message); + return 1; + } + sprintf(tmpfilename, "%s.1", infilename); + if(0 == (fout = fopen(tmpfilename, "w"))) { + fprintf(stderr, "can't open file %s for writing\n", tmpfilename); + return 255; + } + grabbag__cuesheet_emit(fout, cuesheet, "\"dummy.wav\" WAVE", is_cdda); + fclose(fout); + + /* + * pass 2 + */ + if(0 == (fin = fopen(tmpfilename, "r"))) { + fprintf(stderr, "can't open file %s for reading\n", tmpfilename); + return 255; + } + if(0 != (cuesheet = grabbag__cuesheet_parse(fin, &error_message, &last_line_read, is_cdda, lead_out_offset))) { + if(fin != stdin) + fclose(fin); + } + else { + printf("pass2: parse error, line %u: \"%s\"\n", last_line_read, error_message); + if(fin != stdin) + fclose(fin); + return 1; + } + if(!FLAC__metadata_object_cuesheet_is_legal(cuesheet, is_cdda, &error_message)) { + printf("pass2: illegal cuesheet: \"%s\"\n", error_message); + return 1; + } + sprintf(tmpfilename, "%s.2", infilename); + if(0 == (fout = fopen(tmpfilename, "w"))) { + fprintf(stderr, "can't open file %s for writing\n", tmpfilename); + return 255; + } + grabbag__cuesheet_emit(fout, cuesheet, "\"dummy.wav\" WAVE", is_cdda); + fclose(fout); + + return 0; +} + +int main(int argc, char *argv[]) +{ + FLAC__uint64 lead_out_offset; + FLAC__bool is_cdda = false; + const char *usage = "usage: test_cuesheet cuesheet_file lead_out_offset [ cdda ]\n"; + + if(argc < 3 || argc > 4) { + fprintf(stderr, usage); + return 255; + } + + lead_out_offset = (FLAC__uint64)strtoul(argv[2], 0, 10); + if(argc == 4) { + if(0 == strcmp(argv[3], "cdda")) + is_cdda = true; + else { + fprintf(stderr, usage); + return 255; + } + } + + return do_cuesheet(argv[1], is_cdda, lead_out_offset); +} +FLAC__StreamMetadata *grabbag__cuesheet_parse(FILE *file, const char **error_message, unsigned *last_line_read, FLAC__bool is_cdda, FLAC__uint64 lead_out_offset); diff --git a/src/test_grabbag/cuesheet/test_cuesheet.dsp b/src/test_grabbag/cuesheet/test_cuesheet.dsp new file mode 100644 index 00000000..97d5d9eb --- /dev/null +++ b/src/test_grabbag/cuesheet/test_cuesheet.dsp @@ -0,0 +1,96 @@ +# Microsoft Developer Studio Project File - Name="test_cuesheet" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=test_cuesheet - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "test_cuesheet.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "test_cuesheet.mak" CFG="test_cuesheet - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "test_cuesheet - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "test_cuesheet - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "test_cuesheet - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "..\..\..\obj\release\bin" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "..\..\..\include" /D "NDEBUG" /D "FLAC__NO_DLL" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /FD /c +# SUBTRACT CPP /YX /Yc /Yu +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 ..\..\obj\release\lib\grabbag_static.lib ..\..\obj\release\lib\libFLAC_static.lib /nologo /subsystem:console /machine:I386 + +!ELSEIF "$(CFG)" == "test_cuesheet - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "..\..\..\obj\debug\bin" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\..\include" /D "_DEBUG" /D "FLAC__NO_DLL" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c +# SUBTRACT CPP /YX /Yc /Yu +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 ..\..\obj\debug\lib\grabbag_static.lib ..\..\obj\debug\lib\libFLAC_static.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "test_cuesheet - Win32 Release" +# Name "test_cuesheet - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "c" +# Begin Source File + +SOURCE=.\main.c +# End Source File +# End Group +# End Target +# End Project