changeset 2564:b24eda79942b

Fixes to ModPlug plugin - don't allow song to loop infinitely, correct loading from archive.
author Sergiy Pylypenko <x.pelya.x@gmail.com>
date Mon, 12 May 2008 15:34:58 +0300
parents 38f3540d6b06
children 6fd05978fd4b
files src/modplug/archive/open.cxx src/modplug/sndmix.cxx
diffstat 2 files changed, 87 insertions(+), 83 deletions(-) [+]
line wrap: on
line diff
--- a/src/modplug/archive/open.cxx	Mon May 12 02:33:43 2008 +0300
+++ b/src/modplug/archive/open.cxx	Mon May 12 15:34:58 2008 +0300
@@ -13,9 +13,11 @@
 
 Archive* OpenArchive(const string& aFileName) //aFilename is url --yaz
 {
+	// TODO: archive support in Modplug plugin is broken - it uses popen() call and Unix commandline tools for that.
+	// Plus Modplug allows only one audio file per archive which is wrong anyway.
+
 	string lExt;
 	uint32 lPos;
-
 	// convert from uri to fs based filepath
 	gchar *filename;
 	filename = g_filename_from_uri(aFileName.c_str(), NULL, NULL);
@@ -23,48 +25,49 @@
 	g_free(filename);
 
 	lPos = lRealFileName.find_last_of('.');
-	if(lPos > lRealFileName.length())
-		return NULL;
-	lExt = lRealFileName.substr(lPos);
-	for(uint32 i = 0; i < lExt.length(); i++)
-		lExt[i] = tolower(lExt[i]);
+	if(lPos <= lRealFileName.length() && aFileName.find("file://") == 0)
+	{
+		lExt = lRealFileName.substr(lPos);
+		for(uint32 i = 0; i < lExt.length(); i++)
+			lExt[i] = tolower(lExt[i]);
 
-	if (lExt == ".mdz")
-		return new arch_Zip(lRealFileName);
-	if (lExt == ".mdr")
-		return new arch_Rar(lRealFileName);
-	if (lExt == ".mdgz")
-		return new arch_Gzip(lRealFileName);
-	if (lExt == ".mdbz")
-		return new arch_Bzip2(lRealFileName);
-	if (lExt == ".s3z")
-		return new arch_Zip(lRealFileName);
-	if (lExt == ".s3r")
-		return new arch_Rar(lRealFileName);
-	if (lExt == ".s3gz")
-		return new arch_Gzip(lRealFileName);
-	if (lExt == ".xmz")
-		return new arch_Zip(lRealFileName);
-	if (lExt == ".xmr")
-		return new arch_Rar(lRealFileName);
-	if (lExt == ".xmgz")
-		return new arch_Gzip(lRealFileName);
-	if (lExt == ".itz")
-		return new arch_Zip(lRealFileName);
-	if (lExt == ".itr")
-		return new arch_Rar(lRealFileName);
-	if (lExt == ".itgz")
-		return new arch_Gzip(lRealFileName);
-	if (lExt == ".zip")
-		return new arch_Zip(lRealFileName);
-	if (lExt == ".rar")
-		return new arch_Rar(lRealFileName);
-	if (lExt == ".gz")
-		return new arch_Gzip(lRealFileName);
-	if (lExt == ".bz2")
-		return new arch_Bzip2(lRealFileName);
+		if (lExt == ".mdz")
+			return new arch_Zip(lRealFileName);
+		if (lExt == ".mdr")
+			return new arch_Rar(lRealFileName);
+		if (lExt == ".mdgz")
+			return new arch_Gzip(lRealFileName);
+		if (lExt == ".mdbz")
+			return new arch_Bzip2(lRealFileName);
+		if (lExt == ".s3z")
+			return new arch_Zip(lRealFileName);
+		if (lExt == ".s3r")
+			return new arch_Rar(lRealFileName);
+		if (lExt == ".s3gz")
+			return new arch_Gzip(lRealFileName);
+		if (lExt == ".xmz")
+			return new arch_Zip(lRealFileName);
+		if (lExt == ".xmr")
+			return new arch_Rar(lRealFileName);
+		if (lExt == ".xmgz")
+			return new arch_Gzip(lRealFileName);
+		if (lExt == ".itz")
+			return new arch_Zip(lRealFileName);
+		if (lExt == ".itr")
+			return new arch_Rar(lRealFileName);
+		if (lExt == ".itgz")
+			return new arch_Gzip(lRealFileName);
+		if (lExt == ".zip")
+			return new arch_Zip(lRealFileName);
+		if (lExt == ".rar")
+			return new arch_Rar(lRealFileName);
+		if (lExt == ".gz")
+			return new arch_Gzip(lRealFileName);
+		if (lExt == ".bz2")
+			return new arch_Bzip2(lRealFileName);
+	}
 
-	return new arch_Raw(lRealFileName);
+	return new arch_Raw(aFileName);
 }
 
 bool ContainsMod(const string& aFileName) //aFilename is url --yaz
