MediaMuxer:Unblock writeSampleData,gate pushBuffer

As MediaMuxer's writeSampleData handles inputs from multiple tracks,
limited the scope of mMuxerLock to an inner block so that the
current track's buffer does not wait until the completion
of processing of previous buffer of the same or another track.
It's the responsibility of individual track - MediaAdapter object
to gate its buffers.  When interleaving is enabled and data
is written in chunks, the delay was very much noticeable.
For example, when video buffers were getting written to the file,
no new audio buffer was queued to it's thread.

This change has decreased the time required
to complete muxing data from multiple tracks by as much as 35%.

Bug: 157373376

Test: atest android.media.cts.MediaMuxerTest \
      android.mediav2.cts.MuxerTest \
      android.mediav2.cts.MuxerUnitTest
Change-Id: If02f60441292afcf29d01939b09a80bbba43e6b6
3 files changed