Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef ANDROID_IAUDIOPOLICYSERVICE_H |
| 18 | #define ANDROID_IAUDIOPOLICYSERVICE_H |
| 19 | |
| 20 | #include <stdint.h> |
| 21 | #include <sys/types.h> |
| 22 | #include <unistd.h> |
| 23 | |
| 24 | #include <utils/RefBase.h> |
| 25 | #include <utils/Errors.h> |
| 26 | #include <binder/IInterface.h> |
| 27 | #include <media/AudioSystem.h> |
| 28 | |
Dima Zavin | 7394a4f | 2011-06-13 18:16:26 -0700 | [diff] [blame] | 29 | #include <system/audio_policy.h> |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 30 | |
| 31 | namespace android { |
| 32 | |
| 33 | // ---------------------------------------------------------------------------- |
| 34 | |
| 35 | class IAudioPolicyService : public IInterface |
| 36 | { |
| 37 | public: |
| 38 | DECLARE_META_INTERFACE(AudioPolicyService); |
| 39 | |
| 40 | // |
| 41 | // IAudioPolicyService interface (see AudioPolicyInterface for method descriptions) |
| 42 | // |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 43 | virtual status_t setDeviceConnectionState(audio_devices_t device, |
| 44 | audio_policy_dev_state_t state, |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 45 | const char *device_address) = 0; |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 46 | virtual audio_policy_dev_state_t getDeviceConnectionState(audio_devices_t device, |
Glenn Kasten | 85ab62c | 2012-11-01 11:11:38 -0700 | [diff] [blame] | 47 | const char *device_address) = 0; |
Glenn Kasten | f78aee7 | 2012-01-04 11:00:47 -0800 | [diff] [blame] | 48 | virtual status_t setPhoneState(audio_mode_t state) = 0; |
Glenn Kasten | 85ab62c | 2012-11-01 11:11:38 -0700 | [diff] [blame] | 49 | virtual status_t setForceUse(audio_policy_force_use_t usage, |
| 50 | audio_policy_forced_cfg_t config) = 0; |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 51 | virtual audio_policy_forced_cfg_t getForceUse(audio_policy_force_use_t usage) = 0; |
| 52 | virtual audio_io_handle_t getOutput(audio_stream_type_t stream, |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 53 | uint32_t samplingRate = 0, |
Glenn Kasten | 58f3021 | 2012-01-12 12:27:51 -0800 | [diff] [blame] | 54 | audio_format_t format = AUDIO_FORMAT_DEFAULT, |
Glenn Kasten | 254af18 | 2012-07-03 14:59:05 -0700 | [diff] [blame] | 55 | audio_channel_mask_t channelMask = 0, |
Richard Fitzgerald | ad3af33 | 2013-03-25 16:54:37 +0000 | [diff] [blame] | 56 | audio_output_flags_t flags = AUDIO_OUTPUT_FLAG_NONE, |
| 57 | const audio_offload_info_t *offloadInfo = NULL) = 0; |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 58 | virtual status_t startOutput(audio_io_handle_t output, |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 59 | audio_stream_type_t stream, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 60 | int session = 0) = 0; |
| 61 | virtual status_t stopOutput(audio_io_handle_t output, |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 62 | audio_stream_type_t stream, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 63 | int session = 0) = 0; |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 64 | virtual void releaseOutput(audio_io_handle_t output) = 0; |
Glenn Kasten | eba51fb | 2012-01-23 13:58:49 -0800 | [diff] [blame] | 65 | virtual audio_io_handle_t getInput(audio_source_t inputSource, |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 66 | uint32_t samplingRate = 0, |
Glenn Kasten | 58f3021 | 2012-01-12 12:27:51 -0800 | [diff] [blame] | 67 | audio_format_t format = AUDIO_FORMAT_DEFAULT, |
Glenn Kasten | 254af18 | 2012-07-03 14:59:05 -0700 | [diff] [blame] | 68 | audio_channel_mask_t channelMask = 0, |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 69 | int audioSession = 0) = 0; |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 70 | virtual status_t startInput(audio_io_handle_t input) = 0; |
| 71 | virtual status_t stopInput(audio_io_handle_t input) = 0; |
| 72 | virtual void releaseInput(audio_io_handle_t input) = 0; |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 73 | virtual status_t initStreamVolume(audio_stream_type_t stream, |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 74 | int indexMin, |
| 75 | int indexMax) = 0; |
Eric Laurent | 83844cc | 2011-11-18 16:43:31 -0800 | [diff] [blame] | 76 | virtual status_t setStreamVolumeIndex(audio_stream_type_t stream, |
| 77 | int index, |
| 78 | audio_devices_t device) = 0; |
| 79 | virtual status_t getStreamVolumeIndex(audio_stream_type_t stream, |
| 80 | int *index, |
| 81 | audio_devices_t device) = 0; |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 82 | virtual uint32_t getStrategyForStream(audio_stream_type_t stream) = 0; |
Eric Laurent | 6374252 | 2012-03-08 13:42:42 -0800 | [diff] [blame] | 83 | virtual audio_devices_t getDevicesForStream(audio_stream_type_t stream) = 0; |
Glenn Kasten | 58e5aa3 | 2012-06-20 14:08:14 -0700 | [diff] [blame] | 84 | virtual audio_io_handle_t getOutputForEffect(const effect_descriptor_t *desc) = 0; |
| 85 | virtual status_t registerEffect(const effect_descriptor_t *desc, |
Eric Laurent | 7c7f10b | 2011-06-17 21:29:58 -0700 | [diff] [blame] | 86 | audio_io_handle_t io, |
Eric Laurent | de07013 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 87 | uint32_t strategy, |
| 88 | int session, |
| 89 | int id) = 0; |
| 90 | virtual status_t unregisterEffect(int id) = 0; |
Eric Laurent | db7c079 | 2011-08-10 10:37:50 -0700 | [diff] [blame] | 91 | virtual status_t setEffectEnabled(int id, bool enabled) = 0; |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 92 | virtual bool isStreamActive(audio_stream_type_t stream, uint32_t inPastMs = 0) const = 0; |
Jean-Michel Trivi | 272ab54 | 2013-02-04 16:26:02 -0800 | [diff] [blame] | 93 | virtual bool isStreamActiveRemotely(audio_stream_type_t stream, uint32_t inPastMs = 0) |
| 94 | const = 0; |
Jean-Michel Trivi | d708603 | 2012-10-10 12:11:16 -0700 | [diff] [blame] | 95 | virtual bool isSourceActive(audio_source_t source) const = 0; |
Eric Laurent | 57dae99 | 2011-07-24 13:36:09 -0700 | [diff] [blame] | 96 | virtual status_t queryDefaultPreProcessing(int audioSession, |
| 97 | effect_descriptor_t *descriptors, |
| 98 | uint32_t *count) = 0; |
Richard Fitzgerald | ad3af33 | 2013-03-25 16:54:37 +0000 | [diff] [blame] | 99 | // Check if offload is possible for given format, stream type, sample rate, |
| 100 | // bit rate, duration, video and streaming or offload property is enabled |
| 101 | virtual bool isOffloadSupported(const audio_offload_info_t& info) = 0; |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 102 | }; |
| 103 | |
| 104 | |
| 105 | // ---------------------------------------------------------------------------- |
| 106 | |
| 107 | class BnAudioPolicyService : public BnInterface<IAudioPolicyService> |
| 108 | { |
| 109 | public: |
| 110 | virtual status_t onTransact( uint32_t code, |
| 111 | const Parcel& data, |
| 112 | Parcel* reply, |
| 113 | uint32_t flags = 0); |
| 114 | }; |
| 115 | |
| 116 | // ---------------------------------------------------------------------------- |
| 117 | |
| 118 | }; // namespace android |
| 119 | |
| 120 | #endif // ANDROID_IAUDIOPOLICYSERVICE_H |