Process tracing buffers in the correct order

When there were no free buffers in the pool, we used to flush the buffer
from the head of the queue on the mutator thread and use that buffer.
This could potentially reorder the buffers which isn't expected by the
parsers. So update the implementation to instead wait for a free
buffer.

Bug: 259258187
Test: art/test.py -t 2246

Change-Id: I0b71a38e76a3b1d7ad8836fd9fdac778cdb15fcb
2 files changed