Spawn a thread to handle the disconnects for onRoutingChanged()
and onTearDown(). This is to prevent deadlocks when calling back into
AudioFlinger.
Bug: 155819038
Test: See bug for repro steps with OboeTester
Test: Also run TEST DISCONNECT in OboeTester. It was failing.
Test: atest CtsNativeMediaAAudioTestCases
Change-Id: I83212fea140d3b6beca9aa737606a77a7c97b007
An app (B) that asks for an exclusive stream can steal
an exclusive stream from an earlier app (A).
App B will be given the MMAP resource as a SHARED stream.
The stream for app A will be disconnected and released
by the service.
If app A reopens a stream then it will get a SHARED
stream.
The order of the opening of the streams is controlled by using a
recursive_mutex in AAudioService::openStream().
Bug: 129846760
Test: media/libaaudio/tests/test_steal_exclusive.cpp
Test: also
Test: Launch AudioTroubleMaker. It should say "EXCLUSIVE".
Test: Press Home button.
Test: Siren sound from AudioTroubleMaker should continue.
Test: Launch OboeTester
Test: TEST OUTPUT, then Open, Start
Test: You should get an MMAP SHARED stream on Pixel.
Test: Go back to AudioTroubleMaker. It should say "SHARED".
Change-Id: I7f8339d8ed62546520a9b46ed398418b41ca2832
Log events from service.
Log start, stop, disconnect and other events.
Log underruns and bufferSize.
Bug: 154543374
Test: adb shell dumpsys media.metrics --clear
Test: run an app that uses MMAP, like OboeTester
Test: adb shell dumpsys media.metrics
Test: Expect to see lots of "audio.stream" events.
Change-Id: I690e5226b695d53d038d644f4438c759e08f9fbb
In aaudio, when adding tracks to mixed stream, it is needed to update
audio attributes to HAL whenever the tracks are added or removed.
Currently, only the audio attributes used to open the stream will be
sent to the HAL. In that case, adding audio attributes of the clients
when starting the stream can help solve the problem. In audio flinger,
the client's audio attributes will be used to create MmapTrack.
Test: play multiple aaudio tracks, add log
Bug: 77279923
Change-Id: Ic1c536049e194a2bb7513425ee4828d52769d27f
Split close into close and release phases.
Release() will release hardware and service resources.
Close() will delete the stream object.
This allows us to defer the deletion and avoid race conditions.
The CLOSING state is used to indicate that a stream has been released.
Added some test cases to test_various.cpp.
A lone call to close() will automatically call release() so we should
have good code coverage for testing.
Bug: 136288001
Test: adb shell test_various
Test: atest CtsNativeMediaAAudioTestCases
Change-Id: Ia648838f30c521ba101f55259dbcd4594c1263cd
Add the possibility for apps to indicate that their
capture use case is private and that a privileged Assistant
should not be able to capture concurrently.
This allows to override the default behavior tied to the audio
source (e.g VOICE_COMMUNICATION is private by default but
UNPROCESSED is not).
- Add AAudio API to set and get privacy sensitive mode on input stream
- Add MediaRecorder API to set and get privacy sensitive mode
- Modify AudioSource constructor to accept audio attributes instead of an
audio source to specify the use case.
- Modify audio policy concurrent capture logic to use audio attributes
flag instead of audio source to decide of a capture client has
requested privacy mode or not.
Bug: 137850106
Test: CTS AudioRecordTest and MediaRecorderTest, manual audio smoke tests
Change-Id: I250ea5da4c1da809ceac0da22ae9bee15b937001
Before, in Android 10, this would have been a small leak because
unlinkToDeath is not called, but now, objects are automatically
unlinked. However, this presents a problem since you must hold onto
a binder in order to linkToDeath. This now holds onto the binder
and is relying on the automatic-unlinkToDeath behavior.
Fixes: 145675653
Test: atest CtsNativeMediaAAudioTestCases
arm64-v8a CtsNativeMediaAAudioTestCases: Passed: 122, Failed: 0, Ignored: 0, Assumption Failed: 0
Test: after using app and killing which uses AAudio MMAP stream,
dumpsys output for media.aaudio is cleaned up:
------------ AAudio Service ------------
Stream Handles:
AAudioClientTracker:
AAudioEndpointManager:
Exclusive MMAP Endpoints: 0
ExclusiveSearchCount: 3
ExclusiveFoundCount: 0
ExclusiveOpenCount: 1
ExclusiveCloseCount: 1
Shared Endpoints: 0
SharedSearchCount: 1
SharedFoundCount: 0
SharedOpenCount: 0
SharedCloseCount: 0
Change-Id: I2ef141320dc3ef0135fb7ef002d85377d06a75c2
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 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 was fixed when converting to Android.bp in internal master, so
that's the Merged-In reference.
Test: treehugger
Change-Id: I6a503ac7f3c283b7ef6a657c100901469447a22b
Merged-In: I7061e99da18f5f7fad00527f01bf97ae6cebea2f
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
Removed additional includes previously added by LOCAL_C_INCLUDES,
none of them are actually needed.
Bug: 121208203
Test: make
Change-Id: I7061e99da18f5f7fad00527f01bf97ae6cebea2f
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
Service RT thread should run at a slightly higher priority because
it generally does less work and is more critical.
Bug: 71817389
Test: Run an AAudio stream in SHARED mode.
Test: adb shell ps -e -T -o uid,pid,tid,ppid,pri,ni,cmd| grep AAudio
Test: See bug for more test instructions.
Change-Id: I762af6ac1a9883d47b4c42bfe9f8455416251a12
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)
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
This prevents the stream from getting suspended
if not read or written fast enough.
Bug: 129140370
Test: test_full_queue
Change-Id: Icc5ddc72c99fb3c518736f2a50d6c6a0276ee196
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>
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
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
Remove logging that is redundant or no longer needed.
Test: write_sine_callback -pl
Test: write_sine_callback -pl -r44100
Change-Id: I9004d32509757847764b9533c5cda743c6bd81a0
There was a potential race between setting the first timestamp
and reading the first timestamp that could cause the timestamp service
thread to exit. This would cause the client to not get any timestamps.
Then the timing model would not advance and the stream would stall.
This could result in read() or write() returning zero,
or a TIMEOUT error.
This was rare except for some devices that had different
timing in the HAL.
Bug: 68271891
Bug: 117557847
Test: adb shell write_sine_callback -pl -m2 -n2 -s2 -c2 -l100
Test: atest CtsNativeMediaAAudioTestCases
Change-Id: Ib0974a576aaa17ff8de40899e60ed56015027bd7
There was a potential race between setting the first timestamp
and reading the first timestamp that could cause the timestamp service
thread to exit. This would cause the client to not get any timestamps.
Then the timing model would not advance and the stream would stall.
This could result in read() or write() returning zero,
or a TIMEOUT error.
This was rare except for some devices that had different
timing in the HAL.
Bug: 68271891
Bug: 117557847
Test: adb shell write_sine_callback -pl -m2 -n2 -s2 -c2 -l100
Test: atest CtsNativeMediaAAudioTestCases
Change-Id: Ib0974a576aaa17ff8de40899e60ed56015027bd7
Construct a flowgraph based on the source and destination
format and channelCount. This is groundwork for supporting 24-bit
PCM formats.
Also cleaned up handling of device related format.
This CL removes more code than it adds.
Bug: 65067568
Test: write_sine_callback.cpp -pl
Test: write_sine_callback.cpp -pl -x
Test: input_monitor -pl
Test: input_monitor -pl -x
Change-Id: Ia155bff0164912011d09b61b54f983ccf4490bd1
SHARED streams and endpoints were being created with sharing mode
set to EXCLUSIVE. This was confusing the close() code and caused a hang.
Now we create a modified Request object with the sharing mode set
correctly.
Bug: 112709847
Test: Hack AAudioServiceEndpointMMAP so isBufferShareable is false.
Test: 'adb shell write_sine_callback -pl -x -s2' should not hang.
Change-Id: I7a5c8260beaffdd706f34d35ef00a61b072adb1d
Remove unused methods and fields.
Better code format and alignment.
Use unique_ptr for mFifo.
Remove getFifoController() method that exposed pointer.
Updates tests and calling code as needed.
Test: test_atomic_fifo.cpp
Change-Id: I1ea66beaadeb74083307835858b757e4753affda
Move increment and decrement of reference count under
the same lock used for finding the stream.
Bug: 79693915
Test: run CTS tests
Change-Id: I206eb09724a81f2d79a03fa756adbcbb8abf5efa
Avoid using the mServiceEndpoint smart pointer
from multiple threads.
Bug: 74122779
Test: see bug for test instructions
Change-Id: Idaf9e32a163b25e51bde35d6f5ea10a372b5d916
Needed for silencing specific input streams.
Pass AAudioService reference into AAudioServiceEndpointMMAP.
Use it to find a specific stream by PortHandle then
stop it and disconnect it.
Bug: 72134552
Test: b/72134552#comment10
Change-Id: Ibdf242f834c83b47c967c3cc634ed1083b019d4a