Commit graph

83 commits

Author SHA1 Message Date
Jean-Michel Trivi
71834f3775 r_submix module: pipe size changes with sample rate
Adapt the pipe size based on the sample rate.
Behavior is unchanged for the default sample rate (48kHz), size
is adjusted by the ratio relative to the default rate.

Bug: 141604269
Test: atest AudioHostTest#testTwoChannelCapturingMediaConversion
Change-Id: I0ba45af18ef02dc0ef77d480e1203d2cd1db9864
2022-02-02 08:27:24 -08:00
Greg Kaiser
3f7bbbb4f1 r_submix HAL: Remove unused variable
We no longer set force_pipe_creation after the removal of
legacy code for in-pipe conversions, so we remove it.

Test: TreeHugger
Bug: 141604269
Change-Id: I82393ba0ad3142aa75d482cc6b0edbaeebbd8116
2022-01-05 07:00:42 -08:00
Jean-Michel Trivi
61d799a5e1 Merge "r_submix HAL: remove legacy code for in-pipe conversions" 2022-01-04 16:36:02 +00:00
Jean-Michel Trivi
16699d13ec r_submix: add owners file
Bug: 141604269
Test: see gerrit
Change-Id: I975390f8f495267ef0cd24dc8e73db859e541146
2021-12-30 16:29:03 -08:00
Jean-Michel Trivi
a33c1654fb r_submix HAL: remove legacy code for in-pipe conversions
Old hacky uses of this HAL required channel and sample
rate conversion, which were never expected when this HAL
is used for its real application as the backend for
dynamic audio policies. In that context conversions are
performed in audio_flinger in the mixer.

Bug: 141604269
Test: atest AudioHostTest#testTwoChannelCapturing

Change-Id: I333e981fb3db403ab2da6f77debe49bc7d132ebc
2021-12-23 11:49:28 -08:00
Mikhail Naganov
8c97d24e3a r_submix: Implement get_capture_position
IStream.getCapturePosition becomes mandatory in
audio HAL V7. The legacy implementation must
provide it for the default HAL implementation.

Bug: 161253754
Test: atest VtsHalAudioV7_0TargetTest
Change-Id: I2f2094f0499ba85f53f291e0a269211981b4c9d8
2021-03-17 13:19:49 -07:00
Bob Badour
d7984ccf02 [LSC] Add LOCAL_LICENSE_KINDS to hardware/libhardware
Added SPDX-license-identifier-Apache-2.0 to:
  modules/audio/Android.bp
  modules/audio_remote_submix/Android.bp
  modules/audio_remote_submix/tests/Android.bp
  modules/camera/3_0/Android.bp
  modules/consumerir/Android.bp
  modules/fingerprint/Android.bp
  modules/gralloc/Android.mk
  modules/hwcomposer/Android.bp
  modules/input/evdev/Android.bp
  modules/local_time/Android.bp
  modules/nfc-nci/Android.bp
  modules/nfc/Android.bp
  modules/power/Android.bp
  modules/radio/Android.bp
  modules/sensors/Android.bp
  modules/sensors/Android.mk
  modules/sensors/dynamic_sensor/Android.bp
  modules/sensors/dynamic_sensor/HidUtils/Android.bp
  modules/soundtrigger/Android.bp
  modules/thermal/Android.bp
  modules/tv_input/Android.bp
  modules/usbaudio/Android.bp
  modules/usbcamera/Android.bp
  modules/vibrator/Android.bp
  modules/vr/Android.bp
  tests/camera3/Android.bp
  tests/fingerprint/Android.bp
  tests/hardware/Android.bp
  tests/hwc/Android.bp
  tests/input/evdev/Android.bp
  tests/nusensors/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD to:
  Android.bp
  modules/camera/3_4/Android.mk

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all

Exempt-From-Owner-Approval: janitorial work
Change-Id: I28924363e6c478f5d0b465b63534c4efd041c770
2021-02-12 20:51:13 -08:00
Mikhail Naganov
e72761731d Convert mask types from uint32_t to enum type
This applies to the following types:

