Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fcb00d9d authored by Garmond Leung's avatar Garmond Leung Committed by Gerrit - the friendly Code Review server
Browse files

policy_hal: update custom audio policy implementation APIs against O-AOSP

update custom audio policy implementation APIs against below O-AOSP updates.

1) audio policy: broadcast device connect event before refreshing profiles

This patch broadcasts the connect device event before checking and reloading
capabilities of profiles.
It allows the HAL implementor to use connect / disconnect event to respectively
load / reset capabilities of devices that has dynamic capabilities (e.g. HDMI).

Change-Id: Ie0533da25fed89cb9e5bbfc5b1fc886b3176837d

2) audio policy: fix volume control regression

commit 28d09f064 introduced regressions in volume control resulting
in changing some device/stream volumes unexpectedly.

Bug: 27586382
Change-Id: I3fe2a25767319800b0db5fd1ed7c1bd751b04732

3) audio policy: fix in call volume over USB

Do not consider only primary output for voice volume control as
sometimes the output device selected for a call can be connected to
another output stream (e.g USB)

Bug: 27108587
Change-Id: I8ec3db272f87d49f57044a771019672050f63d32

4) audio policy: new getOutputForAttr() prototype.

Update getOutputForAttr() prototype and group all logic
dealing with audio attributes to stream type conversion in
audio policy manager.

Bug: 18067208.
Change-Id: I1bfbe9626c04c7955d77f8a70aecfad2cb204817

5) AudioRecord: use audio attributes instead of audio source.

Added AudioRecord constructor with audio attributes.
Replaced AudioPolicymanager::getInput() by getInputForAttr().

Bug: 16006090.
Change-Id: I15df21e4411db688e3096dd801cf579d76d81711

6) audiopolicy: Two clients can not offload concurrently

If two application are playing a compatible offload stream at the same
time.

Bug: 34012147
Change-Id: I98a8913d6faf5092a1e43a0bdd0f1ce1482221a9

7) Fix clang-tidy warnings in audio and playerservice.

* Add explicit keyword to conversion constructors.
Bug: 28341362
* Use const reference type for read-only parameters.
Bug: 30407689
Test: build with WITH_TIDY=1
Change-Id: I265f3b094e08d5705b506b3fbba51439c134af84

8) audio policy for concurrent capture.

First implementation of concurrent capture policy:
Initially, only capture for HOTWORD or FM TUNER sources or
re-route submix is allowed at the same time as any other capture.
Several capture clients can share the same input stream. In this case
active clients are sorted by audio source priority level and the input
path configuration and routing is driven by the highest priority
active source.

Bug: 22702906
Change-Id: Icbedfe001c6243ecad7a7b57ab78d893b2b97402

Change-Id: I54f24d3e0914db3c9f7da26ea053ee6c5aa91784
parent 9065e379
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -26,7 +26,8 @@ LOCAL_C_INCLUDES := $(TOPDIR)frameworks/av/services \
                    $(TOPDIR)frameworks/av/services/audiopolicy/engine/interface \
                    $(TOPDIR)frameworks/av/services/audiopolicy \
                    $(TOPDIR)frameworks/av/services/audiopolicy/common/managerdefinitions/include \
                    $(call include-path-for, avextension)
                    $(call include-path-for, avextension) \
                    $(TOPDIR)system/core/base/include


LOCAL_SHARED_LIBRARIES := \
+184 −262

File changed.

Preview size limit exceeded, changes collapsed.

+14 −20
Original line number Diff line number Diff line
/*
 * Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
 * Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
 * Not a contribution.
 *
 * Copyright (C) 2009 The Android Open Source Project
@@ -67,15 +67,15 @@ public:
                                         audio_io_handle_t *input,
                                         audio_session_t session,
                                         uid_t uid,
                                         uint32_t samplingRate,
                                         audio_format_t format,
                                         audio_channel_mask_t channelMask,
                                         const audio_config_base_t *config,
                                         audio_input_flags_t flags,
                                         audio_port_handle_t selectedDeviceId,
                                         input_type_t *inputType);
                                         input_type_t *inputType,
                                         audio_port_handle_t *portId);
        // indicates to the audio policy manager that the input starts being used.
        virtual status_t startInput(audio_io_handle_t input,
                                    audio_session_t session);
                                    audio_session_t session,
                                    concurrency_type__mask_t *concurrency);
        // indicates to the audio policy manager that the input stops being used.
        virtual status_t stopInput(audio_io_handle_t input,
                                   audio_session_t session);
@@ -90,13 +90,6 @@ protected:
                                                   audio_devices_t device,
                                                   int delayMs = 0, bool force = false);

        // selects the most appropriate device on output for current state
        // must be called every time a condition that affects the device choice for a given output is
        // changed: connected device, phone state, force use, output start, output stop..
        // see getDeviceForStrategy() for the use of fromCache parameter
        audio_devices_t getNewOutputDevice(const sp<AudioOutputDescriptor>& outputDesc,
                                           bool fromCache);

        // avoid invalidation for active music stream on  previous outputs
        // which is supported on the new device.
        bool isInvalidationOfMusicStreamNeeded(routing_strategy strategy);
@@ -109,12 +102,12 @@ protected:

        // if argument "device" is different from AUDIO_DEVICE_NONE,  startSource() will force
        // the re-evaluation of the output device.
        status_t startSource(sp<AudioOutputDescriptor> outputDesc,
        status_t startSource(const sp<AudioOutputDescriptor>& outputDesc,
                             audio_stream_type_t stream,
                             audio_devices_t device,
                             const char *address,
                             uint32_t *delayMs);
         status_t stopSource(sp<AudioOutputDescriptor> outputDesc,
         status_t stopSource(const sp<AudioOutputDescriptor>& outputDesc,
                            audio_stream_type_t stream,
                            bool forceDeviceUpdate);
        // event is one of STARTING_OUTPUT, STARTING_BEACON, STOPPING_OUTPUT, STOPPING_BEACON
@@ -143,6 +136,7 @@ private:
        audio_io_handle_t getOutputForDevice(
                audio_devices_t device,
                audio_session_t session,
                uid_t client,
                audio_stream_type_t stream,
                uint32_t samplingRate,
                audio_format_t format,
@@ -155,12 +149,10 @@ private:
                audio_session_t session,
                audio_stream_type_t *stream,
                uid_t uid,
                uint32_t samplingRate,
                audio_format_t format,
                audio_channel_mask_t channelMask,
                const audio_config_t *config,
                audio_output_flags_t flags,
                audio_port_handle_t selectedDeviceId,
                const audio_offload_info_t *offloadInfo);
                audio_port_handle_t *portId);
        // Used for voip + voice concurrency usecase
        int mPrevPhoneState;
#ifdef VOICE_CONCURRENCY
@@ -170,8 +162,10 @@ private:
        // Used for record + playback concurrency
        bool mIsInputRequestOnProgress;
#endif

#ifdef FM_POWER_OPT
        float mPrevFMVolumeDb;
        bool mFMIsActive;
#endif
};

};