Loading services/audiopolicy/Android.mk +8 −2 Original line number Diff line number Diff line Loading @@ -16,13 +16,13 @@ else LOCAL_SRC_FILES += \ service/AudioPolicyInterfaceImpl.cpp \ service/AudioPolicyClientImpl.cpp endif LOCAL_C_INCLUDES := \ $(TOPDIR)frameworks/av/services/audioflinger \ $(call include-path-for, audio-effects) \ $(call include-path-for, audio-utils) $(call include-path-for, audio-utils) \ $(TOPDIR)frameworks/av/services/audiopolicy/common/include LOCAL_SHARED_LIBRARIES := \ libcutils \ Loading Loading @@ -63,6 +63,9 @@ LOCAL_SHARED_LIBRARIES := \ liblog \ libsoundtrigger LOCAL_C_INCLUDES += \ $(TOPDIR)frameworks/av/services/audiopolicy/common/include \ LOCAL_STATIC_LIBRARIES := \ libmedia_helper \ libaudiopolicycomponents Loading @@ -84,6 +87,9 @@ LOCAL_SHARED_LIBRARIES := \ LOCAL_STATIC_LIBRARIES := \ libaudiopolicycomponents LOCAL_C_INCLUDES += \ $(TOPDIR)frameworks/av/services/audiopolicy/common/include \ LOCAL_MODULE:= libaudiopolicymanager include $(BUILD_SHARED_LIBRARY) Loading services/audiopolicy/common/include/policy.h 0 → 100755 +84 −0 Original line number Diff line number Diff line /* * Copyright (C) 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include <system/audio.h> // For mixed output and inputs, the policy will use max mixer sampling rates. // Do not limit sampling rate otherwise #define MAX_MIXER_SAMPLING_RATE 48000 // For mixed output and inputs, the policy will use max mixer channel count. // Do not limit channel count otherwise #define MAX_MIXER_CHANNEL_COUNT 8 /** * A device mask for all audio input devices that are considered "virtual" when evaluating * active inputs in getActiveInput() */ #define APM_AUDIO_IN_DEVICE_VIRTUAL_ALL (AUDIO_DEVICE_IN_REMOTE_SUBMIX|AUDIO_DEVICE_IN_FM_TUNER) /** * A device mask for all audio input and output devices where matching inputs/outputs on device * type alone is not enough: the address must match too */ #define APM_AUDIO_DEVICE_MATCH_ADDRESS_ALL (AUDIO_DEVICE_IN_REMOTE_SUBMIX | \ AUDIO_DEVICE_OUT_REMOTE_SUBMIX) /** * Check if the state given correspond to an in call state. * @TODO find a better name for widely call state * * @param[in] state to consider * * @return true if given state represents a device in a telephony or VoIP call */ static inline bool is_state_in_call(int state) { return (state == AUDIO_MODE_IN_CALL) || (state == AUDIO_MODE_IN_COMMUNICATION); } /** * Check if the input device given is considered as a virtual device. * * @param[in] device to consider * * @return true if the device is a virtual one, false otherwise. */ static bool is_virtual_input_device(audio_devices_t device) { if ((device & AUDIO_DEVICE_BIT_IN) != 0) { device &= ~AUDIO_DEVICE_BIT_IN; if ((popcount(device) == 1) && ((device & ~APM_AUDIO_IN_DEVICE_VIRTUAL_ALL) == 0)) return true; } return false; } /** * Check whether the device type is one * where addresses are used to distinguish between one connected device and another * * @param[in] device to consider * * @return true if the device needs distinguish on address, false otherwise.. */ static bool device_distinguishes_on_address(audio_devices_t device) { return ((device & APM_AUDIO_DEVICE_MATCH_ADDRESS_ALL & ~AUDIO_DEVICE_BIT_IN) != 0); } services/audiopolicy/common/managerdefinitions/Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ LOCAL_SHARED_LIBRARIES := \ LOCAL_C_INCLUDES += \ $(LOCAL_PATH)/include \ $(TOPDIR)frameworks/av/services/audiopolicy/common/include \ LOCAL_EXPORT_C_INCLUDE_DIRS := \ $(LOCAL_PATH)/include Loading services/audiopolicy/common/managerdefinitions/include/AudioInputDescriptor.h +26 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #include <utils/Errors.h> #include <system/audio.h> #include <utils/SortedVector.h> #include <utils/KeyedVector.h> namespace android { Loading @@ -34,6 +35,8 @@ public: AudioInputDescriptor(const sp<IOProfile>& profile); void setIoHandle(audio_io_handle_t ioHandle); audio_module_handle_t getModuleHandle() const; status_t dump(int fd); audio_port_handle_t mId; Loading @@ -56,4 +59,27 @@ public: void toAudioPort(struct audio_port *port) const; }; class AudioInputCollection : public DefaultKeyedVector< audio_io_handle_t, sp<AudioInputDescriptor> > { public: bool isSourceActive(audio_source_t source) const; sp<AudioInputDescriptor> getInputFromId(audio_port_handle_t id) const; uint32_t activeInputsCount() const; /** * return io handle of active input or 0 if no input is active * Only considers inputs from physical devices (e.g. main mic, headset mic) when * ignoreVirtualInputs is true. */ audio_io_handle_t getActiveInput(bool ignoreVirtualInputs = true); audio_devices_t getSupportedDevices(audio_io_handle_t handle) const; status_t dump(int fd) const; }; }; // namespace android services/audiopolicy/common/managerdefinitions/include/AudioOutputDescriptor.h +37 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #include "ApmImplDefinitions.h" #include <utils/Errors.h> #include <utils/Timers.h> #include <utils/KeyedVector.h> #include <system/audio.h> namespace android { Loading Loading @@ -54,6 +55,8 @@ public: virtual sp<AudioPort> getAudioPort() const { return mProfile; } void toAudioPort(struct audio_port *port) const; audio_module_handle_t getModuleHandle() const; audio_port_handle_t mId; audio_io_handle_t mIoHandle; // output handle uint32_t mLatency; // Loading @@ -73,4 +76,38 @@ public: uint32_t mDirectOpenCount; // number of clients using this output (direct outputs only) }; class AudioOutputCollection : public DefaultKeyedVector< audio_io_handle_t, sp<AudioOutputDescriptor> > { public: bool isStreamActive(audio_stream_type_t stream, uint32_t inPastMs = 0) const; /** * return whether a stream is playing remotely, override to change the definition of * local/remote playback, used for instance by notification manager to not make * media players lose audio focus when not playing locally * For the base implementation, "remotely" means playing during screen mirroring which * uses an output for playback with a non-empty, non "0" address. */ bool isStreamActiveRemotely(audio_stream_type_t stream, uint32_t inPastMs = 0) const; /** * returns the A2DP output handle if it is open or 0 otherwise */ audio_io_handle_t getA2dpOutput() const; sp<AudioOutputDescriptor> getOutputFromId(audio_port_handle_t id) const; sp<AudioOutputDescriptor> getPrimaryOutput() const; /** * return true if any output is playing anything besides the stream to ignore */ bool isAnyOutputActive(audio_stream_type_t streamToIgnore) const; audio_devices_t getSupportedDevices(audio_io_handle_t handle) const; status_t dump(int fd) const; }; }; // namespace android Loading
services/audiopolicy/Android.mk +8 −2 Original line number Diff line number Diff line Loading @@ -16,13 +16,13 @@ else LOCAL_SRC_FILES += \ service/AudioPolicyInterfaceImpl.cpp \ service/AudioPolicyClientImpl.cpp endif LOCAL_C_INCLUDES := \ $(TOPDIR)frameworks/av/services/audioflinger \ $(call include-path-for, audio-effects) \ $(call include-path-for, audio-utils) $(call include-path-for, audio-utils) \ $(TOPDIR)frameworks/av/services/audiopolicy/common/include LOCAL_SHARED_LIBRARIES := \ libcutils \ Loading Loading @@ -63,6 +63,9 @@ LOCAL_SHARED_LIBRARIES := \ liblog \ libsoundtrigger LOCAL_C_INCLUDES += \ $(TOPDIR)frameworks/av/services/audiopolicy/common/include \ LOCAL_STATIC_LIBRARIES := \ libmedia_helper \ libaudiopolicycomponents Loading @@ -84,6 +87,9 @@ LOCAL_SHARED_LIBRARIES := \ LOCAL_STATIC_LIBRARIES := \ libaudiopolicycomponents LOCAL_C_INCLUDES += \ $(TOPDIR)frameworks/av/services/audiopolicy/common/include \ LOCAL_MODULE:= libaudiopolicymanager include $(BUILD_SHARED_LIBRARY) Loading
services/audiopolicy/common/include/policy.h 0 → 100755 +84 −0 Original line number Diff line number Diff line /* * Copyright (C) 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include <system/audio.h> // For mixed output and inputs, the policy will use max mixer sampling rates. // Do not limit sampling rate otherwise #define MAX_MIXER_SAMPLING_RATE 48000 // For mixed output and inputs, the policy will use max mixer channel count. // Do not limit channel count otherwise #define MAX_MIXER_CHANNEL_COUNT 8 /** * A device mask for all audio input devices that are considered "virtual" when evaluating * active inputs in getActiveInput() */ #define APM_AUDIO_IN_DEVICE_VIRTUAL_ALL (AUDIO_DEVICE_IN_REMOTE_SUBMIX|AUDIO_DEVICE_IN_FM_TUNER) /** * A device mask for all audio input and output devices where matching inputs/outputs on device * type alone is not enough: the address must match too */ #define APM_AUDIO_DEVICE_MATCH_ADDRESS_ALL (AUDIO_DEVICE_IN_REMOTE_SUBMIX | \ AUDIO_DEVICE_OUT_REMOTE_SUBMIX) /** * Check if the state given correspond to an in call state. * @TODO find a better name for widely call state * * @param[in] state to consider * * @return true if given state represents a device in a telephony or VoIP call */ static inline bool is_state_in_call(int state) { return (state == AUDIO_MODE_IN_CALL) || (state == AUDIO_MODE_IN_COMMUNICATION); } /** * Check if the input device given is considered as a virtual device. * * @param[in] device to consider * * @return true if the device is a virtual one, false otherwise. */ static bool is_virtual_input_device(audio_devices_t device) { if ((device & AUDIO_DEVICE_BIT_IN) != 0) { device &= ~AUDIO_DEVICE_BIT_IN; if ((popcount(device) == 1) && ((device & ~APM_AUDIO_IN_DEVICE_VIRTUAL_ALL) == 0)) return true; } return false; } /** * Check whether the device type is one * where addresses are used to distinguish between one connected device and another * * @param[in] device to consider * * @return true if the device needs distinguish on address, false otherwise.. */ static bool device_distinguishes_on_address(audio_devices_t device) { return ((device & APM_AUDIO_DEVICE_MATCH_ADDRESS_ALL & ~AUDIO_DEVICE_BIT_IN) != 0); }
services/audiopolicy/common/managerdefinitions/Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ LOCAL_SHARED_LIBRARIES := \ LOCAL_C_INCLUDES += \ $(LOCAL_PATH)/include \ $(TOPDIR)frameworks/av/services/audiopolicy/common/include \ LOCAL_EXPORT_C_INCLUDE_DIRS := \ $(LOCAL_PATH)/include Loading
services/audiopolicy/common/managerdefinitions/include/AudioInputDescriptor.h +26 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #include <utils/Errors.h> #include <system/audio.h> #include <utils/SortedVector.h> #include <utils/KeyedVector.h> namespace android { Loading @@ -34,6 +35,8 @@ public: AudioInputDescriptor(const sp<IOProfile>& profile); void setIoHandle(audio_io_handle_t ioHandle); audio_module_handle_t getModuleHandle() const; status_t dump(int fd); audio_port_handle_t mId; Loading @@ -56,4 +59,27 @@ public: void toAudioPort(struct audio_port *port) const; }; class AudioInputCollection : public DefaultKeyedVector< audio_io_handle_t, sp<AudioInputDescriptor> > { public: bool isSourceActive(audio_source_t source) const; sp<AudioInputDescriptor> getInputFromId(audio_port_handle_t id) const; uint32_t activeInputsCount() const; /** * return io handle of active input or 0 if no input is active * Only considers inputs from physical devices (e.g. main mic, headset mic) when * ignoreVirtualInputs is true. */ audio_io_handle_t getActiveInput(bool ignoreVirtualInputs = true); audio_devices_t getSupportedDevices(audio_io_handle_t handle) const; status_t dump(int fd) const; }; }; // namespace android
services/audiopolicy/common/managerdefinitions/include/AudioOutputDescriptor.h +37 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #include "ApmImplDefinitions.h" #include <utils/Errors.h> #include <utils/Timers.h> #include <utils/KeyedVector.h> #include <system/audio.h> namespace android { Loading Loading @@ -54,6 +55,8 @@ public: virtual sp<AudioPort> getAudioPort() const { return mProfile; } void toAudioPort(struct audio_port *port) const; audio_module_handle_t getModuleHandle() const; audio_port_handle_t mId; audio_io_handle_t mIoHandle; // output handle uint32_t mLatency; // Loading @@ -73,4 +76,38 @@ public: uint32_t mDirectOpenCount; // number of clients using this output (direct outputs only) }; class AudioOutputCollection : public DefaultKeyedVector< audio_io_handle_t, sp<AudioOutputDescriptor> > { public: bool isStreamActive(audio_stream_type_t stream, uint32_t inPastMs = 0) const; /** * return whether a stream is playing remotely, override to change the definition of * local/remote playback, used for instance by notification manager to not make * media players lose audio focus when not playing locally * For the base implementation, "remotely" means playing during screen mirroring which * uses an output for playback with a non-empty, non "0" address. */ bool isStreamActiveRemotely(audio_stream_type_t stream, uint32_t inPastMs = 0) const; /** * returns the A2DP output handle if it is open or 0 otherwise */ audio_io_handle_t getA2dpOutput() const; sp<AudioOutputDescriptor> getOutputFromId(audio_port_handle_t id) const; sp<AudioOutputDescriptor> getPrimaryOutput() const; /** * return true if any output is playing anything besides the stream to ignore */ bool isAnyOutputActive(audio_stream_type_t streamToIgnore) const; audio_devices_t getSupportedDevices(audio_io_handle_t handle) const; status_t dump(int fd) const; }; }; // namespace android