From: Jorg S. <Jor...@gm...> - 2007-04-19 15:07:07
|
Hi everyone, I've created a branch for the cached multi-threaded background file conversion. You can switch to the branch from a regular checkout by typing cvs up -r threaded_conversion_branch (and 'cvs up -r HEAD' brings you back to the main branch). The code still needs a bit of cleaning up on the GUI side (preferences dialog, log window, file transfer dialog), but I believe the background code is there and working. What it does: as soon as you add/drag a music file to an iPod for which a conversion script is set up in the preferences, conversion of that track will start in a background thread. The maximum number of background threads is configurable (hardcoded to 2 in file_convert.c at the moment (max_threads_num) -- does anyone know how to autodetect the number of CPUs/cores?). That sounds easy, but it took me around 1700 lines of code/comments to make it thread-safe... I've heavily All converted files are written to a cache directory (currently hard-coded to ~/.gtkpod/conversion_cache, changeable manually in the prefs file. The maximum size of the conversion cache is hard-coded to 4 GB (also changeable in the prefs file). Once the cache is full, files not needed for transfer are removed in a oldest-first order until the size is below the limit again. No new conversion is started as long as the cache size is too large. The name of the converted file is stored in the extra information. If you dragged a track from the local repository to the iPod, the cached file will be available for the next time when you drag that file to an iPod and no new conversion will take place. This does not work if you add directly from the file system (but could easily be made to work by saving a list of original-file/converted-file correspondances). If you remove a track from an iPod while it is being converted, conversion will be stopped on that track. Children of the shell script are successfully killed as well (another small thing that took an entire evening to work out ;-) I'd appreciate if you could try out this new code and give some feedback. Many of the new code was inspired by the previous work on on-the-fly-conversion by arc d[r]eadlock and Simon Naunton without which I don't think I'd even have started. So thank you once again! Cheers, JCS. |