- audio_gain_mode_t;
- audio_flags_mask_t;
- audio_channel_representation_t;
- audio_channel_mask_t;
- audio_devices_t.

Enum types are distinct thus proper overloading on the type
is possible in C++. Also, assignments to enum types are
less prone to errors.

Bug: 169889714
Test: basic audio functionality
Change-Id: I8f1e6fa2bbad8900fdae66f01ac70c75953fd62c
Merged-In: I8f1e6fa2bbad8900fdae66f01ac70c75953fd62c
2020-11-24 03:43:26 +00:00
Inseob Kim
73dad9ba12 Merge "Use shared version of vndk libmedia_helper" am: deb0edbe3a am: 1f95cfe12e
am: 738edce4ac

Change-Id: Ic2a698b04ce0ca812edf8397bd835dd235a62eb9
2019-11-10 22:37:54 -08:00
Treehugger Robot
deb0edbe3a Merge "Use shared version of vndk libmedia_helper" 2019-11-11 06:15:20 +00:00
Mikhail Naganov
739ce6bbad r_submix: Fix get_next_write_timestamp and get_input_buffer_size
Fix the implementation to conform to VTS expectations.

out_get_next_write_timestamp must return "NOT_SUPPORTED" (-ENOSYS)
as it is not supported.

adev_get_input_buffer_size must return a non-zero
buffer size for supported formats, regardless of whether
there are any opened streams at the moment.

Bug: 141847510
Test: atest VtsHalAudioV6_0TargetTest
Change-Id: I322bf8cf42415fddb028c9cd10db0ac82089ce85
2019-11-05 14:52:57 -08:00
Eric Laurent
7788716bde audio remote submix: fix write blocked on input standby
Do not block in out_write() when the peer input is in standby to avoid
remaining stuck when writing to the blocking mono pipe.
Bug: 141878993
Test: atest AudioHostTest#testTwoChannelCapturing
Change-Id: Ie92d59529ac1018a6785c3ac31696dcccdbb204a
2019-10-15 12:20:34 -07:00
Mikhail Naganov
6c857d913a Merge "Remote submix: replace include path with module dependency" am: 9359ffb16b am: 5290206202 am: 4cd72e2e6c am: d7e68975db
am: 0bea0da877

Change-Id: I8bf6aa0dde3e2566b5ded95ab47cb2577024f1eb
2019-08-05 11:38:08 -07:00
Mikhail Naganov
5290206202 Merge "Remote submix: replace include path with module dependency"
am: 9359ffb16b

Change-Id: Ifb7af40f20ee05a034063c3c179282c301926344
2019-08-05 11:08:23 -07:00
Mikhail Naganov
282ca7a544 Remote submix: replace include path with module dependency
The include path was needed because libnbaio_mono was missing
an include export for libaudioutils headers.

Test: make
Change-Id: I6d6aa2826ed259b682e8a417557fb6fdfb3caea6
2019-08-02 08:55:16 -07:00
Mikhail Naganov
e842139890 Merge "r_submix: Fix compilation for non-default configurations" am: a5c2957f63 am: fcaa728e9e am: 0440eb8f00 am: 815f0f234d
am: a8cb6b00a8

Change-Id: Ib122861bfa2adffbecc4aefa89de7388e8a24e81
2019-07-26 22:01:33 -07:00
Mikhail Naganov
fcaa728e9e Merge "r_submix: Fix compilation for non-default configurations"
am: a5c2957f63

Change-Id: Iaa60e3cf875ce2f0606b4080eff06b66e8fa0072
2019-07-26 21:10:35 -07:00
Mikhail Naganov
1462c760d7 r_submix: Fix compilation for non-default configurations
Fix compilation for:
  #define ENABLE_LEGACY_INPUT_OPEN 0
  #define ENABLE_RESAMPLING 0

Test: make
Change-Id: I11a868c49181b35d3b85ea62a372a94a1b589bc1
2019-07-26 15:11:41 -07:00
Eric Laurent
f76f1832d1 remote submix: force pipe shutdown on input close
Force mono pipe shutdown when all input stream clients are closed
so that a pending write is not stuck waiting for available buffer.

