[3.3.x] MediaLibraryModels: fix concurrency by implementing locking
It is legal for the media library to send events from any thread so read and write access to the local cache array must be protected by locking to avoid concurrency issues.
(cherry picked from commit a2c85741, backport of !739 (merged) including the extra fix in !741 (merged))
Edited by Felix Paul Kühne