changeset 1539:488f7e6c36ed

Tuple builder for modplug. Someone do me a favour and fix getinfo to do something like the one in console.
author Tony Vroon <chainsaw@gentoo.org>
date Thu, 30 Aug 2007 23:38:01 +0100
parents da1aa3c38cda
children ebeab5b388bc
files src/modplug/modplugbmp.cxx src/modplug/modplugbmp.h src/modplug/plugin.cxx
diffstat 3 files changed, 117 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/modplug/modplugbmp.cxx	Thu Aug 30 18:55:36 2007 +0200
+++ b/src/modplug/modplugbmp.cxx	Thu Aug 30 23:38:01 2007 +0100
@@ -13,10 +13,12 @@
 #include "sndfile.h"
 #include "stddefs.h"
 #include "archive/open.h"
+extern "C" {
 #include "audacious/configdb.h"
+#include "audacious/output.h"
+#include "audacious/tuple.h"
+#include "audacious/tuple_formatter.h"
 #include "audacious/vfs.h"
-extern "C" {
-#include "audacious/output.h"
 }
 
 // ModplugXMMS member functions ===============================
@@ -638,6 +640,102 @@
 	delete lArchive;
 }
 
+Tuple* ModplugXMMS::GetSongTuple(const string& aFilename)
+{
+	CSoundFile* lSoundFile;
+	Archive* lArchive;
+	
+	//open and mmap the file
+        lArchive = OpenArchive(aFilename);
+        if(lArchive->Size() == 0)
+        {
+                delete lArchive;
+                return NULL;
+        }
+
+	Tuple *ti = tuple_new_from_filename(aFilename.c_str());
+	lSoundFile = new CSoundFile;
+	lSoundFile->Create((uchar*)lArchive->Map(), lArchive->Size());
+	switch(lSoundFile->GetType())
+        {
+	case MOD_TYPE_MOD:
+		tuple_associate_string(ti, "codec", "ProTracker");
+		break;
+	case MOD_TYPE_S3M:
+		tuple_associate_string(ti, "codec", "Scream Tracker 3");
+		break;
+	case MOD_TYPE_XM:
+		tuple_associate_string(ti, "codec", "Fast Tracker 2");
+		break;
+	case MOD_TYPE_IT:
+		tuple_associate_string(ti, "codec", "Impulse Tracker");
+		break;
+	case MOD_TYPE_MED:
+		tuple_associate_string(ti, "codec", "OctaMed");
+		break;
+	case MOD_TYPE_MTM:
+		tuple_associate_string(ti, "codec", "MTM");
+		break;
+	case MOD_TYPE_669:
+		tuple_associate_string(ti, "codec", "669 Composer / UNIS 669");
+		break;
+	case MOD_TYPE_ULT:
+		tuple_associate_string(ti, "codec", "ULT");
+		break;
+	case MOD_TYPE_STM:
+		tuple_associate_string(ti, "codec", "Scream Tracker");
+		break;
+	case MOD_TYPE_FAR:
+		tuple_associate_string(ti, "codec", "Farandole");
+		break;
+	case MOD_TYPE_AMF:
+		tuple_associate_string(ti, "codec", "ASYLUM Music Format");
+		break;
+	case MOD_TYPE_AMS:
+		tuple_associate_string(ti, "codec", "AMS module");
+		break;
+	case MOD_TYPE_DSM:
+		tuple_associate_string(ti, "codec", "DSIK Internal Format");
+		break;
+	case MOD_TYPE_MDL:
+		tuple_associate_string(ti, "codec", "DigiTracker");
+		break;
+	case MOD_TYPE_OKT:
+		tuple_associate_string(ti, "codec", "Oktalyzer");
+		break;
+	case MOD_TYPE_DMF:
+		tuple_associate_string(ti, "codec", "Delusion Digital Music Fileformat (X-Tracker)");
+		break;
+	case MOD_TYPE_PTM:
+		tuple_associate_string(ti, "codec", "PolyTracker");
+		break;
+	case MOD_TYPE_DBM:
+		tuple_associate_string(ti, "codec", "DigiBooster Pro");
+		break;
+	case MOD_TYPE_MT2:
+		tuple_associate_string(ti, "codec", "MT2");
+		break;
+	case MOD_TYPE_AMF0:
+		tuple_associate_string(ti, "codec", "AMF0");
+		break;
+	case MOD_TYPE_PSM:
+		tuple_associate_string(ti, "codec", "PSM");
+		break;
+	default:
+		tuple_associate_string(ti, "codec", "ModPlug unknown");
+		break;
+	}
+	tuple_associate_string(ti, "quality", "sequenced");
+	tuple_associate_string(ti, "title", lSoundFile->GetTitle());
+	tuple_associate_int(ti, "length", lSoundFile->GetSongTime() * 1000);
+	
+	//unload the file
+	lSoundFile->Destroy();
+	delete lSoundFile;
+	delete lArchive;
+	return ti;
+}
+
 void ModplugXMMS::SetInputPlugin(InputPlugin& aInPlugin)
 {
 	mInPlug = &aInPlugin;
--- a/src/modplug/modplugbmp.h	Thu Aug 30 18:55:36 2007 +0200
+++ b/src/modplug/modplugbmp.h	Thu Aug 30 23:38:01 2007 +0100
@@ -14,7 +14,11 @@
 #include "stddefs.h"
 #endif
 
+extern "C" {
 #include "audacious/plugin.h"
+#include "audacious/tuple.h"
+#include "audacious/tuple_formatter.h"
+}
 
 /* Module files have their magic deep inside the file, at offset 1080; source: http://www.onicos.com/staff/iz/formats/mod.html and information by Michael Doering from UADE */
 #define MOD_MAGIC_PROTRACKER4	(unsigned char [4]) { 0x4D, 0x2E, 0x4B, 0x2E }  // "M.K." - Protracker 4 channel
@@ -96,6 +100,7 @@
 	float32 GetTime();                   // Get the current play time.
 
 	void GetSongInfo(const string& aFilename, char*& aTitle, int32& aLength); // Function to grab the title string
+	Tuple* GetSongTuple(const string& aFilename);
 
 	void SetInputPlugin(InputPlugin& aInPlugin);
 	void SetOutputPlugin(OutputPlugin& aOutPlugin);
--- a/src/modplug/plugin.cxx	Thu Aug 30 18:55:36 2007 +0200
+++ b/src/modplug/plugin.cxx	Thu Aug 30 23:38:01 2007 +0100
@@ -4,9 +4,13 @@
  * This source code is public domain.
  */
 
-#include "audacious/plugin.h"
 #include "modplug.h"
 #include "gui/main.h"
+extern "C" {
+#include "audacious/plugin.h"
+#include "audacious/tuple.h"
+#include "audacious/tuple_formatter.h"
+}
 
 extern InputPlugin gModPlug;
 
@@ -44,6 +48,7 @@
 {
 	gModplugXMMS.Seek(float32(aTime));
 }
+
 static int GetTime(InputPlayback *data)
 {
 	float32 lTime;
@@ -60,6 +65,11 @@
 	gModplugXMMS.GetSongInfo(aFilename, *aTitle, *aLength);
 }
 
+static Tuple* GetSongTuple(char* aFilename)
+{
+	return gModplugXMMS.GetSongTuple(aFilename);
+}
+
 void ShowAboutBox(void)
 {
 	ShowAboutWindow();
@@ -106,7 +116,7 @@
 	GetSongInfo,
 	ShowFileInfoBox,
 	NULL,	// output
-	NULL,   // tuple
+	GetSongTuple,
 	NULL,
 	NULL,
 	CanPlayFileFromVFS,	// vfs