Bug: 119057550
Test: abort search on BLE remote
Merged-In: I4391e73874e502da5000b1746436fb61bb2fe869
Change-Id: I4391e73874e502da5000b1746436fb61bb2fe869
2019-07-26 15:10:03 -07:00
Inseob Kim
0e88ff0735 Use shared version of vndk libmedia_helper
Vendor modules should use shared vndk.

Bug: 137178339
Test: m
Change-Id: Ia4911f189750d9c54bcf8a4572b8c8aad27d866b
2019-07-24 13:52:47 +09:00
Eric Laurent
2cadb587e0 remote submix: add null check on audio pipe pointer
In remote submix audio HAL, Add null check on Pipe sink pointer
in out_get_presentation_position() and out_get_render_position().

Bug: 117183072
Test: manual test with capture from BLE remote mic.
Change-Id: I05aa87f414c69bcd08c7692918e6a215077b7ea2
2019-07-01 11:55:52 -07:00
François Gaffie
71832e785c Fix remote submix MIX_RECORD stop
Since rework of presentationTimestamp in AudioFlinger, it is expecting
to drain correctly before stopping an output.
When a MIX RECORDER is set,
1/ Dynamic Policy Mix is registered
2/ Extraction Sink Port is made available
3/ Player is started on this sink
4/ Extraction source port is connected upon start Output
4/ Capture may be launched on the source to be rerouted
5/ All Capture are stopped, player is stopped
6/ Extraction source port shall be disconnected on stopOutput

Step 6 does not happen as the track is never set as drained.

Upon capture stop, rxSink MonoPipe is put in shutdown state. Any further
write will discard the buffer. However, frames written shall be
incremented of these frame discarded to be able to set the track as
drained.

This CL fixes this issue.

