How to report progress to GUI?

How to report progress to GUI?

[This is a follow-up question to another thread I started, entitled "TBB for Qt CD ripper?"]

My general question is, given that TBB tasks should not block on a mutex, how is it possible to report progress of tasks back to the main GUI thread?

My application is a CD ripper with a Qt GUI. CD ripping is a two phase process. The first phase is to extract the raw audio data from the CD to a set of WAV files. The second phase is to encode the WAV files into the desired audio format, such as FLAC, Mp3, or Ogg Vorbis. It is this second phase that I am attempting to parallelize using the TBB library. I originally envisioned that I would use one tbb::task for each track to be encoded, but in the original thread I started for this topic it was suggested that I break down the encoding of each track into many small TBB tasks, say one task for every two seconds of audio to be encoded.

Let's say that a CD has 15 tracks on it. The application would first extract the CD audio to 15 separate WAV files, and then would create a bunch of TBB tasks (either explicitly, or using tbb::pipeline). I would like the GUI for my application to display a progress bar for each track that is to be encoded, so once the encoding phase started I would have 15 progress bars displayed on the screen. However, since each track is going to be encoded using an arbitrary number of independent TBB tasks, I need some way of communicating progress of each track back to the progress bar displayed on the screen for that track.

Is there any sort of mechanism to communicate such information from TBB tasks back to the main GUI thread without blocking progress of the tasks?

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Presumably each track will loop on

fill buffer, process, output buffer (as pipeline in parallel)

Since you apparently can tell the distance between raw tracks you should know the number of fill buffers required to process each track. Convert the next fill buffer number to % completed (for track) and then write to cell in shared array (one cell to hold %completed for each track). Then have timing thread periodically notify GUI such that it can update gauges.


Leave a Comment

Please sign in to add a comment. Not a member? Join today