changeset 257:e0dc4cc45d26 trunk

[svn] - NewVFS probe support
author nenolod
date Sat, 18 Nov 2006 11:46:50 -0800
parents acb93b546742
children 1987fda01d2a
files ChangeLog src/mpg123/mpg123.c
diffstat 2 files changed, 39 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Nov 18 11:46:19 2006 -0800
+++ b/ChangeLog	Sat Nov 18 11:46:50 2006 -0800
@@ -1,3 +1,10 @@
+2006-11-18 19:46:19 +0000  Tony Vroon <chainsaw@gentoo.org>
+  revision [536]
+  Port to NewVFS probe function.
+  trunk/src/alac/plugin.c |   16 ++++++----------
+  1 file changed, 6 insertions(+), 10 deletions(-)
+
+
 2006-11-18 19:20:57 +0000  Tony Vroon <chainsaw@gentoo.org>
   revision [534]
   Port to NewVFS probe function.
--- a/src/mpg123/mpg123.c	Sat Nov 18 11:46:19 2006 -0800
+++ b/src/mpg123/mpg123.c	Sat Nov 18 11:46:50 2006 -0800
@@ -271,9 +271,8 @@
 #define DET_BUF_SIZE 4096
 
 static gboolean
-mpgdec_detect_by_content(char *filename)
+mpgdec_detect_by_content(VFSFile *file)
 {
-    VFSFile *file;
     guchar tmp[4];
     guint32 head;
     struct frame fr;
@@ -282,8 +281,6 @@
     gboolean ret = FALSE;
     guint cyc = 0;
 
-    if ((file = vfs_fopen(filename, "rb")) == NULL)
-        return FALSE;
     if (vfs_fread(tmp, 1, 4, file) != 4)
         goto done;
     if (!memcmp(tmp, "ID3", 3))
@@ -340,29 +337,45 @@
     }
 
   done:
-    vfs_fclose(file);
     return ret;
 }
 
 static int
 is_our_file(char *filename)
 {
+    VFSFile *file;
     gchar *ext = strrchr(filename, '.');
+    gboolean ret = FALSE;
+
+    file = vfs_fopen(filename, "rb");
 
     if (CHECK_STREAM_URI(filename) &&
         (ext && strncasecmp(ext, ".ogg", 4)) &&
         (ext && strncasecmp(ext, ".flac", 5)))
-	return TRUE;
-    else if (mpgdec_detect_by_content(filename))
-        return TRUE;
-#if 0
-    else if (ext && (!strncasecmp(ext, ".mp3", 4)
-	|| !strncasecmp(ext, ".mp2", 4)
-	|| !strncasecmp(ext, ".mpg", 4)))
-        return TRUE;
-#endif
+	ret = TRUE;
+    else if (mpgdec_detect_by_content(file))
+        ret = TRUE;
+
+    if (file != NULL)
+        vfs_fclose(file);
+
+    return ret;
+}
 
-    return FALSE;
+static int
+is_our_fd(char *filename, VFSFile *file)
+{
+    gchar *ext = strrchr(filename, '.');
+    gboolean ret = FALSE;
+
+    if (CHECK_STREAM_URI(filename) &&
+        (ext && strncasecmp(ext, ".ogg", 4)) &&
+        (ext && strncasecmp(ext, ".flac", 5)))
+	ret = TRUE;
+    else if (mpgdec_detect_by_content(file))
+        ret = TRUE;
+
+    return ret;
 }
 
 static void
@@ -994,7 +1007,10 @@
     get_song_info,
     mpgdec_file_info_box,       /* file_info_box */
     NULL,
-    get_song_tuple
+    get_song_tuple,
+    NULL,
+    NULL,
+    is_our_fd,
 };
 
 InputPlugin *