[Scummvm-cvs-logs] SF.net SVN: scummvm:[46359] tools/branches/gsoc2009-gui

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Sun Dec 13 20:49:49 CET 2009


Revision: 46359
          http://scummvm.svn.sourceforge.net/scummvm/?rev=46359&view=rev
Author:   fingolfin
Date:     2009-12-13 19:49:49 +0000 (Sun, 13 Dec 2009)

Log Message:
-----------
GUI TOOLS: Some cleanup (e.g. move compression specific stuff to compress.h, where it belongs)

Modified Paths:
--------------
    tools/branches/gsoc2009-gui/compress.cpp
    tools/branches/gsoc2009-gui/compress.h
    tools/branches/gsoc2009-gui/tool.cpp
    tools/branches/gsoc2009-gui/tool.h
    tools/branches/gsoc2009-gui/util.cpp
    tools/branches/gsoc2009-gui/util.h

Modified: tools/branches/gsoc2009-gui/compress.cpp
===================================================================
--- tools/branches/gsoc2009-gui/compress.cpp	2009-12-13 15:19:56 UTC (rev 46358)
+++ tools/branches/gsoc2009-gui/compress.cpp	2009-12-13 19:49:49 UTC (rev 46359)
@@ -882,10 +882,14 @@
 // The old code can be removed once all tools have been converted
 
 CompressionTool::CompressionTool(const std::string &name, ToolType type) : Tool(name, type) {
+	_supportedFormats = AUDIO_ALL;
 	_format = AUDIO_MP3;
 }
 
 void CompressionTool::parseAudioArguments() {
+	if (_supportedFormats == AUDIO_NONE)
+		return;
+
 	_format = AUDIO_MP3;
 
 	if (_arguments.front() ==  "--mp3")
@@ -978,3 +982,32 @@
 
 	return os.str();
 }
+
+const char *audio_extensions(AudioFormat format) {
+	switch(format) {
+	case AUDIO_MP3:
+		return ".mp3";
+	case AUDIO_VORBIS:
+		return ".ogg";
+	case AUDIO_FLAC:
+		return ".fla";
+	case AUDIO_NONE:
+	default:
+		return ".unk";
+	}
+}
+
+CompressionFormat compression_format(AudioFormat format) {
+	switch(format) {
+	case AUDIO_MP3:
+		return COMPRESSION_MP3;
+	case AUDIO_VORBIS:
+		return COMPRESSION_OGG;
+	case AUDIO_FLAC:
+		return COMPRESSION_FLAC;
+	case AUDIO_NONE:
+	default:
+		throw ToolException("Unknown compression format");
+	}
+}
+

Modified: tools/branches/gsoc2009-gui/compress.h
===================================================================
--- tools/branches/gsoc2009-gui/compress.h	2009-12-13 15:19:56 UTC (rev 46358)
+++ tools/branches/gsoc2009-gui/compress.h	2009-12-13 19:49:49 UTC (rev 46359)
@@ -33,24 +33,21 @@
 #include <FLAC/stream_encoder.h>
 #endif
 
-/* We use string constants here, so we can insert the
- * constants directly into literals
- * These are given integer definitions below
- */
+enum {
+	/* These are the defaults parameters for the Lame invocation */
+	minBitrDef	= 24,
+	maxBitrDef	= 64,
+	algqualDef	= 2,
+	vbrqualDef	= 4,
 
-/* These are the defaults parameters for the Lame invocation */
-#define minBitrDef	24
-#define maxBitrDef 64
-#define algqualDef 2
-#define vbrqualDef 4
+	/* The default for oggenc invocation is to use the --quality option only */
+	oggqualDef	= 3,
 
-/* The default for oggenc invocation is to use the --quality option only */
-#define oggqualDef 3
+	/* These are the default parameters for the FLAC invocation */
+	flacCompressDef		= 8,
+	flacBlocksizeDef	= 1152
+};
 
-/* These are the default parameters for the FLAC invocation */
-#define flacCompressDef 8
-#define flacBlocksizeDef 1152
-
 #define TEMP_WAV	"tempfile.wav"
 #define TEMP_RAW	"tempfile.raw"
 #define TEMP_MP3	"tempfile.mp3"
@@ -59,10 +56,36 @@
 
 
 
+/** 
+ * Different audio formats.
+ * You can bitwise them to represent several formats.
+ */
+enum AudioFormat {
+	AUDIO_NONE = 0,
+	AUDIO_VORBIS = 1,
+	AUDIO_FLAC = 2,
+	AUDIO_MP3 = 4,
+	AUDIO_ALL = AUDIO_VORBIS | AUDIO_FLAC | AUDIO_MP3
+};
+
 /**
- * Compression tool
- * A tool, which can compress to either MP3, Vorbis or FLAC formats
+ * Another enum, which cannot be ORed.
+ * These are the values written to the output files.
  */
