History log of /hardware/interfaces/audio/2.0/default/StreamOut.cpp
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
46cba442d25e16cce4d5f009f4700a88d53636b1 06-Oct-2017 Kevin Rocard <krocard@google.com> Legacy wrapper: Use arbitrary limit on buffer size

The legacy HAL wrapper prepareForWrite and prepareForRead used
to return INVALID_ARGUMENTS if the computed buffer size just
under SIZE_MAX.

This meant that the limitation depended on the architecture (32 vs 64
bit size_t). This caused VTS test failure on 64 bits.

Instead of dynamically calculating an arbitrary max size,
choose a fixed one. This max buffer size has been chosen at 1GiB.
It should be enough for the foreseeable future and not too close
from the 4GiB max on 32 bit.

Test: vts-tradefed run commandAndExit vts --module VtsHalAudioV2_0Target
Bug: 67030516
Change-Id: I4cc3efda9bb66e6dae8b4e6785f52d9e51440aee
Signed-off-by: Kevin Rocard <krocard@google.com>
/hardware/interfaces/audio/2.0/default/StreamOut.cpp
96a3a19beda45bef7c34fc06a0048174f3a7e362 20-May-2017 Mikhail Naganov <mnaganov@google.com> audiohal: Prevent logspam when calling get_presentation_position

get_presentation_position can return ENODATA if the stream
has stopped but the write is still querying the position.

Bug: 38376424
Change-Id: I9d516a19fb347843a8ec8e8e9a0f5eab0b0798e6
Test: no log messages from StreamHAL about get_presentation_position
/hardware/interfaces/audio/2.0/default/StreamOut.cpp
4c030024dfa9cdf924cb771580e13d237f1ec813 09-May-2017 Kevin Rocard <krocard@google.com> Audio HAL: A volume/gain outside of [0,1] is an error

Hals are supposed to received normalized volumes, between 0 and 1.
Previously volumes outside [0,1] were clamp to this range.
This clamping has the capability to hide bugs thus return an error if
such volume is received.

Test: vts-tradefed run vts --module VtsHalAudioV2_0Target
Test: call/play music/record/video...
Bug: 36311550
Change-Id: Ia4880bdff6111cbcdae6a4ebee921eddae141ee4
Signed-off-by: Kevin Rocard <krocard@google.com>
/hardware/interfaces/audio/2.0/default/StreamOut.cpp
195205b323b7d93cf4d477445469759b27371f45 03-May-2017 Kevin Rocard <krocard@google.com> Audio HAL VTS: Sanitize prepareFor{Writing,Reading} input size

Return an error if framesCount or frameSize are null to avoid a division
by zero when calculating the buffer size.

The message queues are allocated with a buffer size but if two big they will
assert not return an error.
Thus take some margin on the buffer size check.

Note that both function should be refactored as 99% identical.

Test: vts-tradefed run vts --module VtsHalAudioV2_0Target
Test: call/play music/record/video...
Bug: 36311550
Change-Id: I0576e9016ef2e567c8d4e171c6237883d9865db9
Signed-off-by: Kevin Rocard <krocard@google.com>
/hardware/interfaces/audio/2.0/default/StreamOut.cpp
c07df49e455ef67f880a3ca29ce585a213bccdde 03-May-2017 Kevin Rocard <krocard@google.com> Audio HAL VTS: refactor prepareFor{Reading,Writing}

Those functions had lots of copy paste on errors and
the following patch will even add more error detections.
Refactor the hidl_cb call to avoid all duplication.
Note that both function should be refactored as 99% identical.

Test: vts-tradefed run vts --module VtsHalAudioV2_0Target
Test: call/play music/record/video...
Bug: 36311550
Change-Id: I40d6926b4f9f5e3aba51e878f55fb013f4ca09c1
Signed-off-by: Kevin Rocard <krocard@google.com>
/hardware/interfaces/audio/2.0/default/StreamOut.cpp
72e50e2ef1480fc3d90f0d88c7e9e3595622e75c 05-May-2017 Kevin Rocard <krocard@google.com> Audio HAL VTS: Fix style on modified files

