Remove timing jitter during startup of audio

This fixes a regression introduced recently, that increased timing jitter
during the startup of the FastMixer and AudioTrack callback threads.

The regression was to make requestPriority() asynchronous as a way to
avoid an apparent priority inversion in system_server.  This means that
the target thread could run briefly with the initial priority, before
the new priority takes effect.

This change removes the startup jitter for FastMixer, by making the
requestPriority() synchronous again for that case.  It doesn't matter
that this restores the priority inversion involving normal mixer thread,
because it happens during startup of both threads.

The change also removes the startup jitter for the AudioTrack callback
thread, by having the target thread check whether the requestPriority()
has completed yet.  If not, the target thread blocks with a timeout
until the priority boost finishes.

Finally, we now log an error message if the expected priority boost
doesn't happen.

Bug: 8698989
Change-Id: Id590e9a274b70ec1ba85b44a585ee37a22e41cbc
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index 47ca100..539bb4f 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -373,7 +373,9 @@
         switch(event->type()) {
             case CFG_EVENT_PRIO: {
                 PrioConfigEvent *prioEvent = static_cast<PrioConfigEvent *>(event);
-                int err = requestPriority(prioEvent->pid(), prioEvent->tid(), prioEvent->prio());
+                // FIXME Need to understand why this has be done asynchronously
+                int err = requestPriority(prioEvent->pid(), prioEvent->tid(), prioEvent->prio(),
+                        true /*asynchronous*/);
                 if (err != 0) {
                     ALOGW("Policy SCHED_FIFO priority %d is unavailable for pid %d tid %d; "
                           "error %d",