tl;dr: Why does AudioThumbnail::setDataSource
require the message manager to be locked?
I just tripped across this assert while attempting to load/create thumbnails for my tracks in a background thread:
bool AudioThumbnail::setDataSource (LevelDataSource* newSource)
{
JUCE_ASSERT_MESSAGE_MANAGER_IS_LOCKED
None of the code in that method does anything with the message manager, so why is it requiring it to be locked?
To attempt to answer that myself I dug through the history of that one line:
-
About 8 months ago as part of a bulk change the macro replaced a plain
jassert
- a good cleanup, but no answer. -
About 9 years ago that
jassert
was added, but the addition doesn’t seem to follow from the commit description.
I know 9 years is a long time ago - I don’t remember why I coded what 1 year ago!
As a test I commented out the macro and didn’t experience any additional ill effects in my application.
If it is not needed could it be removed so that thumbnail creation can be done easily outside of the message loop without having to do an additional lock on it? If it is needed, then a code comment explaining why would help posterity. I can submit a PR if wanted once it’s determined either way.