In order to avoid style inconsistency as well as non functional
modification in following patches,
fix the style of all files modified for the fix of the VTS tests.

Patch generated with:
$ clang-format -i --style file -- <file list>

Bug: 36311550
Test: compile
Change-Id: I53dbcdabf959a6100e34a2ee4d0f951d525049cb
/hardware/interfaces/audio/2.0/default/StreamOut.cpp
40343061d5f6f309c68a54940e24d404e6cd620a 01-Apr-2017 Kevin Rocard <krocard@google.com> Audio HAL: Destroy EventFlag on failed prepareTo{write,read}

If prepareToWrite or prepareToRead fails after EventFlag is created, it
is not destroyed. This lead to strange random crashes (double free it seems).

Use the RAII pattern to manage the EventFlag life cycle.

Test: Run test on target
Bug: 36311550

Change-Id: I53a04a62b7d12fdcc94afd8ced3e547aa6edff50
Signed-off-by: Kevin Rocard <krocard@google.com>
/hardware/interfaces/audio/2.0/default/StreamOut.cpp
b6498cbdf6c04c631ccf6a6e65a1264b455e3088 01-Apr-2017 Kevin Rocard <krocard@google.com> Audio HAL: Check for buffer size overflow

The audio buffer size is not provided by the client, it is computed from
the sample size and the number of sample.

No check was done as if the multiplication of these two numbers would
produce an overflow. This leaded to erroneous memory access crashing the
media server.

Test: Run on target
Bug: 36311550

Change-Id: I3436800ab6ac1b5e6a6aa4d03d6b96910eb54652
Signed-off-by: Kevin Rocard <krocard@google.com>
/hardware/interfaces/audio/2.0/default/StreamOut.cpp
67d550888a021633cc33cb284bb0658b008887c6 01-Apr-2017 Kevin Rocard <krocard@google.com> Audio HAL: Detect buffer memory allocation failure

If the requested buffer was too big, memory allocation would fail,
resulting if a audio hal crash (uncatch exception thrown by new).

Properly hadle the failure by retuning INVALID_PARAMETERS in such case.

Bug: 36311550
Test: Run test on target

Change-Id: Ib4170eb6a9f88f9352d0912083b43d600771bb8e
Signed-off-by: Kevin Rocard <krocard@google.com>
/hardware/interfaces/audio/2.0/default/StreamOut.cpp
936279e1ffe6bf7e842c46f9a94d98a48dce6754 29-Mar-2017 Mikhail Naganov <mnaganov@google.com> audiohal: Fix UAF of HAL devices in Stream objects

Stream objects used to hold a pointer to underlying HAL device
object which they didn't own. Since destruction of server side
objects is asynchronous, it was possible that a Device object
gets destroyed before Stream objects, making all the HAL device
object pointer to become stale.

Fixed by adding a strong reference to Device objects into Stream
objects.

Bug: 36702804
Change-Id: I3da3611afbb91d6fd6410ac5b8af2a2eebfa6dac
Test: ran Loopback app and HAL VTS tests
(cherry picked from commit 96d3573cda6f76bcbfc277e69d94914a565218d8)
/hardware/interfaces/audio/2.0/default/StreamOut.cpp
b0dd076c60fb9d4860ef4bdd8865f1f21eb92af8 22-Mar-2017 Mikhail Naganov <mnaganov@google.com> audiohal: Remove stale TODOs

Bug: 34109709
Change-Id: I9b30ffa2ed06be8cf31cdbfbcc0f4cb0dac7be54
Test: make
/hardware/interfaces/audio/2.0/default/StreamOut.cpp
476930c978f511fc97e24ea7d804d2396d2ede9e 03-Mar-2017 Mikhail Naganov <mnaganov@google.com> Revert "audiohal: Add diagnostic message to check the number of bytes written"

