changeset 1311:4ececb6a4acb trunk

[svn] RMI support for timidity by nemo, for which he would like to credit giacomos amidi-plug detection code.
author chainsaw
date Mon, 19 Jun 2006 10:52:13 -0700
parents ff98136a93d2
children f7244db08f40
files ChangeLog Plugins/Input/timidity/libtimidity/readmidi.c Plugins/Input/timidity/src/xmms-timidity.c
diffstat 3 files changed, 67 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Jun 19 02:29:23 2006 -0700
+++ b/ChangeLog	Mon Jun 19 10:52:13 2006 -0700
@@ -1,3 +1,12 @@
+2006-06-19 09:29:23 +0000  William Pitcock <nenolod@nenolod.net>
+  revision [1532]
+  - title streaming works again, but we aren't pushing back to the playlist quite yet
+  
+
+  Changes:        Modified:
+  +65 -50         trunk/Plugins/Input/vorbis/vorbis.c  
+
+
 2006-06-19 08:51:01 +0000  William Pitcock <nenolod@nenolod.net>
   revision [1530]
   - if tuple->length == -1 then don't show a length
--- a/Plugins/Input/timidity/libtimidity/readmidi.c	Mon Jun 19 02:29:23 2006 -0700
+++ b/Plugins/Input/timidity/libtimidity/readmidi.c	Mon Jun 19 10:52:13 2006 -0700
@@ -519,7 +519,32 @@
       return 0;
     }
   len=SWAPBE32(len);
-  if (memcmp(tmp, "MThd", 4) || len < 6)
+  if (strncmp(tmp, "MThd", 4) != 0)
+    {
+      if ( !strncmp( tmp , "RIFF" , 4 ) )
+        {
+          mid_istream_read(stream, tmp, 1, 4);
+          if ( strncmp( tmp , "RMID" , 4 ) != 0)
+            {
+              DEBUG_MSG("Not a MIDI file!\n");
+              return 0;
+            }
+          else
+            {
+              mid_istream_read(stream, tmp, 1, 4);
+              mid_istream_read(stream, tmp, 1, 4);
+              mid_istream_read(stream, tmp, 1, 4);
+              mid_istream_read(stream, &len, 4, 1);
+              len=SWAPBE32(len);
+            }
+        }
+        else
+        {
+          DEBUG_MSG("Not a MIDI file!\n");
+          return 0;
+        }
+    }
+  if (len < 6)
     {
       DEBUG_MSG("Not a MIDI file!\n");
       return 0;
--- a/Plugins/Input/timidity/src/xmms-timidity.c	Mon Jun 19 02:29:23 2006 -0700
+++ b/Plugins/Input/timidity/src/xmms-timidity.c	Mon Jun 19 10:52:13 2006 -0700
@@ -238,18 +238,38 @@
 	gtk_widget_hide(xmmstimid_conf_wnd);
 }
 
-int xmmstimid_is_our_file(char *filename) {
-	VFSFile *file;
-	gchar magic[4];
-	if ((file = vfs_fopen(filename, "rb"))) {
-		vfs_fread(magic, 1, 4, file);
-		if (!strncmp(magic, "MThd", 4)) {
-			vfs_fclose(file);
-			return 1;
-		}
-		vfs_fclose(file);
-        }
-	return 0;
+static gint xmmstimid_is_our_file( gchar * filename )
+{
+    VFSFile * fp;
+    gchar magic_bytes[4];
+
+    fp = vfs_fopen( filename , "rb" );
+
+    if (fp == NULL)
+	return FALSE;
+
+    vfs_fread( magic_bytes , 1 , 4 , fp );
+
+    if ( !strncmp( magic_bytes , "MThd" , 4 ) )
+    {
+      vfs_fclose( fp );
+      return TRUE;
+    }
+
+    if ( !strncmp( magic_bytes , "RIFF" , 4 ) )
+    {
+      /* skip the four bytes after RIFF,
+         then read the next four */
+      vfs_fseek( fp , 4 , SEEK_CUR );
+      vfs_fread( magic_bytes , 1 , 4 , fp );
+      if ( !strncmp( magic_bytes , "RMID" , 4 ) )
+      {
+        vfs_fclose( fp );
+        return TRUE;
+      }
+    }
+    vfs_fclose( fp );
+  return FALSE;
 }
 
 static void *xmmstimid_play_loop(void *arg) {