@@ -79,46 +82,47 @@
 	g_free(filename);
 
 	lPos = lRealFileName.find_last_of('.');
-	if(lPos > lRealFileName.length())
-		return false;
-	lExt = lRealFileName.substr(lPos);
-	for(uint32 i = 0; i < lExt.length(); i++)
-		lExt[i] = tolower(lExt[i]);
+	if(lPos <= lRealFileName.length() && aFileName.find("file://") == 0)
+	{
+		lExt = lRealFileName.substr(lPos);
+		for(uint32 i = 0; i < lExt.length(); i++)
+			lExt[i] = tolower(lExt[i]);
 
-	if (lExt == ".mdz")
-		return arch_Zip::ContainsMod(lRealFileName);
-	if (lExt == ".mdr")
-		return arch_Rar::ContainsMod(lRealFileName);
-	if (lExt == ".mdgz")
-		return arch_Gzip::ContainsMod(lRealFileName);
-	if (lExt == ".mdbz")
-		return arch_Bzip2::ContainsMod(lRealFileName);
-	if (lExt == ".s3z")
-		return arch_Zip::ContainsMod(lRealFileName);
-	if (lExt == ".s3r")
-		return arch_Rar::ContainsMod(lRealFileName);
-	if (lExt == ".s3gz")
-		return arch_Gzip::ContainsMod(lRealFileName);
-	if (lExt == ".xmz")
-		return arch_Zip::ContainsMod(lRealFileName);
-	if (lExt == ".xmr")
-		return arch_Rar::ContainsMod(lRealFileName);
-	if (lExt == ".xmgz")
-		return arch_Gzip::ContainsMod(lRealFileName);
-	if (lExt == ".itz")
-		return arch_Zip::ContainsMod(lRealFileName);
-	if (lExt == ".itr")
-		return arch_Rar::ContainsMod(lRealFileName);
-	if (lExt == ".itgz")
-		return arch_Gzip::ContainsMod(lRealFileName);
-	if (lExt == ".zip")
-		return arch_Zip::ContainsMod(lRealFileName);
-	if (lExt == ".rar")
-		return arch_Rar::ContainsMod(lRealFileName);
-	if (lExt == ".gz")
-		return arch_Gzip::ContainsMod(lRealFileName);
-	if (lExt == ".bz2")
-		return arch_Bzip2::ContainsMod(lRealFileName);
-
-	return arch_Raw::ContainsMod(lRealFileName);
+		if (lExt == ".mdz")
+			return arch_Zip::ContainsMod(lRealFileName);
+		if (lExt == ".mdr")
+			return arch_Rar::ContainsMod(lRealFileName);
+		if (lExt == ".mdgz")
+			return arch_Gzip::ContainsMod(lRealFileName);
+		if (lExt == ".mdbz")
+			return arch_Bzip2::ContainsMod(lRealFileName);
+		if (lExt == ".s3z")
+			return arch_Zip::ContainsMod(lRealFileName);
+		if (lExt == ".s3r")
+			return arch_Rar::ContainsMod(lRealFileName);
+		if (lExt == ".s3gz")
+			return arch_Gzip::ContainsMod(lRealFileName);
+		if (lExt == ".xmz")
+			return arch_Zip::ContainsMod(lRealFileName);
+		if (lExt == ".xmr")
+			return arch_Rar::ContainsMod(lRealFileName);
+		if (lExt == ".xmgz")
+			return arch_Gzip::ContainsMod(lRealFileName);
+		if (lExt == ".itz")
+			return arch_Zip::ContainsMod(lRealFileName);
+		if (lExt == ".itr")
+			return arch_Rar::ContainsMod(lRealFileName);
+		if (lExt == ".itgz")
+			return arch_Gzip::ContainsMod(lRealFileName);
+		if (lExt == ".zip")
+			return arch_Zip::ContainsMod(lRealFileName);
+		if (lExt == ".rar")
+			return arch_Rar::ContainsMod(lRealFileName);
+		if (lExt == ".gz")
+			return arch_Gzip::ContainsMod(lRealFileName);
+		if (lExt == ".bz2")
+			return arch_Bzip2::ContainsMod(lRealFileName);
+	}
+	
+	return arch_Raw::ContainsMod(aFileName);
 }
--- a/src/modplug/sndmix.cxx	Mon May 12 02:33:43 2008 +0300
+++ b/src/modplug/sndmix.cxx	Mon May 12 15:34:58 2008 +0300
@@ -20,7 +20,7 @@
 // Mixing Configuration (SetWaveConfig)
 DWORD CSoundFile::gdwSysInfo = 0;
 DWORD CSoundFile::gnChannels = 1;
-DWORD CSoundFile::gdwSoundSetup = 0;
+DWORD CSoundFile::gdwSoundSetup = SNDMIX_NOBACKWARDJUMPS; // Do not allow song to loop infinitely
 DWORD CSoundFile::gdwMixingFreq = 44100;
 DWORD CSoundFile::gnBitsPerSample = 16;
 // Mixing data initialized in