OSDN Git Service

Fix slow AudioTrack and AudioRecord destruction
authorGlenn Kasten <gkasten@google.com>
Fri, 20 Sep 2013 16:20:45 +0000 (09:20 -0700)
committerGlenn Kasten <gkasten@google.com>
Fri, 20 Sep 2013 19:22:29 +0000 (12:22 -0700)
commit5a6cd224d07c05b496b6aca050ce5ecf96f125af
treec5d2fe55f0080c9660d283d040616d9a9fb6decc
parenta3b97ad288e6808c54c6275eaac1bd53108d8f11
Fix slow AudioTrack and AudioRecord destruction

There were two causes for the slowness:

When thread was paused, it used nanosleep and sleep.  These usually
run to completion (except for POSIX signal, which we avoid because it
is low-level).  Instead, replace the nanosleep and sleep by condition
timed wait, as that can be made to return early by a condition signal.
Another advantage of condition timed wait is that a condition wait was
already being used at top of thread loop, so it is a simpler change.

The AudioRecord destructor was missing a proxy interrupt that was correct
in AudioTrack.  This proxy interrupt is needed in case another thread
is blocked in proxy obtainBuffer.

Does not address the 1 second polling for NS_WHENEVER.

Bug: 10822765
Change-Id: Id665994551e87e4d7da9c7b015f424fd7a0b5560
include/media/AudioRecord.h
include/media/AudioTrack.h
media/libmedia/AudioRecord.cpp
media/libmedia/AudioTrack.cpp