A recent change in master caused the default buffer size to be zero. ag/9499599
That caused a CTS failure.
This change restores the behavior of Q.
Bug: 143308870
Test: atest CtsNativeMediaAAudioTestCases
Change-Id: Id70b0c53e80531c3ea491b56b8fc107ca5ab6e51
Go ahead and write the data to the buffer if there is room,
even if it exceeds the setBufferSizeInFrames().
There is no point of holding it in the application buffer.
By making the data available to the DSP we can reduce glitches
or reduce latency.
Because this offers better glitch protection, we can allow
setBufferSizeInFrames() to accept a buffer size of zero.
This will provide the lowest possible latency.
Test: OboeTester glitch test
Change-Id: Ie706867c5dd57c29b4393c806cd51ae09198873e
Measure distribution of MMAP timestamp lateness.
This is used to discover the actual DSP timing behavior.
Turn histogram log on or off using a property.
Test: adb root
Test: adb shell setprop aaudio.log_mask 1
Test: run an AAudio MMAP program
Test: adb logcat | grep ClockModel
Change-Id: I910831d1feee43c59d1af2ac3135a910fef36fb2
This can be used to debug and analyze problems
with the AAudio MMAP IsochronousClockModel.
That is a model of the DSP that is used by AAudio
to predict the read/write timing of the DSP.
If there is an error in the model or in the timestamps
then the DSP and CPU pointers can cross, which causes
an audio glitch.
By changing the offset we can force glitches and indirectly
measure the time distribution of the DSP transfers.
Test: adb shell setprop aaudio.out_mmap_offset_usec
Bug: 123096058
Change-Id: I9a3df345a6820baf20a24d261642b3c8c0c2a27e
Allow any amount of lateness.
This will allow the ClockModel to work with a wider range
of DSP behaviors. It should also handle timing jitter
caused by resampling in the DSP.
Use a drift value to stabilize the early and late ends of
the clock model window.
Test: run OboeTester Glitch Test
Bug: 123096058
Change-Id: Ic6e03d7878b26c4bf1d05708cff0ca2a771a9f80
Was incorrectly looking at the buffer size instead of the buffer
capacity.
Test: OboeTester ECHO INPUT to OUTPUT
Test: set Input margin to 4
Test: XRun# for input should stay at zero
Bug: 141700208
Change-Id: I21ecdac19f5361a1b33f4dc2aaec170de9e28fc6
This change moves almost everything from libaadio.so to
separate libaaudio_internal.so library. This is done to
avoid exporting symbols which apps are not allowed to use
but have them available for platform libraries by exporting
them from libaaudio_internal.so
Bug: http://b/69603741
Test: make
Merged-In: If93118ed2c266faf2964abf21e17b0b13df493d2
Change-Id: If93118ed2c266faf2964abf21e17b0b13df493d2
In previous attempt it was mistakenly applied to cc_library_header
instead of the actual library. Do it correctly this time.
The intention of this change is to hide unintentionally
exported symbols from the library.
Bug: http://b/69603741
Test: make
Change-Id: I47967abea0b39aec05e80823c9eb3fe53f9fa591
This change moves almost everything from libaadio.so to
separate libaaudio_internal.so library. This is done to
avoid exporting symbols which apps are not allowed to use
but have them available for platform libraries by exporting
them from libaaudio_internal.so
Bug: http://b/69603741
Test: make
Merged-In: If93118ed2c266faf2964abf21e17b0b13df493d2
Change-Id: If93118ed2c266faf2964abf21e17b0b13df493d2
This change moves almost everything from libaadio.so to
separate libaaudio_internal.so library. This is done to
avoid exporting symbols which apps are not allowed to use
but have them available for platform libraries by exporting
them from libaaudio_internal.so
Bug: http://b/69603741
Test: make
Change-Id: If93118ed2c266faf2964abf21e17b0b13df493d2
This will allow AAudio to track the DSP better when
the DSP has variable timing, such as when resampling.
Keep track of the maximum lateness.
Do not assume it is only one burst.
Account for the lateness on the input streams
so we don't try to read the data before the DSP
has written it.
Bug: 123643363
Test: record through iRig UA using Oboe Tester
Test: see bug for details
Change-Id: I49eb852c6d0324e8a26ee912da5108021ec113fe
Close a stream at the same time the callback
is trying to stop the stream. This replicates
a hang that was detected in SynthMark.
Bug: 134963902
Test: this is a test
Change-Id: I7c87ecfefa2498fd1f4f9a1e406118c42a78545b
Unlock and lock around the join() because the callback
thread that we are joining may be blocked by the lock.
Check for DISCONNECTED state so the error callback is
also joined correctly.
Remove unnecessary waitForStateChange that could cause
a timeout delay on DISCONNECT.
Bug: 134963902
Test: test_stop_hang (see bug report)
Change-Id: I5080fa655da35b3221234a2bcafb6ccd71d3ca27
Correct an error that caused the timing window to jump
forward in time by one burst when a late timestamp was detected.
Bug: 133513175
Bug: 122680738
Bug: 123643363
Test: aaudio_loopback -tm -s20
Change-Id: I65c05d2ab123bcd347cb900de055c49c0c9beada
Two fixes for multichannel playback over USB from
AAudio legacy streams:
1: AAudio use a channel index mask and not a positional mask
when channel count is greater than 2.
2: audio policy gives priority to an output mixer which can support
the requested channel mask without downmixing
Bug: 131685020
Test: play multichannel audio over USB
Change-Id: I13f2da48d47fcf81f522096d90ba59a89379cffb
AAudioService would fail if a null client was passed.
Two null checks were added. One where we know the null
client first appears. And one where the client is first used
in case other calls are passing null.
Bug: 116230453
Test: Bug has a POC apk that triggers the bug.
Test: Look for messages like:
Test: AAudio : BnAAudioService::onTransact() client is NULL!
Change-Id: Id9c4fc154226ab40df97335da8bc9361cfc99a73
This will more accurately track the read or write
position of the DSP.
The client sometimes aggregates multiple hardware bursts
to avoid waking up too often. This can make it look like the DSP has
processed a larger amount of memory than it really has.
With this change, the timing model will advance in sync with the hardware.
Bug: 117834966
Bug: 130911274
Test: see bug for repro steps
Change-Id: Id22f1f313e02f0514665ee5ac144cab4684e3bc1
Reduce log spam and error logging as part of the Green Log effort.
Replace logging of addresses with integer IDs.
Bug: 36785118
Bug: 122073229
Bug: 130569151
Test: Open an AAudio stream at 44100 and look at logcat.
Test: adb shell write_sine_callback -pl -r44100
Test: adb logcat | grep -i aaudio | grep " E "
Test: Should see no "E" logs from AAudio.
Test: Should see no addresses from AAudio.
Change-Id: I1d4e0bc349095f818fad52603d2bb8e7317d3681
Merged-In: I1d4e0bc349095f818fad52603d2bb8e7317d3681
(cherry picked from commit 7ba46558fb)
This can cause a stream to get suspended if not processed.
Bug: 129140370
Test: this is a test
Test: test_full_queue
Change-Id: Ib8961ad708cb258c08a956c6ced813f23c437fc4
Clip setBufferSizeInFrames() to at least one burst
for Legacy streams to avoid underruns.
Bug: 129545119
Test: Look at BufferSize when you run this.
Test: adb shell write_sine_callback -pn -n0
Test: It should not glitch.
Change-Id: Id82862d59122ba2d9dd98dff579b5c147e40fab5
The opt-out was not published in the map.txt
Test: atest CtsNativeMediaAAudioTestCases
Change-Id: Ie4dec4abd9c569e2459dd02f9f372e30dd42267f
Signed-off-by: Kevin Rocard <krocard@google.com>
The opt-out was only present in the java API but not on the native ones.
Test: atest test_attributes
Change-Id: I1b84f1a428508e00de65e615b59405b9ee2ba009
Signed-off-by: Kevin Rocard <krocard@google.com>
This is useful when there are multiple audio devices in the system.
Test: use aaudio_loopback on a TV device with USB soundcard connected
specify -d<HDMI out device id> -D<USB in device id>
Change-Id: I60e84132f5974db6f4314c58f76705018e22b7db
Was colliding with -z option for capacity.
Also print data size in output buffer.
Test: adb shell write_sine_callback -pl -n2 -h8 -s10
Change-Id: If64f0876d3a2e1a95426dddf122693dbf3a314cd
Allow -n to specify buffer size for -tm test.
It was being forced to the size of the input buffer.
Test: aaudio_loopback -tm -s20 -n2
Change-Id: I4b71238f17bb87c22602bf86e2b91cfa41e3ae55
Various improvements including:
Show frame number of first 32 glitches.
Show graph at first glitch.
Hang in the callback using -h{msec} option.
Test: Run glitch test for 20 seconds, hang for 40 msec
Test: adb shell aaudio_loopback -tm -s20 -h40
Change-Id: I8e0f7bfd89efe907c38093e65e7775f48adf88f7
Only use the clock model for the position when
it is running and when the service is not updating
the FIFO counter.
Bug: 120932593
Bug: 122374244
Test: test_return_stop
Test: test_return_stop -i
Change-Id: I6d6a23b35dca5529b6221e1b3b4a4e6672093bf2
Was set to 2X framesRead on stop.
It turns out that AudioRecord::stop() does NOT reset getPosition()
to zero. But AudioRecord::start() does.
So the logic handling the reset had to move to the start code.
Bug: 121196899
Test: test_return_stop -i -n
Change-Id: I93635f9ba501b71b99b1df34c7920f7bfea5ca88
Simulate a sample rate clock that is slightly off from the expected
rate. The clock model should adjust to the drift and stay locked.
Test: this is a test
Change-Id: I402d8a90c920ff9eca611ee56071441826fc9876
There were several different timestamp variables with slightly
different meaning but with the same name.
That made it hard to debug the code.
Test: atest CtsNativeMediaAAudioTestCases
Change-Id: Iebf438676925c698377abe02c81f3d559829318a
Test for timestamps returned when STOPPED.
Test for no valid timestamps.
Bug: 122043542
Test: adb shell test_timestamps
Change-Id: I3f9ea636c7a469ffd6aa721776127dfeac94bc1e
If the input stream is not yet running then it will return
INVALID_STATE.
Test: aaudio_loopback -tm
Change-Id: I752675bf7dd7325beee16f3de24183042632f807
Stop the stream when the callback returns AAUDIO_CALLBACK_RESULT_STOP.
Refactor start/pause/stop code to allow different paths for
stop from the app or from the callback.
Fix error handling in joinThread().
Simplify code path through PlayerBase.
Bug: 120932593
Bug: 121158739
Test: test_return_stop
Test: test_return_stop -i
Test: test_return_stop -n
Test: test_return_stop -i -n
Test: atest CtsNativeMediaAAudioTestCases
Change-Id: I85134211348b26077693d9a71bf1331dad60da38
Check for the effects of setting a bogus counter.
Check for writes to memory surrounding the FIFO.
Check for negative array indices.
Bug: 120789744
Test: this is a test
Change-Id: Ia30cdef7f9d60f0a98b9af964cb3b3159df37dc9
(cherry picked from commit fcdc02782c)
The index into the FIFO is calculated by using:
counter % capacity
But the counter is signed and when it is negative the
modulo can have a negative result. That can cause
a negative array index and an access out of bounds.
This is not normally a problem because the counter
is 64 bits and it will not overflow until the audio
has run for a few million years. But a hacker might
be able to modify this internal counter and force
an error.
The solution involves casting to a uint64_t before doing
the modulo.
Note that there may still be a discontinuity when the
counter wraps from -1 to 0. But that will not result
in an out-of-bounds access. It may cause a noise but
an app could simply create a noise directly. So that is
not considered an exploit.
Bug: 120789744
Test: test_atomic_fifo.cpp
Change-Id: I6fe57bcb44528d29b5edb817c592e5e9a8aaf8eb
(cherry picked from commit f4f8142768)
This commit adds the following audio capture sources:
- AUDIO_SOURCE_VOICE_PERFORMANCE: for real time live performances like Karaoke.
- AUDIO_SOURCE_ECHO_REFERENCE: for capturing the reference signal to suppress by an echo
canceller. Protected by privileged permission CAPTURE_AUDIO_OUTPUT.
Also added device AUDIO_DEVICE_IN_ECHO_REFERENCE selected when the requested
capture source is AUDIO_SOURCE_ECHO_REFERENCE.
Bug: 118203066
Test: CTS tests for audio capture
Change-Id: Ieb159ea82a7b81acf762506a44e24ec80111609f
This will prevent log spam when AAUDIO_CALLBACK_RESULT_STOP
is returned from an audio callback.
Bug: 120845500
Test: test_return_stop.cpp
Change-Id: Icfe1541d6fa7b045285ac3dfbb75dfed5424d49b
The index into the FIFO is calculated by using:
counter % capacity
But the counter is signed and when it is negative the
modulo can have a negative result. That can cause
a negative array index and an access out of bounds.
This is not normally a problem because the counter
is 64 bits and it will not overflow until the audio
has run for a few million years. But a hacker might
be able to modify this internal counter and force
an error.
The solution involves casting to a uint64_t before doing
the modulo.
Note that there may still be a discontinuity when the
counter wraps from -1 to 0. But that will not result
in an out-of-bounds access. It may cause a noise but
an app could simply create a noise directly. So that is
not considered an exploit.
Bug: 120147915
Test: test_atomic_fifo.cpp
Change-Id: I6fe57bcb44528d29b5edb817c592e5e9a8aaf8eb
Check for the effects of setting a bogus counter.
Check for writes to memory surrounding the FIFO.
Check for negative array indices.
Bug: 120147915
Test: this is a test
Change-Id: Ia30cdef7f9d60f0a98b9af964cb3b3159df37dc9
Remove logging that is redundant or no longer needed.
Test: write_sine_callback -pl
Test: write_sine_callback -pl -r44100
Change-Id: I9004d32509757847764b9533c5cda743c6bd81a0
Help the autocorrelator recognize the peaks easier.
Reduce false detection of suboctaves.
Better timing for devices with high latency.
Improve error reporting.
Set input capacity based on output burst.
Bug: 119032743
Test: see repro case in bug
Test: aaudio_loopback -te -pl
Merged-In: I921c81db882f46ede8988cbdbebda0765e775086
Change-Id: I921c81db882f46ede8988cbdbebda0765e775086
Workaround for a recent change in the build that made command line apps
incompatible with O.
Test: adb shell aaudio_loopback -?
Test: should print help and not crash
Change-Id: If2a2288249a33c16fa5004b6b7db1a5ff9e22745
Merged-In: If2a2288249a33c16fa5004b6b7db1a5ff9e22745
Make silence detector less sensitive to noise by setting the
threshold proportional to the measured pulse level.
Make glitch detector less sensitive to noise by setting the
threshold proportional to the measured noise level.
Report signal to noise ratio.
Improved printed messages, show state as text.
Bug: 117834966
Test: aaudio_loopback -pl -tm
Change-Id: I5593cd1ade93ecbcb05f42af07626013d036f29a
Merged-In: I5593cd1ade93ecbcb05f42af07626013d036f29a
This can be used to reproduce the wrap around bug
in the MMAP FIFO in OC_MR1.
Bug: 78139448
Test: aaudio_loopback -tm -pl -Pl -z120
Change-Id: I923e60432f1c9777355d12d76609f2d70393f61b
Merged-In: I923e60432f1c9777355d12d76609f2d70393f61b
That was causing us to not get a FAST track.
Bug: 112186931
Test: adb shell aaudio_loopback -te -pl -Pl -m1 -n2
Test: should get PerformanceMode 12 on INPUT
Change-Id: Ib8b00585a80bdd86f752a5ee37aacd92f06db347
Merged-In: Ib8b00585a80bdd86f752a5ee37aacd92f06db347
Help the autocorrelator recognize the peaks easier.
Reduce false detection of suboctaves.
Better timing for devices with high latency.
Improve error reporting.
Set input capacity based on output burst.
Bug: 119032743
Test: see repro case in bug
Test: aaudio_loopback -te -pl
Change-Id: I921c81db882f46ede8988cbdbebda0765e775086