changeset 1336:0fdf6ee112f5

Automated merge with ssh://majeru@hg.atheme.org//hg/audacious-plugins
author Cristi Magherusan <majeru@atheme-project.org>
date Sun, 22 Jul 2007 17:36:12 +0300
parents 59699988d194 (current diff) 4b07404814ca (diff)
children 831720848162
files
diffstat 2 files changed, 28 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/src/madplug/fileinfo.c	Sun Jul 22 17:34:21 2007 +0300
+++ b/src/madplug/fileinfo.c	Sun Jul 22 17:36:12 2007 +0300
@@ -587,7 +587,7 @@
         ("single channel"), ("dual channel"), "joint stereo", "stereo"
     };
     gchar *tmp, *utf_filename;
-
+    gchar *realfn = NULL;
 #ifdef DEBUG
     {
         tmp = str_to_utf8(fileurl);
@@ -597,7 +597,7 @@
     }
 #endif
 
-    if(!vfs_file_test(fileurl, G_FILE_TEST_EXISTS)) {
+    if(!vfs_is_remote(fileurl) && !vfs_file_test(fileurl, G_FILE_TEST_EXISTS)) {
         return;
     }
 
@@ -605,23 +605,13 @@
 
     if(audmad_is_remote(fileurl)) {
         info.remote = TRUE;
-        return; //file info dialog for remote streaming doesn't make sense.
+        if(vfs_is_streaming(info.infile))
+           return; //file info dialog for remote streaming doesn't make sense.
     }
 
-    tmp = g_filename_from_uri(fileurl, NULL, NULL);
-    if (tmp == NULL)
-    {
-#ifdef DEBUG
-        tmp = str_to_utf8(fileurl);
-        g_message("f: audmad_get_file_info: %s , g_filename_from_uri failed", tmp);
-        g_free(tmp);
-        tmp = NULL;
-#endif
-        return;
-    }
-    utf_filename = str_to_utf8(tmp);
-    g_free(tmp);
-    tmp = NULL;
+    realfn = g_filename_from_uri(fileurl, NULL, NULL);
+    utf_filename = str_to_utf8(realfn ? realfn : fileurl);
+    g_free(realfn); realfn = NULL;
     create_window();
 
     info.fileinfo_request = TRUE;
--- a/src/madplug/plugin.c	Sun Jul 22 17:34:21 2007 +0300
+++ b/src/madplug/plugin.c	Sun Jul 22 17:36:12 2007 +0300
@@ -288,12 +288,8 @@
 
 gboolean audmad_is_remote(gchar *url)
 {
-    if (!strncasecmp("http://", url, 7)
-        || !strncasecmp("https://", url, 8)
-        || !strncasecmp("lastfm://", url, 9))
-        return TRUE;
-    else
-        return FALSE;
+    gboolean rv = vfs_is_remote(url);
+    return rv;
 }
 
 // audacious vfs fast version
@@ -638,6 +634,8 @@
     struct id3_file *id3file = NULL;
     struct id3_tag *tag = NULL;
 
+    gboolean local_fd = FALSE;
+
 #ifdef DEBUG
     string = str_to_utf8(filename);
     g_message("f: mad: audmad_get_song_tuple: %s", string);
@@ -646,7 +644,7 @@
 #endif
 
     if(info.remote && mad_timer_count(info.duration, MAD_UNITS_SECONDS) <= 0){
-        if(fd || (info.playback && info.playback->playing)) {
+        if((fd && vfs_is_streaming(fd)) || (info.playback && info.playback->playing)) {
             gchar *tmp = NULL;
             tuple = bmp_title_input_new();
 
@@ -692,10 +690,15 @@
 
     tuple = bmp_title_input_new();
 
-    if (!fd)
-        id3file = id3_file_open(filename, ID3_FILE_MODE_READONLY);
-    else
-        id3file = id3_file_vfsopen(fd, ID3_FILE_MODE_READONLY);
+    // if !fd, pre-open the file with vfs_fopen() and reuse fd.
+    if(!fd) {
+        fd = vfs_fopen(filename, "rb");
+        if(!fd)
+            return NULL;
+        local_fd = TRUE;
+    }
+
+    id3file = id3_file_vfsopen(fd, ID3_FILE_MODE_READONLY);
 
     if (id3file) {
 
@@ -739,7 +742,7 @@
             else {
                 char *dummy = NULL;
                 int length = 0;
-                audmad_get_song_length(filename, &length, fd ? fd : NULL);
+                audmad_get_song_length(filename, &length, fd);
                 tuple->length = length;
                 g_free(dummy);
             }
@@ -762,7 +765,7 @@
 
         }
         id3_file_close(id3file);
-    }
+    } // id3file
     else { // no id3tag
         realfn = g_filename_from_uri(filename, NULL, NULL);
         tuple->file_name = g_path_get_basename(realfn ? realfn : filename);
@@ -774,12 +777,16 @@
             char *dummy = NULL;
             int length = 0;
             if(tuple->length == -1) {
-                audmad_get_song_length(filename, &length, fd ? fd : NULL);
+                audmad_get_song_length(filename, &length, fd);
                 tuple->length = length;
             }
             g_free(dummy);
         }
     }
+
+    if(local_fd)
+        vfs_fclose(fd);
+
 #ifdef DEBUG
     g_message("e: mad: audmad_get_song_tuple");
 #endif