Diagnostic logging can be removed now as we have figured out that the problem isn't with the legacy hal.

This reverts commit 8d391c8eed27b14eab1f9fde0cb22a5c5d925a6a.

Change-Id: I70a3454c05a0f49f3a3bed06e5a11616ed90ddf3
/hardware/interfaces/audio/2.0/default/StreamOut.cpp
8d391c8eed27b14eab1f9fde0cb22a5c5d925a6a 28-Feb-2017 Mikhail Naganov <mnaganov@google.com> audiohal: Add diagnostic message to check the number of bytes written

Temporary change for investigating b/35813113. Need to test
the hypothesis that sometimes either legacy HAL, or the wrapper
reports more bytes written than being asked for.

Bug: 35813113
Change-Id: I6596403e0ddcdcc8b061d1977e329f67670f30db
Test: make
/hardware/interfaces/audio/2.0/default/StreamOut.cpp
b2e8954c7c4c5279931e3e357ddc0261c3d96bf7 11-Feb-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "audio: Remove timeout from waits on event flags in HAL driver threads"
e867456982c1ee68e884294f5655abb6212ab533 10-Feb-2017 Mikhail Naganov <mnaganov@google.com> audio: Remove timeout from waits on event flags in HAL driver threads

This fixes a power regression caused by periodic wakeups of
the driver threads even when the device is idle.

The timeout is really not needed, it used to be there to ensure that
the thread exits its loop, but then an explicit wake-up call before
closing the thread had been added for this purpose.

Bug: 34682579
Test: Follow repro steps from the bug, compare power consumption
to the legacy version of the audio HAL.

Change-Id: I0bfc2079a449894c5d0bd6ef19b53ca425795a9e
/hardware/interfaces/audio/2.0/default/StreamOut.cpp
a1db22a3e5b45b3bd3c2edf84c605ce211c89220 07-Feb-2017 Mikhail Naganov <mnaganov@google.com> audiohal: Pass thread identifiers to the client for priority adjustment

HALs are prohibited from using framework binder, and there is
no equivalent scheduling policy service in hwbinder. Thus, in order
to match priorities of FastCapture / Mixer threads with their
counterparts in the HAL, it is needed to request the priority boost
from audioflinger on behalf of the HAL.

Bug: 34131400
Change-Id: I7c8db9d520b4cf272d2896ad875752b109b57ab7
Test: check priority match between audioflinger's and hal's threads
/hardware/interfaces/audio/2.0/default/StreamOut.cpp
9bb90a55d6ddc81d40556f05a3f2e3f4612b9b8b 06-Feb-2017 Mikhail Naganov <mnaganov@google.com> Merge "audiohal: Make closing of effects and streams fast"
a7426f7147ae565a212f46c1dbdc351425b5b278 06-Feb-2017 Mikhail Naganov <mnaganov@google.com> Merge "audiohal: Make sure audio data transfer related commands go via FMQ"
a468fa84d13b085b1808f20f70d22ed9dbe3f3eb 31-Jan-2017 Mikhail Naganov <mnaganov@google.com> audiohal: Make sure audio data transfer related commands go via FMQ

When outputting audio, the framework issues several HAL calls
from the same thread that writes into data FMQ. These calls
also need to be served on the same thread that writes audio data
to HAL. The same thing happens when audio input is commenced.

Add a command FMQ for passing different commands to the HAL thread.
This way, depending on the calling thread, the same call may go
either via hwbinder or via the command queue.

