Mpeg4Writer: Synchronize multi-track gainmap muxing

HEIF/AVIF images with gainmap will include at least two
tracks. Each track will have its own thread for writing
and calculating the sample offsets. Currently sample
offset calculation relies on the same parent
functionality and is not synchronized.
Avoid possible race conditions by synchronizing access
in this scenario.

Flag: EXEMPT bugfix
Bug: 376155468
Test: atest -c -d cts/tests/camera/src/android/hardware/camera2/cts/ImageReaderTest.java#testHeicUltraHdr

Change-Id: I1bad7fa8e3a70f27478d81fd80c0873c9e43525e
1 file changed