robinbowes / flac2mp3

flac2mp3 is a tool to convert audio files from flac to mp3 format including the copying of tags.
GNU General Public License v3.0
141 stars 29 forks source link

Feature/separate loops #22

Open carlasplund opened 11 years ago

carlasplund commented 11 years ago

use two separate loops (step 3/5)

In this third step towards progress reporting, two separate loops are used instead of one. The first loop is non-parallelized, where we check each file for need of transcoding. If it doesn't need to be transcoded it is tagged, if necessary. If it does need to be transcoded its name and filesize is saved in a datastructure, but no more processing on the file takes place until the second loop. The progress of the first loop is displayed and updated in 1 s intervals.

In the second loop, parallel processing is used to transcode the files found in the first loop. Here, in the coming steps 4 and 5, we will extend the 'run_on_finish' callback sub to also include progress reporting and estimated time to finish, based on timing and file size data.

Note that nothing would be gained by having the first loop similarly parallelized - the computational overhead is far too big in comparison to the relatively light cpu load.