Test: AudioPolicyEmulatorTests --gtest_filter=RecordInjectionSourceMatch/DynamicPolicyMixRecordInjectionTest.RecordingInjection/*
Bug: 130356101
Change-Id: I861c4867991da8bcc1090be56d64e69646d58dc2
Signed-off-by: François Gaffie <francois.gaffie@renault.com>
2019-04-15 14:34:06 -07:00
Eric Laurent
5b78d41954 remote submix: force pipe shutdown on input close
Force mono pipe shutdown when all input stream clients are closed
so that a pending write is not stuck waiting for available buffer.

Bug: 119057550
Test: abort search on BLE remote
Change-Id: I4391e73874e502da5000b1746436fb61bb2fe869
2019-03-04 19:45:12 +00:00
Mikhail Naganov
16ad46ef48 Revert recent r_submix patches
Revert "r_submix: Fix logspam on pipe corruption"
This reverts commit ab5b51838c.
Revert "r_submix: Use intermediate pipe in non-blocking mode"
This reverts commit 1df8a0039f.

Reason: breaks Android Auto projected mode

Bug: 74142786
Test: with Android Auto head unit simulator
Change-Id: I8e1bc146a131cb5b1ab88cf242b03a6b02a84339
2018-03-05 20:39:30 +00:00
Mikhail Naganov
1d0e97310b Revert recent r_submix patches
Revert "r_submix: Fix logspam on pipe corruption"
This reverts commit ab5b51838c.
Revert "r_submix: Use intermediate pipe in non-blocking mode"
This reverts commit 1df8a0039f.

Reason: breaks Android Auto projected mode

Bug: 74142786
Test: with Android Auto head unit simulator
Change-Id: I8e1bc146a131cb5b1ab88cf242b03a6b02a84339
2018-03-05 12:32:13 -08:00
Mikhail Naganov
ab5b51838c r_submix: Fix logspam on pipe corruption
Prevent logging an error message on every attempt to write
if the FIFO backing up the MonoPipe got corrupted. This condition
can be detected by checking for -EIO error code.

Bug: 74067530
Test: make audio_utils_fifo_base::mIsShutdown to be set by default,
      run r_submix_tests and observe logcat

Change-Id: I5d67997e902e834f04c10f9ffb39b16cba9c5739
2018-03-01 13:49:58 -08:00
Mikhail Naganov
1df8a0039f r_submix: Use intermediate pipe in non-blocking mode
Switch the pipe into non-blocking mode to prevent stalling
when attempting to close it.

Simulate circular buffer behavior by flushing old data if
there is no more space in the pipe.

This removes the need for "exiting=1" parameter.

Bug: 73175392
Test: r_submix_tests
Change-Id: Iff89980af71112892ff262030e471ae736b1f62a
2018-02-27 10:11:33 -08:00
Mikhail Naganov
bf115538e8 r_submix: Add more tests
From analyzing the coverage data, these tests seem to cover
all the critical functionality of the remote submix module.

Bug: 73175392
Test: r_submix_tests
Change-Id: I7f6be95245c6ab59611fc5e269e3f9f2079b8ee4
2018-02-27 10:02:33 -08:00
Mikhail Naganov
80179932c9 r_submix: Add some tests
Add simple tests to verify remote submix behavior regarding
blocking writes. Currently one of the tests fails (does not finish),
this needs to be fixed.

Also fixed some minor issues in remote submix module code.

Bug: 73175392
Test: r_submix_tests
Change-Id: Ic88d0c385c0102e35b4f751f9c5cd8a6488949c8
2018-02-15 17:09:47 -08:00
Kevin Rocard
c6ec9486d8 Revert "Audio V4: Split system and vendor Audio.h"
This reverts commit fc9e212f01.

Reason for revert: Breaks multiple devices

Change-Id: I816671fd92246f85c97d00819858a74e36e2929d
2018-01-24 06:04:27 +00:00
Kevin Rocard
fc9e212f01 Audio V4: Split system and vendor Audio.h
audio.h and its dependencies (audio-effect.h, sound_trigger.h...)
used to be shared between system and vendor code.

This led to multiple problems:

1) Such sharing contradicts the Treble policy of
strict independence of framework and vendor code.

2) When audio.h was changed, every vendor needed to update
its code in the next release. This meant that audio*.h
headers were mostly changed in backward compatible manner.
Nevertheless, for P the HIDL interface and thus the audio.h
interface are changed in backward incompatible way.
(Some enum are becoming 64 bit long).

3) As the headers were common, some API used only by the framework
needed to be visible to the vendors (mostly enum values).

4) Treble policy is to support at least one previous HAL version

As a result the audio*.h headers are now duplicated,
one set for the framework, and one for the vendor.

Each set will evolve independently. After this split,
the framework-only APIs will be removed from the vendor headers
and vice versa.

The split is implements as such:

 + for system code

    - NOT moving the libaudio_system_headers
      Eg: system/audio.h and system/audio_effects/effect_equalizer.h
          are still in system/media/audio

    - the legacy audio HAL API that were in libhardware headers
          are now in libaudiohal_legacy_headers
      Eg: hardware/audio.h and hardware/audio_effect.h
          are now in frameworks/av/media/libaudiohal/legacy/

 + for vendor code

    - moving libaudio_system_headers and the legacy audio HAL API
          that were in libhardware_headers in
          android.hardware.audio.common.legacy@2.0
      Note that those headers are now versioned, so migrating to a @4.0
          HIDL HAL will mean changing the legacy dependency too.
      Eg: system/audio.h, system/audio-effect.h, hardware/audio.h
          are now in hardware/interfaces/audio/common/2.0/legacy

    - the legacy audio effect HAL API that was in libaudioeffects
          is now moved in android.hardware.audio.effect.legacy@2.0
      Eg: audio_effects/effect*.h are now in
          hardware/interfaces/audio/effect/2.0/legacy

    - the legacy sound trigger HAL API that were in libhardware_headers
          is now moved in android.hardware.soundtrigger.legacy@2.0
      Eg: hardware/sound_trigger.h is now in
          hardware/interfaces/audio/effect/2.0/legacy

libaudioutil being used by both system and vendor, had
to be renamed for system to libaudioutil_system.

Vendor libs that now depend on the audio.h of a specific
version and are not extensively referenced in non google code,
append @2.0 to their name.

Note that headers that are not expected to change in the 4.0 HAL are
left in all-versions folder to avoid duplication.
This is an implementation detail as the versioned libraries export
the all-versions headers.

Note that strict vendor-system separation is enforced by the
build-system. The system headers are not available for vendor
libs and vice-versa.

Note that this patch is split between numerous git repository (>10),
all the commits having the same Change-id for searchability.

Note that audio_policy.h is no longer exposed to vendors
as the legacy audio policy HAL API was never officially supported.
As a result the audiopolicy stub implementation has been removed.

Test: compile taimen-userdebug walleye-userdebug
              sailfish-userdebug marlin-userdebug
              gce_x86_phone-userdebug gce_x86_phone
              full-eng aosp_arm aosp_x86-eng
Test: check that the emulator booted and played audio
Test: full QA on sailfish-userdebug and taimen-userdebug
Bug: 38184704
Change-Id: I950f4e0a55613d72e32eba31bd563cb5bafe2d1a
Signed-off-by: Kevin Rocard <krocard@google.com>
2018-01-20 21:39:40 -08:00
Dan Willemsen
86e247ae89 Convert to Android.bp
See build/soong/README.md for more information

Test: mmma hardware/libhardware
Change-Id: Ibb7e2af9d55f581e951d8996cea5e52cd0766b04
2017-12-27 11:05:29 -08:00
Chih-Hung Hsieh
66f312b91c Merge "Use -Werror in hardware/libhardware/modules"
am: 298fc4f6f5

Change-Id: I3c23dc4ce4609ec27402cae52b71ef79067c8e73
2017-12-06 18:42:24 +00:00
Chih-Hung Hsieh
1f601b1d7d Use -Werror in hardware/libhardware/modules
* Remove unused local variables.
* Remove or comment out unused static functions.
* Fix trivial bugs found by unused value warnings.

Bug: 66996870
Test: build with WITH_TIDY=1
Change-Id: I99389b883c89551850180d25241a35a40bb77b26
2017-12-01 10:37:19 -08:00
Steven Moreland
ee7cf40c01 Make audio_remote_submix build with the VNDK.
When the vndk is enabled (BOARD_VNDK_VERSION=current),
vendor libraries must only link against vendor variants
in the build system. This means that they receive restricted
sets of headers and that automatic global headers are restricted.

Test: build audio_remote_submix with BOARD_VNDK_VERSION=current
Bug: 37342627
Change-Id: I1170443466df58fa7b66096241e881a38f8cf1ac
2017-07-06 11:11:16 -07:00
Jiyong Park
118f3dc236 Build audio.r_submix.default with BOARD_VNDK_VERSION
Add missing header unistd.h

Bug: 37342627
Test: BOARD_VNDK_VERSION=current m -j audio.r_submix.default
Change-Id: I5baa960dcdfc3d93d7cf172b23173dfb48babf88
2017-07-04 12:55:23 +09:00
Vijay Venkatraman
8352c0dddf Add libhardware_headers and libutils
Bug: 33241851
Test: build target and pass CTS
Test: With BOARD_VNDK_VERSION, mma works
Change-Id: I3303ed86d49207987dc611b3a2112e9361ddd979
2017-06-02 15:56:37 -07:00
Mark Salyzyn
1ae7379baa resolve merge conflicts of 7c451a93 to oc-dev-plus-aosp
Test: I solemnly swear I tested this conflict resolution.
Bug: 34250038
Change-Id: I4196a6d5a1365106643ac6c1548fd86faffead6f
2017-04-12 09:11:38 -07:00
Mark Salyzyn
d88dfe8607 libhardware: deprecate cutils/log.h
Replace cutils/log.h with log/log.h. Sort headers. Minimize conflicts.
Add missing required headers.

Test: compile
Bug: 34250038
Change-Id: I5c0f231cbfed90b73e0538c9d32ad3226c7cc5e4
2017-04-11 10:50:06 -07:00
Po-Chien Hsueh
c535b2fded Move default HAL libraries to vendor
Libraries under /hardware/libhardware/modules should go to /vendor/.

These are conventionl HALs for default implementations, most of them
are not used.

Camera and thermal are already moved in other CLs.

Bug: 35907904
Test: Compiled and checked install path. Verified on Sailfish with
$ lsof | grep default.

Change-Id: Ibde574001c01cbfea014a20a0fbbb3265e6cdc8a
2017-03-07 11:28:32 +08:00
Glenn Kasten
57eaa9bcd8 fifo: add dependency needed after re-implementation of MonoPipe
MonoPipe is being re-implemented on top of FIFO in audio_utils.

Test: builds OK
Change-Id: I42a30c5cc859150c3b9e2b23aad3c9c14c7c341a
2016-12-12 15:54:14 -08:00
Jean-Michel Trivi
79fbccf91b Fix typo in error logs in r_submix open_input_stream function
Change-Id: I52d5268290802e3f0a88662aa6fbe9a46efda735
2016-04-05 17:20:29 -07:00
Eric Laurent
854a10af10 Add debug folder for audioserver
Use /data/misc/audioserver instead of data/misc/media for
audioserver debug.

Bug: 27064332
Change-Id: Ic213ee0354d9ab1ed1980e8c3d07cd239597ad2e
2016-02-24 00:27:46 +00:00
Glenn Kasten
04c88495bb Remove TimedAudioTrack and associated code
Bug: 8278435
Change-Id: I095c1a4888e645e14d93b0b15fbef4524a831ca1
2016-01-25 13:43:58 -08:00
Andy Hung
0b93c0ab58 Do not reset out_get_presentation_position() to 0 on standby
Bug: 21199150
Bug: 23080499
Change-Id: I749b331bfce8cfe27b16bb2fce14f23816fb48ce
2015-08-12 23:28:30 +00:00
Jean-Michel Trivi
25f4751f6d Implement timestamp reporting functions
Count number of frames that have been written, reset on standby.
The presentation position is the number of written frames minus
  the frames still in the pipe (they were written but not presented).

Bug 21198864

Change-Id: I00ef10f56a825555e7a970cce1504a9bd3744e04
2015-05-28 16:19:36 -07:00
Jean-Michel Trivi
bbb3e77ab0 Reduce pipe length
Bug 21198864

Change-Id: I5bb7ba20c4e2d294363a3a4487f4e3ae634ada46
2015-05-27 09:40:56 -07:00
Jean-Michel Trivi
257fde6eb5 Reroute submix HAL: fix race condition on output state
When reading from a pipe, the output may have been previously
 closed, therefore the output state should only be read if it
 is still available.
This fixes a race condition observed between in_read() (which
 accesses the output stream) and adev_close_output_stream()
 (which sets the output reference to NULL).
 No issue with out_write() which checks the input reference.

Bug 16009464

Change-Id: I979bc12c8fe91fad9b6f6c9e0be107c1bacae360
2014-12-09 20:27:11 -08:00
Jean-Michel Trivi
b73bc86089 Support multiple pipes for rerouting
The implementation for "remote submix" supported only one pipe
  to capture the output of a mix.
This CL adds support for multiple pipes to support capturing
  multiple audio routes.
The structure for the r_submix audio device holds an array
  of route configurations (route_config), each referencing
  the input and output of the pipe dedicated to this route.
  Each route is associated to a unique address. Standby
  status is maintained per stream.

Bug 16009464

Change-Id: Ie164c4ad2a6d8138f825484e7faf29a974ccf82e
2014-11-17 17:04:45 -08:00
Jean-Michel Trivi
793a854e45 Fix remote submix crash on null sink
The "remote submix" HAL uses a MonoPipe instance to "pipe" audio
  from the sink of this virtual device HAL to its source.
  The life-cycle of this pipe is:
  - creation when either the input or output stream is open
  - destruction when both input and output are closed.

Changes are:
Fix test for pipe destruction: destroy pipe when both
  input and output streams are NULL.
Count how many read errors went into the logs and cap them
  so as not to spam the logs when the pipe is not properly
  set up. Less 'I' logs, 'D' logs instead.
When opening input stream, check for non-null sink before
  checking if it's shutdown.

Bug 16653334
Bug 17111907

Change-Id: I634b4192b00f9b74a5109f42242423e9c8cb4c7c
2014-10-15 15:16:10 -07:00