This dramatically reduces jitter in RTT measurements (although
doesn't improve the latency).

Bug: 30222631
Test: scripted RTT app
Change-Id: I04c826e2479d8210fd9c99756241156cda3143b6
/hardware/interfaces/audio/2.0/default/StreamOut.cpp
b0abafbf0a6174e8c8933cc5fb19501a2d22c53b 01-Feb-2017 Mikhail Naganov <mnaganov@google.com> audiohal: Make closing of effects and streams fast

There were two problems:

1. Joining of reader / writer / process threads (the threads that
interact with HAL) was taking up to 1 second because the thread
was usually waiting for an event flag to be toggled, or a 1s
timeout.

2. Calling IStream.close or IEffect.close shouldn't tax the caller.
Changed the code so a call to close only signals the thread that
it's time to exit, and then the thread is only joined in the
effect or stream destructor.

Bug: 34800063
Bug: 34499806
Test: see repro steps in the bugs
Change-Id: Ife20524a1eba4ec9a78152e89862526e8cd5c960
/hardware/interfaces/audio/2.0/default/StreamOut.cpp
d63e79022a1c244617d6aab7806788570373016a 31-Jan-2017 Mikhail Naganov <mnaganov@google.com> Audio HAL default implementation: reduce logspam

Legacy BT A2DP implementation of Audio HAL may be returning EAGAIN
from get_presentation_position, this is normal and shouldn't be
logged. Otherwise we create logspam as this HAL function is called
often.

Bug: 30222631
Change-Id: I9394dbc1d53c1f4136c2d538fccd519964ff1697
Test: play music via BT A2DP
/hardware/interfaces/audio/2.0/default/StreamOut.cpp
6b058752c53d61596f8cda16dfa8f8842bca8a2e 23-Jan-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Use MQDescriptor typedefs for cleanup"
790db1074c92cc682c0da7fcdf454bd5e36f93fb 10-Jan-2017 Hridya Valsaraju <hridya@google.com> Use MQDescriptor typedefs for cleanup

Test: mm
Bug: 33815422

Change-Id: I41ca833231622a5a72970014cfcac400b512e44a
/hardware/interfaces/audio/2.0/default/StreamOut.cpp
ee901e3fd885709abc9b9e2b8e521022e27522d3 12-Jan-2017 Mikhail Naganov <mnaganov@google.com> audiohal: Fix incompatibility with legacy hal for writes

The combo call to stream_out->write + get_presentation_position
wasn't delivering the results of these calls entirely
correctly. Since the 'WriteResult' struct was lacking the field
for returning the status of the call to
'get_presentation_position', the client could erroneously update
the presentation position to bogus values if the call to the
legacy HAL had failed.

Updated IStreamOut.WriteStatus to include the missing field,
and updated the code to fill it out.

Also fixed logspam resulting from calling a stubbed
stream_in->get_capture_position.

Bug: 30222631
Test: Loopback RTT, media CTS
Change-Id: I38ac3b01beb095e176b54608e11e71ae5d5eafb6
/hardware/interfaces/audio/2.0/default/StreamOut.cpp
b29438ef70549a331d11c0384c53cf1dc6e7f0be 22-Dec-2016 Mikhail Naganov <mnaganov@google.com> audiohal: Re-implement stream read and write using FMQ

Result: no hwbinder calls due read / write session.

Added IStream.close method for explicitly freeing up of resources
consumed by the stream before automatic server objects reaping
gets to it.

Test: make, perform Loopback RTT, check traces
Bug: 30222631
Change-Id: I678559f6ef30026685df787cd2ba7c2ee449ed27
/hardware/interfaces/audio/2.0/default/StreamOut.cpp
f6b8df28cf405be72ee6765bc742efe697f15ae7 21-Dec-2016 Eric Laurent <elaurent@google.com> Merge changes I64f56526,I65c5c7ba

* changes:
audio treble HAL: implement methods and structures for stream in MMAP mode
audio: add methods and structures for streamin MMAP mode
7deb7dad39e58b6e5de812075950adc27cd51d95 16-Dec-2016 Eric Laurent <elaurent@google.com> audio treble HAL: implement methods and structures for stream in MMAP mode

Bug: 33398120
Test: make marlin-eng with ENABLE_TREBLE true
Change-Id: I64f56526c7c775b03191439188545171b565ef31
/hardware/interfaces/audio/2.0/default/StreamOut.cpp
685f0e36a1185b24f473f0382ba2175685dbcdf9 17-Dec-2016 Mikhail Naganov <mnaganov@google.com> Fix offload tracks playback

Translation between audio_offload_info_t and AudioOffloadInfo
was missing a field. This was causing compressed tracks to play
using 'deep_buffer' mode instead of 'offload'.

Changing output stream async callback methods to 'oneway',
since they don't require anything from the callee.

Change-Id: I27fe7fb715e421f102db21a10d34e1dc3134cf01
Test: play MP3 file with Play Music, check audioflinger dump
/hardware/interfaces/audio/2.0/default/StreamOut.cpp
13f43f4afeb56edf8aab858320107d0e378a6356 08-Dec-2016 Mikhail Naganov <mnaganov@google.com> audiohal: Do not log if EINVAL is received from get_presentation_position

This happens often, and it's normal. Avoid logging it down as this
causes logspam.

Bug: 33353073
Change-Id: Ia3b1b8af61bdf83e9bcde0e5bed0285af037df45
Test: cause the system to play some sounds (e.g. UI clicks), watch logcat
/hardware/interfaces/audio/2.0/default/StreamOut.cpp
7bdce32513128aeee040f5ea0fcf2773f2e1e557 02-Dec-2016 Yifan Hong <elsk@google.com> Merge "Update to use the correct logging library."
f9d303435d80161fabb16cdff3b8f2f75f362480 30-Nov-2016 Yifan Hong <elsk@google.com> Update to use the correct logging library.

Test: mma compiles
Change-Id: Idb33dea5faaf1a5e54719c2a5a683d2d47e9b8e8
/hardware/interfaces/audio/2.0/default/StreamOut.cpp
6e81e9bb3c13d8c51fde503cf8be2bfb56e1ca1d 17-Nov-2016 Mikhail Naganov <mnaganov@google.com> Audio HAL: fixes for issues discovered after client conversion

Several issues addressed:

-- added IDevice.supportsAudioPatches to query whether
create/removeAudioPatch is actually supported by HAL;

-- IStreamOutCallback proxy needs to be owned by IStreamOut
implementation. In order for the client to reset the reference,
added method IStreamOut.clearCallback;

-- IDevice.open{Input|Output}Stream need to return a "suggested" audio
config from HAL;

-- code for converting between system/audio.h and HIDL
data structures has been moved to
android.hardware.audio.common@2.0-util library for reuse;

-- added a workaround for the issue with QC effects HAL trying to write
into the input parameters buffer, which is r/o by Binder design.

Bug: 30222631
Change-Id: I64af24d79c12d6ac3b0f87d085a821913e29237b
Test: tried using with WIP HIDL client on N5X
/hardware/interfaces/audio/2.0/default/StreamOut.cpp
70b9a15df00a42b319279d903bf5923564920e3b 18-Nov-2016 Martijn Coenen <maco@google.com> Use newly introduced hidl_handle.

Bug: 32089785
Test: builds
Change-Id: I27c7d3945e1fe390661bf322987011a00fe9b3fe
/hardware/interfaces/audio/2.0/default/StreamOut.cpp
10548295023bee99108e418499aff09fe578211e 31-Oct-2016 Mikhail Naganov <mnaganov@google.com> Implement audio devices and streams HAL delegating to legacy HAL

Changes made to the .hal definition:

- introduce Effect ID returned by the IEffectsFactory that
needs to be passed to IStream.{add|remove}Effect; otherwise
it's impossible to retrieve the underlying HAL effect handle;

- change "bus address" in DeviceAddress to "string" type;

- fix signature of some methods w.r.t. returning Result;

- remove unused "struct AudioPatch".

Bug: 30222631
Test: make
Change-Id: Icb51729ef57bb2a5b0b78609735e7481bc04f95c
/hardware/interfaces/audio/2.0/default/StreamOut.cpp