Page MenuHome

Threaded waveform loading
Needs ReviewPublic

Authored by Antonis Ryakiotakis (psy-fi) on Nov 5 2014, 11:39 AM.

Details

Summary

This is a first implementation of threaded waveform loading. It uses the job system to load waveforms asynchronously but can be further improved by showing the intermediate loaded result while it is being loaded.

The patch includes code that tries to preserve the waveforms between undo steps when possible. It uses data maps which are used elsewhere, see image and movie clip caches. This is pretty much useless currently, because sounds reload completely on loading, something we should avoid with lazy initialization. The code was included to give an idea of how sound data can be preserved. Basically, if sound_load takes a parameter to not delete the waveform in lib_link_sound, this works as intended, but as explained above, the point is to -not- use sound_load for every undo step.

Diff Detail

Event Timeline

Antonis Ryakiotakis (psy-fi) retitled this revision from to Threaded waveform loading.
Antonis Ryakiotakis (psy-fi) updated this object.

Let's recap our IRC discussion, the three problems that we figured out are:

  1. undo/redo reloads waveform and cache every single time which makes it really slow
  2. adding waveform and caching is blocking and slow
  3. having too many file handles open at the same time

And the according solutions are:

  1. using OldNewMap
  2. adding threading
  3. closing files when not needed and reopening when needed

The first two are solved in this patch here, but I'd like to see how OldNewMap affects the first problem, so I'd like to have separate patches. Also this patch is only for the waveform and not for the cache. All other handles to the audio engine should be fine without OldNewMap and threading. The third point should be solved with the D915 patch.

Sergey Sharybin (sergey) added inline comments.
source/blender/blenkernel/intern/sound.c
701

Seems you only do really tiny calculations inside the lock. In this case it's much better to use spin lock instead of mutex.