Loading services/audiopolicy/AudioPolicyInterface.h +24 −28 Original line number Diff line number Diff line Loading @@ -18,16 +18,11 @@ #define ANDROID_AUDIOPOLICYINTERFACE_H #include <media/AudioSystem.h> #include <media/ToneGenerator.h> #include <utils/String8.h> #include <hardware_legacy/AudioSystemLegacy.h> #include <hardware/audio_policy.h> namespace android_audio_legacy { using android::Vector; using android::String8; using android::ToneGenerator; namespace android { // ---------------------------------------------------------------------------- Loading Loading @@ -68,17 +63,17 @@ public: // indicate a change in device connection status virtual status_t setDeviceConnectionState(audio_devices_t device, AudioSystem::device_connection_state state, audio_policy_dev_state_t state, const char *device_address) = 0; // retrieve a device connection status virtual AudioSystem::device_connection_state getDeviceConnectionState(audio_devices_t device, virtual audio_policy_dev_state_t getDeviceConnectionState(audio_devices_t device, const char *device_address) = 0; // indicate a change in phone state. Valid phones states are defined by AudioSystem::audio_mode virtual void setPhoneState(int state) = 0; // indicate a change in phone state. Valid phones states are defined by audio_mode_t virtual void setPhoneState(audio_mode_t state) = 0; // force using a specific device category for the specified usage virtual void setForceUse(AudioSystem::force_use usage, AudioSystem::forced_config config) = 0; virtual void setForceUse(audio_policy_force_use_t usage, audio_policy_forced_cfg_t config) = 0; // retrieve current device category forced for a given usage virtual AudioSystem::forced_config getForceUse(AudioSystem::force_use usage) = 0; virtual audio_policy_forced_cfg_t getForceUse(audio_policy_force_use_t usage) = 0; // set a system property (e.g. camera sound always audible) virtual void setSystemProperty(const char* property, const char* value) = 0; // check proper initialization Loading @@ -89,29 +84,29 @@ public: // // request an output appropriate for playback of the supplied stream type and parameters virtual audio_io_handle_t getOutput(AudioSystem::stream_type stream, virtual audio_io_handle_t getOutput(audio_stream_type_t stream, uint32_t samplingRate, audio_format_t format, audio_channel_mask_t channelMask, AudioSystem::output_flags flags, audio_output_flags_t flags, const audio_offload_info_t *offloadInfo) = 0; // indicates to the audio policy manager that the output starts being used by corresponding stream. virtual status_t startOutput(audio_io_handle_t output, AudioSystem::stream_type stream, audio_stream_type_t stream, int session = 0) = 0; // indicates to the audio policy manager that the output stops being used by corresponding stream. virtual status_t stopOutput(audio_io_handle_t output, AudioSystem::stream_type stream, audio_stream_type_t stream, int session = 0) = 0; // releases the output. virtual void releaseOutput(audio_io_handle_t output) = 0; // request an input appropriate for record from the supplied device with supplied parameters. virtual audio_io_handle_t getInput(int inputSource, virtual audio_io_handle_t getInput(audio_source_t inputSource, uint32_t samplingRate, audio_format_t format, audio_channel_mask_t channelMask, AudioSystem::audio_in_acoustics acoustics) = 0; audio_in_acoustics_t acoustics) = 0; // indicates to the audio policy manager that the input starts being used. virtual status_t startInput(audio_io_handle_t input) = 0; // indicates to the audio policy manager that the input stops being used. Loading @@ -124,29 +119,29 @@ public: // // initialises stream volume conversion parameters by specifying volume index range. virtual void initStreamVolume(AudioSystem::stream_type stream, virtual void initStreamVolume(audio_stream_type_t stream, int indexMin, int indexMax) = 0; // sets the new stream volume at a level corresponding to the supplied index for the // supplied device. By convention, specifying AUDIO_DEVICE_OUT_DEFAULT means // setting volume for all devices virtual status_t setStreamVolumeIndex(AudioSystem::stream_type stream, virtual status_t setStreamVolumeIndex(audio_stream_type_t stream, int index, audio_devices_t device) = 0; // retrieve current volume index for the specified stream and the // specified device. By convention, specifying AUDIO_DEVICE_OUT_DEFAULT means // querying the volume of the active device. virtual status_t getStreamVolumeIndex(AudioSystem::stream_type stream, virtual status_t getStreamVolumeIndex(audio_stream_type_t stream, int *index, audio_devices_t device) = 0; // return the strategy corresponding to a given stream type virtual uint32_t getStrategyForStream(AudioSystem::stream_type stream) = 0; virtual uint32_t getStrategyForStream(audio_stream_type_t stream) = 0; // return the enabled output devices for the given stream type virtual audio_devices_t getDevicesForStream(AudioSystem::stream_type stream) = 0; virtual audio_devices_t getDevicesForStream(audio_stream_type_t stream) = 0; // Audio effect management virtual audio_io_handle_t getOutputForEffect(const effect_descriptor_t *desc) = 0; Loading @@ -158,8 +153,9 @@ public: virtual status_t unregisterEffect(int id) = 0; virtual status_t setEffectEnabled(int id, bool enabled) = 0; virtual bool isStreamActive(int stream, uint32_t inPastMs = 0) const = 0; virtual bool isStreamActiveRemotely(int stream, uint32_t inPastMs = 0) const = 0; virtual bool isStreamActive(audio_stream_type_t stream, uint32_t inPastMs = 0) const = 0; virtual bool isStreamActiveRemotely(audio_stream_type_t stream, uint32_t inPastMs = 0) const = 0; virtual bool isSourceActive(audio_source_t source) const = 0; //dump state Loading Loading @@ -227,10 +223,10 @@ public: // set a stream volume for a particular output. For the same user setting, a given stream type can have different volumes // for each output (destination device) it is attached to. virtual status_t setStreamVolume(AudioSystem::stream_type stream, float volume, audio_io_handle_t output, int delayMs = 0) = 0; virtual status_t setStreamVolume(audio_stream_type_t stream, float volume, audio_io_handle_t output, int delayMs = 0) = 0; // invalidate a stream type, causing a reroute to an unspecified new output virtual status_t invalidateStream(AudioSystem::stream_type stream) = 0; virtual status_t invalidateStream(audio_stream_type_t stream) = 0; // function enabling to send proprietary informations directly from audio policy manager to audio hardware interface. virtual void setParameters(audio_io_handle_t ioHandle, const String8& keyValuePairs, int delayMs = 0) = 0; Loading @@ -239,7 +235,7 @@ public: // request the playback of a tone on the specified stream: used for instance to replace notification sounds when playing // over a telephony device during a phone call. virtual status_t startTone(ToneGenerator::tone_type tone, AudioSystem::stream_type stream) = 0; virtual status_t startTone(audio_policy_tone_t tone, audio_stream_type_t stream) = 0; virtual status_t stopTone() = 0; // set down link audio volume. Loading services/audiopolicy/AudioPolicyManagerBase.cpp +187 −174 File changed.Preview size limit exceeded, changes collapsed. Show changes services/audiopolicy/AudioPolicyManagerBase.h +41 −41 Original line number Diff line number Diff line Loading @@ -23,13 +23,10 @@ #include <utils/Errors.h> #include <utils/KeyedVector.h> #include <utils/SortedVector.h> #include <hardware_legacy/AudioPolicyInterface.h> #include "AudioPolicyInterface.h" namespace android_audio_legacy { using android::KeyedVector; using android::DefaultKeyedVector; using android::SortedVector; namespace android { // ---------------------------------------------------------------------------- Loading Loading @@ -77,33 +74,34 @@ public: // AudioPolicyInterface virtual status_t setDeviceConnectionState(audio_devices_t device, AudioSystem::device_connection_state state, audio_policy_dev_state_t state, const char *device_address); virtual AudioSystem::device_connection_state getDeviceConnectionState(audio_devices_t device, virtual audio_policy_dev_state_t getDeviceConnectionState(audio_devices_t device, const char *device_address); virtual void setPhoneState(int state); virtual void setForceUse(AudioSystem::force_use usage, AudioSystem::forced_config config); virtual AudioSystem::forced_config getForceUse(AudioSystem::force_use usage); virtual void setPhoneState(audio_mode_t state); virtual void setForceUse(audio_policy_force_use_t usage, audio_policy_forced_cfg_t config); virtual audio_policy_forced_cfg_t getForceUse(audio_policy_force_use_t usage); virtual void setSystemProperty(const char* property, const char* value); virtual status_t initCheck(); virtual audio_io_handle_t getOutput(AudioSystem::stream_type stream, virtual audio_io_handle_t getOutput(audio_stream_type_t stream, uint32_t samplingRate, audio_format_t format, audio_channel_mask_t channelMask, AudioSystem::output_flags flags, audio_output_flags_t flags, const audio_offload_info_t *offloadInfo); virtual status_t startOutput(audio_io_handle_t output, AudioSystem::stream_type stream, audio_stream_type_t stream, int session = 0); virtual status_t stopOutput(audio_io_handle_t output, AudioSystem::stream_type stream, audio_stream_type_t stream, int session = 0); virtual void releaseOutput(audio_io_handle_t output); virtual audio_io_handle_t getInput(int inputSource, virtual audio_io_handle_t getInput(audio_source_t inputSource, uint32_t samplingRate, audio_format_t format, audio_channel_mask_t channelMask, AudioSystem::audio_in_acoustics acoustics); audio_in_acoustics_t acoustics); // indicates to the audio policy manager that the input starts being used. virtual status_t startInput(audio_io_handle_t input); Loading @@ -111,21 +109,21 @@ public: // indicates to the audio policy manager that the input stops being used. virtual status_t stopInput(audio_io_handle_t input); virtual void releaseInput(audio_io_handle_t input); virtual void initStreamVolume(AudioSystem::stream_type stream, virtual void initStreamVolume(audio_stream_type_t stream, int indexMin, int indexMax); virtual status_t setStreamVolumeIndex(AudioSystem::stream_type stream, virtual status_t setStreamVolumeIndex(audio_stream_type_t stream, int index, audio_devices_t device); virtual status_t getStreamVolumeIndex(AudioSystem::stream_type stream, virtual status_t getStreamVolumeIndex(audio_stream_type_t stream, int *index, audio_devices_t device); // return the strategy corresponding to a given stream type virtual uint32_t getStrategyForStream(AudioSystem::stream_type stream); virtual uint32_t getStrategyForStream(audio_stream_type_t stream); // return the enabled output devices for the given stream type virtual audio_devices_t getDevicesForStream(AudioSystem::stream_type stream); virtual audio_devices_t getDevicesForStream(audio_stream_type_t stream); virtual audio_io_handle_t getOutputForEffect(const effect_descriptor_t *desc = NULL); virtual status_t registerEffect(const effect_descriptor_t *desc, Loading @@ -136,11 +134,11 @@ public: virtual status_t unregisterEffect(int id); virtual status_t setEffectEnabled(int id, bool enabled); virtual bool isStreamActive(int stream, uint32_t inPastMs = 0) const; virtual 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 virtual bool isStreamActiveRemotely(int stream, uint32_t inPastMs = 0) const; virtual bool isStreamActiveRemotely(audio_stream_type_t stream, uint32_t inPastMs = 0) const; virtual bool isSourceActive(audio_source_t source) const; virtual status_t dump(int fd); Loading Loading @@ -254,14 +252,14 @@ protected: status_t dump(int fd); audio_devices_t device() const; void changeRefCount(AudioSystem::stream_type stream, int delta); void changeRefCount(audio_stream_type_t stream, int delta); bool isDuplicated() const { return (mOutput1 != NULL && mOutput2 != NULL); } audio_devices_t supportedDevices(); uint32_t latency(); bool sharesHwModuleWith(const AudioOutputDescriptor *outputDesc); bool isActive(uint32_t inPastMs = 0) const; bool isStreamActive(AudioSystem::stream_type stream, bool isStreamActive(audio_stream_type_t stream, uint32_t inPastMs = 0, nsecs_t sysTime = 0) const; bool isStrategyActive(routing_strategy strategy, Loading @@ -275,12 +273,12 @@ protected: uint32_t mLatency; // audio_output_flags_t mFlags; // audio_devices_t mDevice; // current device this output is routed to uint32_t mRefCount[AudioSystem::NUM_STREAM_TYPES]; // number of streams of each type using this output nsecs_t mStopTime[AudioSystem::NUM_STREAM_TYPES]; uint32_t mRefCount[AUDIO_STREAM_CNT]; // number of streams of each type using this output nsecs_t mStopTime[AUDIO_STREAM_CNT]; AudioOutputDescriptor *mOutput1; // used by duplicated outputs: first output AudioOutputDescriptor *mOutput2; // used by duplicated outputs: second output float mCurVolume[AudioSystem::NUM_STREAM_TYPES]; // current stream volume int mMuteCount[AudioSystem::NUM_STREAM_TYPES]; // mute request counter float mCurVolume[AUDIO_STREAM_CNT]; // current stream volume int mMuteCount[AUDIO_STREAM_CNT]; // mute request counter const IOProfile *mProfile; // I/O profile this output derives from bool mStrategyMutedByDevice[NUM_STRATEGIES]; // strategies muted because of incompatible // device selection. See checkDeviceMuteStrategies() Loading @@ -301,7 +299,7 @@ protected: audio_channel_mask_t mChannelMask; // audio_devices_t mDevice; // current device this input is routed to uint32_t mRefCount; // number of AudioRecord clients using this output int mInputSource; // input source selected by application (mediarecorder.h) audio_source_t mInputSource; // input source selected by application (mediarecorder.h) const IOProfile *mProfile; // I/O profile this output derives from }; Loading Loading @@ -339,7 +337,7 @@ protected: void addOutput(audio_io_handle_t id, AudioOutputDescriptor *outputDesc); // return the strategy corresponding to a given stream type static routing_strategy getStrategy(AudioSystem::stream_type stream); static routing_strategy getStrategy(audio_stream_type_t stream); // return appropriate device for streams handled by the specified strategy according to current // phone state, connected devices... Loading @@ -363,7 +361,7 @@ protected: int delayMs = 0); // select input device corresponding to requested audio source virtual audio_devices_t getDeviceForInputSource(int inputSource); virtual audio_devices_t getDeviceForInputSource(audio_source_t inputSource); // 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 Loading @@ -375,10 +373,12 @@ protected: // compute the actual volume for a given stream according to the requested index and a particular // device virtual float computeVolume(int stream, int index, audio_io_handle_t output, audio_devices_t device); virtual float computeVolume(audio_stream_type_t stream, int index, audio_io_handle_t output, audio_devices_t device); // check that volume change is permitted, compute and send new volume to audio hardware status_t checkAndSetVolume(int stream, int index, audio_io_handle_t output, audio_devices_t device, int delayMs = 0, bool force = false); status_t checkAndSetVolume(audio_stream_type_t stream, int index, audio_io_handle_t output, audio_devices_t device, int delayMs = 0, bool force = false); // apply all stream volumes to the specified output and device void applyStreamVolumes(audio_io_handle_t output, audio_devices_t device, int delayMs = 0, bool force = false); Loading @@ -391,7 +391,7 @@ protected: audio_devices_t device = (audio_devices_t)0); // Mute or unmute the stream on the specified output void setStreamMute(int stream, void setStreamMute(audio_stream_type_t stream, bool on, audio_io_handle_t output, int delayMs = 0, Loading @@ -399,7 +399,7 @@ protected: // handle special cases for sonification strategy while in call: mute streams or replace by // a special tone in the device used for communication void handleIncallSonification(int stream, bool starting, bool stateChange); void handleIncallSonification(audio_stream_type_t stream, bool starting, bool stateChange); // true if device is in a telephony or VoIP call virtual bool isInCall(); Loading @@ -414,7 +414,7 @@ protected: // returns its handle if any. // transfers the audio tracks and effects from one output thread to another accordingly. status_t checkOutputsForDevice(audio_devices_t device, AudioSystem::device_connection_state state, audio_policy_dev_state_t state, SortedVector<audio_io_handle_t>& outputs, const String8 paramStr); Loading Loading @@ -480,7 +480,7 @@ protected: uint32_t delayMs); audio_io_handle_t selectOutput(const SortedVector<audio_io_handle_t>& outputs, AudioSystem::output_flags flags); audio_output_flags_t flags); IOProfile *getInputProfile(audio_devices_t device, uint32_t samplingRate, audio_format_t format, Loading Loading @@ -530,9 +530,9 @@ protected: // without AUDIO_DEVICE_BIT_IN to allow direct bit // field comparisons int mPhoneState; // current phone state AudioSystem::forced_config mForceUse[AudioSystem::NUM_FORCE_USE]; // current forced use configuration audio_policy_forced_cfg_t mForceUse[AUDIO_POLICY_FORCE_USE_CNT]; // current forced use configuration StreamDescriptor mStreams[AudioSystem::NUM_STREAM_TYPES]; // stream descriptors for volume control StreamDescriptor mStreams[AUDIO_STREAM_CNT]; // stream descriptors for volume control String8 mA2dpDeviceAddress; // A2DP device MAC address String8 mScoDeviceAddress; // SCO device MAC address String8 mUsbCardAndDevice; // USB audio ALSA card and device numbers: Loading Loading @@ -580,7 +580,7 @@ private: int indexInUi); // updates device caching and output for streams that can influence the // routing of notifications void handleNotificationRoutingForStream(AudioSystem::stream_type stream); void handleNotificationRoutingForStream(audio_stream_type_t stream); static bool isVirtualInputDevice(audio_devices_t device); }; Loading Loading
services/audiopolicy/AudioPolicyInterface.h +24 −28 Original line number Diff line number Diff line Loading @@ -18,16 +18,11 @@ #define ANDROID_AUDIOPOLICYINTERFACE_H #include <media/AudioSystem.h> #include <media/ToneGenerator.h> #include <utils/String8.h> #include <hardware_legacy/AudioSystemLegacy.h> #include <hardware/audio_policy.h> namespace android_audio_legacy { using android::Vector; using android::String8; using android::ToneGenerator; namespace android { // ---------------------------------------------------------------------------- Loading Loading @@ -68,17 +63,17 @@ public: // indicate a change in device connection status virtual status_t setDeviceConnectionState(audio_devices_t device, AudioSystem::device_connection_state state, audio_policy_dev_state_t state, const char *device_address) = 0; // retrieve a device connection status virtual AudioSystem::device_connection_state getDeviceConnectionState(audio_devices_t device, virtual audio_policy_dev_state_t getDeviceConnectionState(audio_devices_t device, const char *device_address) = 0; // indicate a change in phone state. Valid phones states are defined by AudioSystem::audio_mode virtual void setPhoneState(int state) = 0; // indicate a change in phone state. Valid phones states are defined by audio_mode_t virtual void setPhoneState(audio_mode_t state) = 0; // force using a specific device category for the specified usage virtual void setForceUse(AudioSystem::force_use usage, AudioSystem::forced_config config) = 0; virtual void setForceUse(audio_policy_force_use_t usage, audio_policy_forced_cfg_t config) = 0; // retrieve current device category forced for a given usage virtual AudioSystem::forced_config getForceUse(AudioSystem::force_use usage) = 0; virtual audio_policy_forced_cfg_t getForceUse(audio_policy_force_use_t usage) = 0; // set a system property (e.g. camera sound always audible) virtual void setSystemProperty(const char* property, const char* value) = 0; // check proper initialization Loading @@ -89,29 +84,29 @@ public: // // request an output appropriate for playback of the supplied stream type and parameters virtual audio_io_handle_t getOutput(AudioSystem::stream_type stream, virtual audio_io_handle_t getOutput(audio_stream_type_t stream, uint32_t samplingRate, audio_format_t format, audio_channel_mask_t channelMask, AudioSystem::output_flags flags, audio_output_flags_t flags, const audio_offload_info_t *offloadInfo) = 0; // indicates to the audio policy manager that the output starts being used by corresponding stream. virtual status_t startOutput(audio_io_handle_t output, AudioSystem::stream_type stream, audio_stream_type_t stream, int session = 0) = 0; // indicates to the audio policy manager that the output stops being used by corresponding stream. virtual status_t stopOutput(audio_io_handle_t output, AudioSystem::stream_type stream, audio_stream_type_t stream, int session = 0) = 0; // releases the output. virtual void releaseOutput(audio_io_handle_t output) = 0; // request an input appropriate for record from the supplied device with supplied parameters. virtual audio_io_handle_t getInput(int inputSource, virtual audio_io_handle_t getInput(audio_source_t inputSource, uint32_t samplingRate, audio_format_t format, audio_channel_mask_t channelMask, AudioSystem::audio_in_acoustics acoustics) = 0; audio_in_acoustics_t acoustics) = 0; // indicates to the audio policy manager that the input starts being used. virtual status_t startInput(audio_io_handle_t input) = 0; // indicates to the audio policy manager that the input stops being used. Loading @@ -124,29 +119,29 @@ public: // // initialises stream volume conversion parameters by specifying volume index range. virtual void initStreamVolume(AudioSystem::stream_type stream, virtual void initStreamVolume(audio_stream_type_t stream, int indexMin, int indexMax) = 0; // sets the new stream volume at a level corresponding to the supplied index for the // supplied device. By convention, specifying AUDIO_DEVICE_OUT_DEFAULT means // setting volume for all devices virtual status_t setStreamVolumeIndex(AudioSystem::stream_type stream, virtual status_t setStreamVolumeIndex(audio_stream_type_t stream, int index, audio_devices_t device) = 0; // retrieve current volume index for the specified stream and the // specified device. By convention, specifying AUDIO_DEVICE_OUT_DEFAULT means // querying the volume of the active device. virtual status_t getStreamVolumeIndex(AudioSystem::stream_type stream, virtual status_t getStreamVolumeIndex(audio_stream_type_t stream, int *index, audio_devices_t device) = 0; // return the strategy corresponding to a given stream type virtual uint32_t getStrategyForStream(AudioSystem::stream_type stream) = 0; virtual uint32_t getStrategyForStream(audio_stream_type_t stream) = 0; // return the enabled output devices for the given stream type virtual audio_devices_t getDevicesForStream(AudioSystem::stream_type stream) = 0; virtual audio_devices_t getDevicesForStream(audio_stream_type_t stream) = 0; // Audio effect management virtual audio_io_handle_t getOutputForEffect(const effect_descriptor_t *desc) = 0; Loading @@ -158,8 +153,9 @@ public: virtual status_t unregisterEffect(int id) = 0; virtual status_t setEffectEnabled(int id, bool enabled) = 0; virtual bool isStreamActive(int stream, uint32_t inPastMs = 0) const = 0; virtual bool isStreamActiveRemotely(int stream, uint32_t inPastMs = 0) const = 0; virtual bool isStreamActive(audio_stream_type_t stream, uint32_t inPastMs = 0) const = 0; virtual bool isStreamActiveRemotely(audio_stream_type_t stream, uint32_t inPastMs = 0) const = 0; virtual bool isSourceActive(audio_source_t source) const = 0; //dump state Loading Loading @@ -227,10 +223,10 @@ public: // set a stream volume for a particular output. For the same user setting, a given stream type can have different volumes // for each output (destination device) it is attached to. virtual status_t setStreamVolume(AudioSystem::stream_type stream, float volume, audio_io_handle_t output, int delayMs = 0) = 0; virtual status_t setStreamVolume(audio_stream_type_t stream, float volume, audio_io_handle_t output, int delayMs = 0) = 0; // invalidate a stream type, causing a reroute to an unspecified new output virtual status_t invalidateStream(AudioSystem::stream_type stream) = 0; virtual status_t invalidateStream(audio_stream_type_t stream) = 0; // function enabling to send proprietary informations directly from audio policy manager to audio hardware interface. virtual void setParameters(audio_io_handle_t ioHandle, const String8& keyValuePairs, int delayMs = 0) = 0; Loading @@ -239,7 +235,7 @@ public: // request the playback of a tone on the specified stream: used for instance to replace notification sounds when playing // over a telephony device during a phone call. virtual status_t startTone(ToneGenerator::tone_type tone, AudioSystem::stream_type stream) = 0; virtual status_t startTone(audio_policy_tone_t tone, audio_stream_type_t stream) = 0; virtual status_t stopTone() = 0; // set down link audio volume. Loading
services/audiopolicy/AudioPolicyManagerBase.cpp +187 −174 File changed.Preview size limit exceeded, changes collapsed. Show changes
services/audiopolicy/AudioPolicyManagerBase.h +41 −41 Original line number Diff line number Diff line Loading @@ -23,13 +23,10 @@ #include <utils/Errors.h> #include <utils/KeyedVector.h> #include <utils/SortedVector.h> #include <hardware_legacy/AudioPolicyInterface.h> #include "AudioPolicyInterface.h" namespace android_audio_legacy { using android::KeyedVector; using android::DefaultKeyedVector; using android::SortedVector; namespace android { // ---------------------------------------------------------------------------- Loading Loading @@ -77,33 +74,34 @@ public: // AudioPolicyInterface virtual status_t setDeviceConnectionState(audio_devices_t device, AudioSystem::device_connection_state state, audio_policy_dev_state_t state, const char *device_address); virtual AudioSystem::device_connection_state getDeviceConnectionState(audio_devices_t device, virtual audio_policy_dev_state_t getDeviceConnectionState(audio_devices_t device, const char *device_address); virtual void setPhoneState(int state); virtual void setForceUse(AudioSystem::force_use usage, AudioSystem::forced_config config); virtual AudioSystem::forced_config getForceUse(AudioSystem::force_use usage); virtual void setPhoneState(audio_mode_t state); virtual void setForceUse(audio_policy_force_use_t usage, audio_policy_forced_cfg_t config); virtual audio_policy_forced_cfg_t getForceUse(audio_policy_force_use_t usage); virtual void setSystemProperty(const char* property, const char* value); virtual status_t initCheck(); virtual audio_io_handle_t getOutput(AudioSystem::stream_type stream, virtual audio_io_handle_t getOutput(audio_stream_type_t stream, uint32_t samplingRate, audio_format_t format, audio_channel_mask_t channelMask, AudioSystem::output_flags flags, audio_output_flags_t flags, const audio_offload_info_t *offloadInfo); virtual status_t startOutput(audio_io_handle_t output, AudioSystem::stream_type stream, audio_stream_type_t stream, int session = 0); virtual status_t stopOutput(audio_io_handle_t output, AudioSystem::stream_type stream, audio_stream_type_t stream, int session = 0); virtual void releaseOutput(audio_io_handle_t output); virtual audio_io_handle_t getInput(int inputSource, virtual audio_io_handle_t getInput(audio_source_t inputSource, uint32_t samplingRate, audio_format_t format, audio_channel_mask_t channelMask, AudioSystem::audio_in_acoustics acoustics); audio_in_acoustics_t acoustics); // indicates to the audio policy manager that the input starts being used. virtual status_t startInput(audio_io_handle_t input); Loading @@ -111,21 +109,21 @@ public: // indicates to the audio policy manager that the input stops being used. virtual status_t stopInput(audio_io_handle_t input); virtual void releaseInput(audio_io_handle_t input); virtual void initStreamVolume(AudioSystem::stream_type stream, virtual void initStreamVolume(audio_stream_type_t stream, int indexMin, int indexMax); virtual status_t setStreamVolumeIndex(AudioSystem::stream_type stream, virtual status_t setStreamVolumeIndex(audio_stream_type_t stream, int index, audio_devices_t device); virtual status_t getStreamVolumeIndex(AudioSystem::stream_type stream, virtual status_t getStreamVolumeIndex(audio_stream_type_t stream, int *index, audio_devices_t device); // return the strategy corresponding to a given stream type virtual uint32_t getStrategyForStream(AudioSystem::stream_type stream); virtual uint32_t getStrategyForStream(audio_stream_type_t stream); // return the enabled output devices for the given stream type virtual audio_devices_t getDevicesForStream(AudioSystem::stream_type stream); virtual audio_devices_t getDevicesForStream(audio_stream_type_t stream); virtual audio_io_handle_t getOutputForEffect(const effect_descriptor_t *desc = NULL); virtual status_t registerEffect(const effect_descriptor_t *desc, Loading @@ -136,11 +134,11 @@ public: virtual status_t unregisterEffect(int id); virtual status_t setEffectEnabled(int id, bool enabled); virtual bool isStreamActive(int stream, uint32_t inPastMs = 0) const; virtual 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 virtual bool isStreamActiveRemotely(int stream, uint32_t inPastMs = 0) const; virtual bool isStreamActiveRemotely(audio_stream_type_t stream, uint32_t inPastMs = 0) const; virtual bool isSourceActive(audio_source_t source) const; virtual status_t dump(int fd); Loading Loading @@ -254,14 +252,14 @@ protected: status_t dump(int fd); audio_devices_t device() const; void changeRefCount(AudioSystem::stream_type stream, int delta); void changeRefCount(audio_stream_type_t stream, int delta); bool isDuplicated() const { return (mOutput1 != NULL && mOutput2 != NULL); } audio_devices_t supportedDevices(); uint32_t latency(); bool sharesHwModuleWith(const AudioOutputDescriptor *outputDesc); bool isActive(uint32_t inPastMs = 0) const; bool isStreamActive(AudioSystem::stream_type stream, bool isStreamActive(audio_stream_type_t stream, uint32_t inPastMs = 0, nsecs_t sysTime = 0) const; bool isStrategyActive(routing_strategy strategy, Loading @@ -275,12 +273,12 @@ protected: uint32_t mLatency; // audio_output_flags_t mFlags; // audio_devices_t mDevice; // current device this output is routed to uint32_t mRefCount[AudioSystem::NUM_STREAM_TYPES]; // number of streams of each type using this output nsecs_t mStopTime[AudioSystem::NUM_STREAM_TYPES]; uint32_t mRefCount[AUDIO_STREAM_CNT]; // number of streams of each type using this output nsecs_t mStopTime[AUDIO_STREAM_CNT]; AudioOutputDescriptor *mOutput1; // used by duplicated outputs: first output AudioOutputDescriptor *mOutput2; // used by duplicated outputs: second output float mCurVolume[AudioSystem::NUM_STREAM_TYPES]; // current stream volume int mMuteCount[AudioSystem::NUM_STREAM_TYPES]; // mute request counter float mCurVolume[AUDIO_STREAM_CNT]; // current stream volume int mMuteCount[AUDIO_STREAM_CNT]; // mute request counter const IOProfile *mProfile; // I/O profile this output derives from bool mStrategyMutedByDevice[NUM_STRATEGIES]; // strategies muted because of incompatible // device selection. See checkDeviceMuteStrategies() Loading @@ -301,7 +299,7 @@ protected: audio_channel_mask_t mChannelMask; // audio_devices_t mDevice; // current device this input is routed to uint32_t mRefCount; // number of AudioRecord clients using this output int mInputSource; // input source selected by application (mediarecorder.h) audio_source_t mInputSource; // input source selected by application (mediarecorder.h) const IOProfile *mProfile; // I/O profile this output derives from }; Loading Loading @@ -339,7 +337,7 @@ protected: void addOutput(audio_io_handle_t id, AudioOutputDescriptor *outputDesc); // return the strategy corresponding to a given stream type static routing_strategy getStrategy(AudioSystem::stream_type stream); static routing_strategy getStrategy(audio_stream_type_t stream); // return appropriate device for streams handled by the specified strategy according to current // phone state, connected devices... Loading @@ -363,7 +361,7 @@ protected: int delayMs = 0); // select input device corresponding to requested audio source virtual audio_devices_t getDeviceForInputSource(int inputSource); virtual audio_devices_t getDeviceForInputSource(audio_source_t inputSource); // 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 Loading @@ -375,10 +373,12 @@ protected: // compute the actual volume for a given stream according to the requested index and a particular // device virtual float computeVolume(int stream, int index, audio_io_handle_t output, audio_devices_t device); virtual float computeVolume(audio_stream_type_t stream, int index, audio_io_handle_t output, audio_devices_t device); // check that volume change is permitted, compute and send new volume to audio hardware status_t checkAndSetVolume(int stream, int index, audio_io_handle_t output, audio_devices_t device, int delayMs = 0, bool force = false); status_t checkAndSetVolume(audio_stream_type_t stream, int index, audio_io_handle_t output, audio_devices_t device, int delayMs = 0, bool force = false); // apply all stream volumes to the specified output and device void applyStreamVolumes(audio_io_handle_t output, audio_devices_t device, int delayMs = 0, bool force = false); Loading @@ -391,7 +391,7 @@ protected: audio_devices_t device = (audio_devices_t)0); // Mute or unmute the stream on the specified output void setStreamMute(int stream, void setStreamMute(audio_stream_type_t stream, bool on, audio_io_handle_t output, int delayMs = 0, Loading @@ -399,7 +399,7 @@ protected: // handle special cases for sonification strategy while in call: mute streams or replace by // a special tone in the device used for communication void handleIncallSonification(int stream, bool starting, bool stateChange); void handleIncallSonification(audio_stream_type_t stream, bool starting, bool stateChange); // true if device is in a telephony or VoIP call virtual bool isInCall(); Loading @@ -414,7 +414,7 @@ protected: // returns its handle if any. // transfers the audio tracks and effects from one output thread to another accordingly. status_t checkOutputsForDevice(audio_devices_t device, AudioSystem::device_connection_state state, audio_policy_dev_state_t state, SortedVector<audio_io_handle_t>& outputs, const String8 paramStr); Loading Loading @@ -480,7 +480,7 @@ protected: uint32_t delayMs); audio_io_handle_t selectOutput(const SortedVector<audio_io_handle_t>& outputs, AudioSystem::output_flags flags); audio_output_flags_t flags); IOProfile *getInputProfile(audio_devices_t device, uint32_t samplingRate, audio_format_t format, Loading Loading @@ -530,9 +530,9 @@ protected: // without AUDIO_DEVICE_BIT_IN to allow direct bit // field comparisons int mPhoneState; // current phone state AudioSystem::forced_config mForceUse[AudioSystem::NUM_FORCE_USE]; // current forced use configuration audio_policy_forced_cfg_t mForceUse[AUDIO_POLICY_FORCE_USE_CNT]; // current forced use configuration StreamDescriptor mStreams[AudioSystem::NUM_STREAM_TYPES]; // stream descriptors for volume control StreamDescriptor mStreams[AUDIO_STREAM_CNT]; // stream descriptors for volume control String8 mA2dpDeviceAddress; // A2DP device MAC address String8 mScoDeviceAddress; // SCO device MAC address String8 mUsbCardAndDevice; // USB audio ALSA card and device numbers: Loading Loading @@ -580,7 +580,7 @@ private: int indexInUi); // updates device caching and output for streams that can influence the // routing of notifications void handleNotificationRoutingForStream(AudioSystem::stream_type stream); void handleNotificationRoutingForStream(audio_stream_type_t stream); static bool isVirtualInputDevice(audio_devices_t device); }; Loading