commit 42ff0255bd1d6989dc67c7d924dabda904c95000
Author: phantomjinx <p.g.richard...@phantomjinx.co.uk>
Date:   Tue Feb 22 23:10:41 2011 +0000

    Fix embedded artwork not being loaded
    
    * Embedded artwork is initially detected and displayed. However, on quitting
      and restarting the artwork is no longer displayed.
    
    * Embedded artwork is only read by the individual filetypes, specifically
      mp3. This file info is never read on startup of the application.
    
    * file_itunesdb.c
     * Add an extra clause to get the track info using the filetypes.
    
    * file.[ch]
     * Make the get_track_info_from_file function available
    
    * gp_init.[ch]
    * gtkpod.c
     * In order to use get_track_info_from_file at startup, all the plugins
       have to be loaded BEFORE it gets called.
     * gp_init is responsible for importing all the itdbs so this needs to be
       split so that all the important bits n pieces are initialised but the
       itbbs are loaded later.
     * gp_init_itdbs is called after all the plugins have been loaded so all
       the itdbs are still fully initialised by the time the gui is displayed

 libgtkpod/file.c          |    2 +-
 libgtkpod/file.h          |    7 +++++++
 libgtkpod/file_itunesdb.c |    8 ++++++++
 libgtkpod/gp_itdb.c       |   24 +++++++++++++++---------
 libgtkpod/gp_itdb.h       |    1 +
 src/gtkpod.c              |    5 +++++
 6 files changed, 37 insertions(+), 10 deletions(-)
---
diff --git a/libgtkpod/file.c b/libgtkpod/file.c
index d2b7c4c..7efa915 100644
--- a/libgtkpod/file.c
+++ b/libgtkpod/file.c
@@ -988,7 +988,7 @@ static void add_coverart(Track *tr) {
  * pc_path_utf8 and pc_path_locale are not changed if an entry already
  * exists. time_added is not modified if already set. */
 /* Returns NULL on error, a pointer to the Track otherwise */
-static Track *get_track_info_from_file(gchar *name, Track *orig_track) {
+Track *get_track_info_from_file(gchar *name, Track *orig_track) {
     Track *track = NULL;
     Track *nti = NULL;
     FileType *filetype;
diff --git a/libgtkpod/file.h b/libgtkpod/file.h
index 36c53be..1756404 100644
--- a/libgtkpod/file.h
+++ b/libgtkpod/file.h
@@ -55,6 +55,13 @@ typedef enum
 typedef void (*AddTrackFunc)(Playlist *plitem, Track *track, gpointer data);
 
 FileType *determine_filetype (const gchar *path);
+
+/*
+ * Used inside file functions but also used in file_itunesdb for importing
+ * itdbs. Embedded artwork can be read using this.
+ */
+Track *get_track_info_from_file(gchar *name, Track *orig_track);
+
 gboolean add_track_by_filename (iTunesDB *itdb, gchar *name,
                                Playlist *plitem, gboolean descend,
                                AddTrackFunc addtrackfunc, gpointer data);
diff --git a/libgtkpod/file_itunesdb.c b/libgtkpod/file_itunesdb.c
index 47ac03c..151e9a4 100644
--- a/libgtkpod/file_itunesdb.c
+++ b/libgtkpod/file_itunesdb.c
@@ -107,6 +107,7 @@ void fill_in_extended_info(Track *track, gint32 total, 
gint32 num) {
     gint ipod_id = 0;
     ExtraTrackData *etr;
     struct track_extended_info *sei = NULL;
+    gchar *trackpath;
 
     g_return_if_fail (track);
     etr = track->userdata;
@@ -160,6 +161,13 @@ void fill_in_extended_info(Track *track, gint32 total, 
gint32 num) {
         if (extendedinfohash)
             g_hash_table_remove(extendedinfohash, &ipod_id);
     }
+
+    /* Try reading artwork data using the filetype of the track */
+    trackpath = get_file_name_from_source(track, SOURCE_PREFER_LOCAL);
+    if (trackpath) {
+        get_track_info_from_file(trackpath, track);
+        g_free(trackpath);
+    }
 }
 
 /* Used to free the memory of hash data */
diff --git a/libgtkpod/gp_itdb.c b/libgtkpod/gp_itdb.c
index 2d84e52..9188fab 100644
--- a/libgtkpod/gp_itdb.c
+++ b/libgtkpod/gp_itdb.c
@@ -789,7 +789,6 @@ void gp_track_cleanup_empty_strings (Track *track)
  */
 void gp_init(int argc, char *argv[]) {
     gchar *cfgdir;
-    gint i;
 
     prefs_init(argc, argv);
     cfgdir = prefs_get_cfgdir();
@@ -818,6 +817,21 @@ void gp_init(int argc, char *argv[]) {
         g_free(filename);
     }
 
+    /* Initiate autodetection */
+    autodetection_init();
+
+    /* initiate client server */
+    server_setup();
+
+    g_free(cfgdir);
+}
+
+/**
+ * Initialise all the itunes databases
+ */
+void gp_init_itdbs() {
+    gint i;
+
     for (i = 0;; ++i) {
         ExtraiTunesDBData *eitdb;
         iTunesDB *itdb = setup_itdb_n(i);
@@ -839,14 +853,6 @@ void gp_init(int argc, char *argv[]) {
             itdb_spl_update_live(itdb);
         }
     }
-
-    /* Initiate autodetection */
-    autodetection_init();
-
-    /* initiate client server */
-    server_setup();
-
-    g_free(cfgdir);
 }
 
 /* Create an repository according to the settings in the preferences
diff --git a/libgtkpod/gp_itdb.h b/libgtkpod/gp_itdb.h
index 7c621fd..74e6b71 100644
--- a/libgtkpod/gp_itdb.h
+++ b/libgtkpod/gp_itdb.h
@@ -122,6 +122,7 @@ struct DeleteData
     DeleteAction deleteaction;
 };
 
+void gp_init_itdbs();
 iTunesDB *setup_itdb_n (gint i);
 
 struct itdbs_head *gp_get_itdbs_head ();
diff --git a/src/gtkpod.c b/src/gtkpod.c
index 0dae804..5bce2e1 100644
--- a/src/gtkpod.c
+++ b/src/gtkpod.c
@@ -94,6 +94,7 @@ void gtkpod_init(int argc, char *argv[]) {
      * initialise gtkpod library items. Needs to be safety threaded due
      * to splash screen.
      */
+
     gdk_threads_enter();
     gp_init(argc, argv);
     gdk_threads_leave();
@@ -167,6 +168,10 @@ void gtkpod_init(int argc, char *argv[]) {
         error = NULL;
     }
 
+    gdk_threads_enter();
+    gp_init_itdbs();
+    gdk_threads_leave();
+
     /* Load layout.*/
     session_dir = g_build_filename(g_get_home_dir(), ".gtkpod", "session", 
NULL);
     if (! g_file_test(session_dir, G_FILE_TEST_IS_DIR))

------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev 
_______________________________________________
gtkpod-cvs2 mailing list
gtkpod-cvs2@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2

Reply via email to