summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJorg Schuler <jcsjcs@users.sourceforge.net>2005-10-11 16:12:04 +0000
committerJorg Schuler <jcsjcs@users.sourceforge.net>2005-10-11 16:12:04 +0000
commit38aaea683fc49a24f24300e74a57e9d562ea86ce (patch)
tree6467970d3ffb87a78e838b68ec6f67a51bd16c28
parenta8f0d03a7efa098546e6808ae0b2adf4d9937e78 (diff)
downloadlibgpod-tmz-38aaea683fc49a24f24300e74a57e9d562ea86ce.tar.gz
libgpod-tmz-38aaea683fc49a24f24300e74a57e9d562ea86ce.tar.xz
libgpod-tmz-38aaea683fc49a24f24300e74a57e9d562ea86ce.zip
* src/itdb_track.c: (itdb_track_add/itdb_track_set_defaults): set
dbid if not set (thanks to Guilherme Salgado for pointing this out) git-svn-id: https://gtkpod.svn.sf.net/svnroot/gtkpod/libgpod/trunk@1117 f01d2545-417e-4e96-918e-98f8d0dbbcb6
-rw-r--r--ChangeLog4
-rw-r--r--src/itdb_playlist.c4
-rw-r--r--src/itdb_track.c26
3 files changed, 31 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 02ebdde..401d81f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,10 @@
* src/itdb_itunesdb.c: (get_mhip): added missing parameter to
a g_warning call, this broke compilation on FC4
+ * src/itdb_track.c: (itdb_track_add/itdb_track_set_defaults): set
+ dbid if not set (thanks to Guilherme Salgado for pointing this
+ out)
+
2005-10-09 Jorg Schuler <jcsjcs at users.sourceforge.net>
* bindings/python/gpod.i: applied Kelvin Lawson's patch to query
diff --git a/src/itdb_playlist.c b/src/itdb_playlist.c
index 4838377..b09bb81 100644
--- a/src/itdb_playlist.c
+++ b/src/itdb_playlist.c
@@ -1,4 +1,4 @@
-/* Time-stamp: <2005-10-02 18:56:09 jcs>
+/* Time-stamp: <2005-10-12 01:04:25 jcs>
|
| Copyright (C) 2002-2005 Jorg Schuler <jcsjcs at users sourceforge net>
| Part of the gtkpod project.
@@ -1076,7 +1076,7 @@ void itdb_playlist_add (Itdb_iTunesDB *itdb, Itdb_Playlist *pl, gint32 pos)
{
id = ((guint64)g_rand_int (grand) << 32) |
((guint64)g_rand_int (grand));
- /* check if id is really random (with 100 playlists the
+ /* check if id is really unique (with 100 playlists the
* chance to create a duplicate is 1 in
* 184,467,440,737,095,516.16) */
for (gl=itdb->playlists; id && gl; gl=gl->next)
diff --git a/src/itdb_track.c b/src/itdb_track.c
index 162abbe..dbfd487 100644
--- a/src/itdb_track.c
+++ b/src/itdb_track.c
@@ -1,4 +1,4 @@
-/* Time-stamp: <2005-09-29 21:02:05 jcs>
+/* Time-stamp: <2005-10-12 01:04:36 jcs>
|
| Copyright (C) 2002-2005 Jorg Schuler <jcsjcs at users sourceforge net>
| Part of the gtkpod project.
@@ -62,6 +62,9 @@ static void itdb_track_set_defaults (Itdb_Track *tr)
gchar *audible_subdesc[] = {"Audible", "audible", "Book", "book", NULL};
gchar *wav_desc[] = {"WAV", "wav", NULL};
+ g_return_if_fail (tr);
+ g_return_if_fail (tr->itdb);
+
/* The exact meaning of unk126 is unknown, but always seems to be
0xffff for MP3/AAC songs, 0x0 for uncompressed songs (like WAVE
format), 0x1 for Audible. */
@@ -125,6 +128,27 @@ static void itdb_track_set_defaults (Itdb_Track *tr)
floating point number. It's uncertain why this is here. itdb
will set this when adding a track */
tr->samplerate2 = tr->samplerate;
+
+ /* set unique ID when not yet set */
+ if (tr->dbid == 0)
+ {
+ GRand *grand = g_rand_new ();
+ GList *gl;
+ guint64 id;
+ do
+ {
+ id = ((guint64)g_rand_int (grand) << 32) |
+ ((guint64)g_rand_int (grand));
+ /* check if id is really unique */
+ for (gl=tr->itdb->tracks; id && gl; gl=gl->next)
+ {
+ Itdb_Track *g_tr = gl->data;
+ g_return_if_fail (g_tr);
+ if (id == g_tr->dbid) id = 0;
+ }
+ } while (id == 0);
+ tr->dbid = id;
+ }
if (tr->dbid2 == 0) tr->dbid2 = tr->dbid;
}