+enum CompressionFormat {
+	COMPRESSION_NONE = 0,
+	COMPRESSION_MP3 = 1,
+	COMPRESSION_OGG = 2,
+	COMPRESSION_FLAC = 3
+};
+
+const char *audio_extensions(AudioFormat format);
+CompressionFormat compression_format(AudioFormat format);
+
+
+/**
+ * A tool, which can compress to either MP3, Vorbis or FLAC formats.
+ */
 class CompressionTool : public Tool {
 public:
 	CompressionTool(const std::string &name, ToolType type);
@@ -70,7 +93,11 @@
 	virtual std::string getHelp() const;
 
 	void parseAudioArguments();
-public:
+
+protected:
+	/** Formats supported by this tool. */
+	AudioFormat _supportedFormats;
+
 	AudioFormat _format;
 
 	// Settings
@@ -85,13 +112,13 @@
 	// flac
 	std::string _flacCompressionLevel;
 	std::string _flacBlockSize;
-	
+
 	// vorbis
 	std::string _oggQuality;
 	std::string _oggMinBitrate;
 	std::string _oggAvgBitrate;
 	std::string _oggMaxBitrate;
-	
+
 public:
 	bool processMp3Parms();
 	bool processOggParms();
@@ -107,6 +134,8 @@
 
 /*
  * Stuff which is in compress.cpp
+ *
+ * TODO: What is this? Document it?
  */
 const extern char *tempEncoded;
 

Modified: tools/branches/gsoc2009-gui/tool.cpp
===================================================================
--- tools/branches/gsoc2009-gui/tool.cpp	2009-12-13 15:19:56 UTC (rev 46358)
+++ tools/branches/gsoc2009-gui/tool.cpp	2009-12-13 19:49:49 UTC (rev 46359)
@@ -33,7 +33,6 @@
 	_type = type;
 
 	_outputToDirectory = true;
-	_supportedFormats = AUDIO_ALL;
 	_supportsProgressBar = false;
 
 	_internalPrint = standardPrint;
@@ -67,8 +66,7 @@
 	}
 
 	// Read standard arguments
-	if (_supportedFormats != AUDIO_NONE)
-		parseAudioArguments();
+	parseAudioArguments();
 	parseOutputArguments();
 	// Read tool specific arguments
 	parseExtraArguments();

Modified: tools/branches/gsoc2009-gui/tool.h
===================================================================
--- tools/branches/gsoc2009-gui/tool.h	2009-12-13 15:19:56 UTC (rev 46358)
+++ tools/branches/gsoc2009-gui/tool.h	2009-12-13 19:49:49 UTC (rev 46359)
@@ -210,8 +210,6 @@
 
 	/** If this tools outputs to a directory, not a file. */
 	bool _outputToDirectory;
-	/** Formats supported by this tool. */
-	AudioFormat _supportedFormats;
 	/** If this tool can display output progress in % */
 	bool _supportsProgressBar;
 

Modified: tools/branches/gsoc2009-gui/util.cpp
===================================================================
--- tools/branches/gsoc2009-gui/util.cpp	2009-12-13 15:19:56 UTC (rev 46358)
+++ tools/branches/gsoc2009-gui/util.cpp	2009-12-13 19:49:49 UTC (rev 46359)
@@ -28,34 +28,6 @@
 	#define	vsnprintf _vsnprintf
 #endif
 
-const char *audio_extensions(AudioFormat format) {
-	switch(format) {
-	case AUDIO_MP3:
-		return ".mp3";
-	case AUDIO_VORBIS:
-		return ".ogg";
-	case AUDIO_FLAC:
-		return ".fla";
-	case AUDIO_NONE:
-	default:
-		return ".unk";
-	}
-}
-
-CompressionFormat compression_format(AudioFormat format) {
-	switch(format) {
-	case AUDIO_MP3:
-		return COMPRESSION_MP3;
-	case AUDIO_VORBIS:
-		return COMPRESSION_OGG;
-	case AUDIO_FLAC:
-		return COMPRESSION_FLAC;
-	case AUDIO_NONE:
-	default:
-		throw ToolException("Unknown compression format");
-	}
-}
-
 void error(const char *s, ...) {
 	char buf[1024];
 	va_list va;

Modified: tools/branches/gsoc2009-gui/util.h
===================================================================
--- tools/branches/gsoc2009-gui/util.h	2009-12-13 15:19:56 UTC (rev 46358)
+++ tools/branches/gsoc2009-gui/util.h	2009-12-13 19:49:49 UTC (rev 46359)
@@ -43,17 +43,13 @@
 #include <string>
 #include <stdexcept>
 
-
 /*
  * GCC specific stuff
  */
 #if defined(__GNUC__)
-        #define GCC_PACK __attribute__((packed))
-        #define NORETURN __attribute__((__noreturn__))
-        #define GCC_PRINTF(x,y) __attribute__((format(printf, x, y)))
+	#define GCC_PACK __attribute__((packed))
 #else
-        #define GCC_PACK
-        #define GCC_PRINTF(x,y)
+	#define GCC_PACK
 #endif
 
 #ifndef ARRAYSIZE
@@ -143,31 +139,4 @@
 void debug(int level, const char *s, ...);
 void notice(const char *s, ...);
 
-
-/** 
- * Different audio formats
- * You can bitwise them to represent several formats
- */
-enum AudioFormat {
-	AUDIO_NONE = 0,
-	AUDIO_VORBIS = 1,
-	AUDIO_FLAC = 2,
-	AUDIO_MP3 = 4,
-	AUDIO_ALL = AUDIO_VORBIS | AUDIO_FLAC | AUDIO_MP3
-};
-
-/**
- * Another enum, which cannot be ORed
- * These are the values written to the output files
- */
-enum CompressionFormat {
-	COMPRESSION_NONE = 0,
-	COMPRESSION_MP3 = 1,
-	COMPRESSION_OGG = 2,
-	COMPRESSION_FLAC = 3
-};
-
-const char *audio_extensions(AudioFormat format);
-CompressionFormat compression_format(AudioFormat format);
-
 #endif


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list