This article describes some tips and tricks for debugging Android audio.
The “tee sink” is an AudioFlinger debugging feature, available in custom
builds only, for retaining a short fragment of recent audio for later
analysis. This permits comparison between what was actually played or
recorded vs. what was expected.
For privacy the tee sink is disabled by default, at both compile-time
and run-time. To use the tee sink, you will need to enable it by
re-compiling, and also by setting a property. Be sure to disable this
feature after you are done debugging; the tee sink should not be left
enabled in production builds.
The instructions in the remainder of this section are for Android 5.0,
and may require changes for other versions.
主题：Analyzing Writing Processes Using Keystroke Logs
- Push or sync the new
libaudioflinger.soto the device’s
adb shell getprop | grep ro.debuggable
Confirm that the output is:
ls -ld /data/misc/media
威尼斯官方网站，Confirm that the output is:
drwx------ media media ... media
If the directory does not exist, create it as follows: mkdir /data/misc/media chown media:media /data/misc/media
echo af.tee=# > /data/local.prop
af.teevalue is a number described below.
chmod 644 /data/local.prop
is a growing literature on the analytics and use of keystroke logs in
digital writing assessments. The results and feedback based upon writing
processes can not only enhance traditional score reports, which may
contain only a single score, but also provide the test users with much
targeted and rich information about the test takers. This workshop will
discuss the use the process features collected from keystroke logs in
understanding students’ English writing proficiency. To give an overview
of the state-of-the-art, this workshop will describe several completed
research studies including one on the effectiveness of using process
features in combination with product features (extracted from automated
scoring system) to predict writing performance.
The value of
af.tee is a number between 0 and 7, expressing the sum of
several bits, one per feature. See the code at
AudioFlinger.cpp for an explanation
of each bit, but briefly:
- 1 = input
- 2 = FastMixer output
- 4 = per-track AudioRecord and AudioTrack
There is no bit for deep buffer or normal mixer yet, but you can get
similar results using “4.”
Test and acquire data
- Run your audio test.
adb shell dumpsys media.audio_flinger
- Look for a line in dumpsys output such as this:
tee copied to /data/misc/media/20131010101147_2.wav
This is a PCM .wav file.
/data/misc/media/*.wavfiles of interest; note that
track-specific dump filenames do not appear in the dumpsys output,
but are still saved to
/data/misc/mediaupon track closure.
- Review the dump files for privacy concerns before sharing with
Try these ideas for more useful results:
- Disable touch sounds and key clicks.
- Maximize all volumes.
- Disable apps that make sound or record from microphone, if they are
not of interest to your test.
- Track-specific dumps are only saved when the track is closed; you
may need to force close an app in order to dump its track-specific
- Do the
dumpsysimmediately after test; there is a limited amount
of recording space available.
- To make sure you don’t lose your dump files, upload them to your
host periodically. Only a limited number of dump files are
preserved; older dumps are removed after that limit is reached.
As noted above, the tee sink feature should not be left enabled. Restore
your build and device as follows:
- Revert the source code changes to
- Push or sync the restored
libaudioflinger.soto the device’s
The standard Java language logging API in Android SDK is
The corresponding C language API in Android NDK is
Within the native portion of Android framework, we prefer macros named
ALOGV, etc. They are declared in
<utils/Log.h>, and for the purposes of this article we’ll collectively
refer to them as
All of these APIs are easy-to-use and well-understood, so they are
pervasive throughout the Android platform. In particular the
mediaserver process, which includes the AudioFlinger sound server,
Nevertheless, there are some limitations to
ALOGx and friends:
- They are susceptible to “log spam”: the log buffer is a shared
resource so it can easily overflow due to unrelated log entries,
resulting in missed information. The
ALOGVvariant is disabled at
compile-time by default. But of course even it can result in log
spam if it is enabled.
- The underlying kernel system calls could block, possibly resulting
in priority inversion and consequently measurement disturbances and
inaccuracies. This is of special concern to time-critical threads
- If a particular log is disabled to reduce log spam, then any
information that would have been captured by that log is lost. It is
not possible to enable a specific log retroactively, after it
becomes clear that the log would have been interesting.