summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJorg Schuler <jcsjcs@users.sourceforge.net>2005-10-25 16:03:38 +0000
committerJorg Schuler <jcsjcs@users.sourceforge.net>2005-10-25 16:03:38 +0000
commit54bf7f19156e1c361aa25a36dbdc1e4070305aa8 (patch)
treea8b56d820a6a52a14c965097aadf262b3b744de1
parentc2e1d273b12a7e73954d892708d8736c00cfc277 (diff)
downloadlibgpod-tmz-54bf7f19156e1c361aa25a36dbdc1e4070305aa8.tar.gz
libgpod-tmz-54bf7f19156e1c361aa25a36dbdc1e4070305aa8.tar.xz
libgpod-tmz-54bf7f19156e1c361aa25a36dbdc1e4070305aa8.zip
* itdb_itunesdb.c (get_mhip): fixed handling for iTunesDB
versions 4.7 and smaller. git-svn-id: https://gtkpod.svn.sf.net/svnroot/gtkpod/libgpod/trunk@1130 f01d2545-417e-4e96-918e-98f8d0dbbcb6
-rw-r--r--ChangeLog3
-rw-r--r--src/itdb_itunesdb.c22
2 files changed, 20 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 454db40..97f620f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,9 @@
* db-artwork_parser.c (ipod_parse_artwork_db): added assertion
to avoid segfault if called NULL parameter.
+ * itdb_itunesdb.c (get_mhip): fixed handling for iTunesDB
+ versions 4.7 and smaller.
+
2005-10-24 Christophe Fergeau <teuf@gnome.org>
* (itdb_write): remove mountpoint as parameter as not used.
diff --git a/src/itdb_itunesdb.c b/src/itdb_itunesdb.c
index 06a94f9..3efe40c 100644
--- a/src/itdb_itunesdb.c
+++ b/src/itdb_itunesdb.c
@@ -1,4 +1,4 @@
-/* Time-stamp: <2005-10-25 23:49:43 jcs>
+/* Time-stamp: <2005-10-26 01:00:07 jcs>
|
| Copyright (C) 2002-2005 Jorg Schuler <jcsjcs at users sourceforge net>
| Part of the gtkpod project.
@@ -1406,6 +1406,7 @@ static glong get_mhip (FImport *fimp, Itdb_Playlist *plitem,
{
return (GPOINTER_TO_UINT(a) - GPOINTER_TO_UINT(b));
}
+ gboolean first_entry = TRUE;
FContents *cts;
guint32 mhip_hlen, mhip_len, mhod_num, mhod_seek;
Itdb_Track *tr;
@@ -1413,6 +1414,7 @@ static glong get_mhip (FImport *fimp, Itdb_Playlist *plitem,
gint32 mhod_type;
guint32 trackid;
+
g_return_val_if_fail (fimp, -1);
g_return_val_if_fail (plitem, -1);
@@ -1464,7 +1466,7 @@ static glong get_mhip (FImport *fimp, Itdb_Playlist *plitem,
mhod = get_mhod (cts, mhod_seek, &mhod_len);
CHECK_ERROR (fimp, -1);
pos = -1;
- if (mhod.valid)
+ if (mhod.valid && first_entry)
{
/* The posids don't have to be in numeric order, but our
database depends on the playlist members being sorted
@@ -1480,8 +1482,11 @@ static glong get_mhip (FImport *fimp, Itdb_Playlist *plitem,
GUINT_TO_POINTER(mhod.data.track_pos));
/* for speedup: pos==-1 is appending at the end */
if (pos == fimp->pos_len) pos = -1;
+ /* don't call this section more than once (it never
+ should happen except in the case of corrupted
+ iTunesDBs...) */
+ first_entry = FALSE;
}
- break;
}
else
{
@@ -1491,8 +1496,8 @@ static glong get_mhip (FImport *fimp, Itdb_Playlist *plitem,
mhip_seek, cts->filename);
break;
}
- mhod_seek += mhod_len;
}
+ mhod_seek += mhod_len;
}
tr = itdb_track_id_tree_by_id (fimp->idtree, trackid);
@@ -1509,7 +1514,14 @@ static glong get_mhip (FImport *fimp, Itdb_Playlist *plitem,
}
}
- return mhip_seek+mhip_len;
+ /* Up to iTunesd V4.7 or so the mhip_len was set incorrectly
+ (mhip_len == mhip_hlen). In that case we need to find the seek
+ to the next mhip by going through all mhods.
+ */
+ if ((mhip_len == mhip_hlen) && (mhod_num > 0))
+ return mhod_seek;
+ else
+ return mhip_seek+mhip_len;
}