From ed49ab8fb85375b277b97c6025aaad2d55186d1b Mon Sep 17 00:00:00 2001 From: Jorg Schuler Date: Tue, 1 May 2007 03:40:38 +0000 Subject: * src/itdb_itunesdb.c (itdb_cp_track_to_ipod): removed static variable "dir_num" which was initialized once and cycled through for each track transfered. This doesn't seem right since different iPods with different number of music directories may be connected at the same time, and itdb_cp_track_to_ipod() may be called for different iTunesDBs at the same in in a threaded environment. Since there is no inherent value in cycling through the directories, a random directory is selected each time. git-svn-id: https://gtkpod.svn.sf.net/svnroot/gtkpod/libgpod/trunk@1425 f01d2545-417e-4e96-918e-98f8d0dbbcb6 --- ChangeLog | 11 +++++++++++ src/itdb_itunesdb.c | 19 ++++++------------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3a74c6b..3ea3683 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2007-05-01 Jorg Schuler + + * src/itdb_itunesdb.c (itdb_cp_track_to_ipod): removed static + variable "dir_num" which was initialized once and cycled through + for each track transfered. This doesn't seem right since + different iPods with different number of music directories may + be connected at the same time, and itdb_cp_track_to_ipod() may + be called for different iTunesDBs at the same in in a threaded + environment. Since there is no inherent value in cycling through + the directories, a random directory is selected each time. + 2007-04-30 Jorg Schuler * src/itdb_itunesdb (itdb_parse_internal): fixed compile warning diff --git a/src/itdb_itunesdb.c b/src/itdb_itunesdb.c index 1114886..43215d7 100644 --- a/src/itdb_itunesdb.c +++ b/src/itdb_itunesdb.c @@ -5493,14 +5493,14 @@ gint itdb_musicdirs_number (Itdb_iTunesDB *itdb) * Copy one track to the iPod. The PC filename is @filename * and is taken literally. * - * The mountpoint of the iPod (in local encoding) is expected in - * track->itdb->mountpoint. + * The mountpoint of the iPod (in local encoding) must have been set + * with itdb_set_mountpoint() (done automatically when reading an + * iTunesDB). * * If @track->transferred is set to TRUE, nothing is done. Upon * successful transfer @track->transferred is set to TRUE. * - * For storage, the directories "f00 ... fnn" will be - * cycled through. + * For storage, the directories "f00 ... fnn" will be used randomly. * * The filename is constructed as "gtkpod"<random number> and copied * to @track->ipod_path. If this file already exists, <random number> @@ -5518,7 +5518,7 @@ gint itdb_musicdirs_number (Itdb_iTunesDB *itdb) gboolean itdb_cp_track_to_ipod (Itdb_Track *track, const gchar *filename, GError **error) { - static gint dir_num = -1; + gint dir_num; gchar *track_db_path, *ipod_fullfile; gboolean success; gint mplen = 0; @@ -5566,14 +5566,7 @@ gboolean itdb_cp_track_to_ipod (Itdb_Track *track, return FALSE; } - if (dir_num == -1) - { - dir_num = g_random_int_range (0, itdb_musicdirs_number (itdb)); - } - else - { - dir_num = (dir_num + 1) % itdb_musicdirs_number (itdb); - } + dir_num = g_random_int_range (0, itdb_musicdirs_number (itdb)); g_snprintf (dir_num_str, 5, "F%02d", dir_num); dest_components[0] = dir_num_str; -- cgit