blob: 959e4c3808db8a3d08cb2302fbe6a051c854a425 [file] [log] [blame]
Eric Laurentc2f1f072009-07-17 12:17:14 -07001/*
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>
Eric Laurentb52c1522014-05-20 11:27:36 -070028#include <media/IAudioPolicyServiceClient.h>
Eric Laurentc2f1f072009-07-17 12:17:14 -070029
Dima Zavin7394a4f2011-06-13 18:16:26 -070030#include <system/audio_policy.h>
Eric Laurentc2f1f072009-07-17 12:17:14 -070031
32namespace android {
33
34// ----------------------------------------------------------------------------
35
36class IAudioPolicyService : public IInterface
37{
38public:
39 DECLARE_META_INTERFACE(AudioPolicyService);
40
41 //
42 // IAudioPolicyService interface (see AudioPolicyInterface for method descriptions)
43 //
Dima Zavinfce7a472011-04-19 22:30:36 -070044 virtual status_t setDeviceConnectionState(audio_devices_t device,
45 audio_policy_dev_state_t state,
Eric Laurentc2f1f072009-07-17 12:17:14 -070046 const char *device_address) = 0;
Dima Zavinfce7a472011-04-19 22:30:36 -070047 virtual audio_policy_dev_state_t getDeviceConnectionState(audio_devices_t device,
Glenn Kasten85ab62c2012-11-01 11:11:38 -070048 const char *device_address) = 0;
Glenn Kastenf78aee72012-01-04 11:00:47 -080049 virtual status_t setPhoneState(audio_mode_t state) = 0;
Glenn Kasten85ab62c2012-11-01 11:11:38 -070050 virtual status_t setForceUse(audio_policy_force_use_t usage,
51 audio_policy_forced_cfg_t config) = 0;
Dima Zavinfce7a472011-04-19 22:30:36 -070052 virtual audio_policy_forced_cfg_t getForceUse(audio_policy_force_use_t usage) = 0;
53 virtual audio_io_handle_t getOutput(audio_stream_type_t stream,
Eric Laurentc2f1f072009-07-17 12:17:14 -070054 uint32_t samplingRate = 0,
Glenn Kasten58f30212012-01-12 12:27:51 -080055 audio_format_t format = AUDIO_FORMAT_DEFAULT,
Glenn Kasten254af182012-07-03 14:59:05 -070056 audio_channel_mask_t channelMask = 0,
Richard Fitzgeraldad3af332013-03-25 16:54:37 +000057 audio_output_flags_t flags = AUDIO_OUTPUT_FLAG_NONE,
58 const audio_offload_info_t *offloadInfo = NULL) = 0;
Jean-Michel Trivi5bd3f382014-06-13 16:06:54 -070059 virtual audio_io_handle_t getOutputForAttr(const audio_attributes_t *attr,
60 uint32_t samplingRate = 0,
61 audio_format_t format = AUDIO_FORMAT_DEFAULT,
62 audio_channel_mask_t channelMask = 0,
63 audio_output_flags_t flags = AUDIO_OUTPUT_FLAG_NONE,
64 const audio_offload_info_t *offloadInfo = NULL) = 0;
Eric Laurentde070132010-07-13 04:45:46 -070065 virtual status_t startOutput(audio_io_handle_t output,
Dima Zavinfce7a472011-04-19 22:30:36 -070066 audio_stream_type_t stream,
Eric Laurentde070132010-07-13 04:45:46 -070067 int session = 0) = 0;
68 virtual status_t stopOutput(audio_io_handle_t output,
Dima Zavinfce7a472011-04-19 22:30:36 -070069 audio_stream_type_t stream,
Eric Laurentde070132010-07-13 04:45:46 -070070 int session = 0) = 0;
Eric Laurentc2f1f072009-07-17 12:17:14 -070071 virtual void releaseOutput(audio_io_handle_t output) = 0;
Glenn Kasteneba51fb2012-01-23 13:58:49 -080072 virtual audio_io_handle_t getInput(audio_source_t inputSource,
Eric Laurentc2f1f072009-07-17 12:17:14 -070073 uint32_t samplingRate = 0,
Glenn Kasten58f30212012-01-12 12:27:51 -080074 audio_format_t format = AUDIO_FORMAT_DEFAULT,
Glenn Kasten254af182012-07-03 14:59:05 -070075 audio_channel_mask_t channelMask = 0,
Eric Laurent7c7f10b2011-06-17 21:29:58 -070076 int audioSession = 0) = 0;
Eric Laurentc2f1f072009-07-17 12:17:14 -070077 virtual status_t startInput(audio_io_handle_t input) = 0;
78 virtual status_t stopInput(audio_io_handle_t input) = 0;
79 virtual void releaseInput(audio_io_handle_t input) = 0;
Dima Zavinfce7a472011-04-19 22:30:36 -070080 virtual status_t initStreamVolume(audio_stream_type_t stream,
Eric Laurentc2f1f072009-07-17 12:17:14 -070081 int indexMin,
82 int indexMax) = 0;
Eric Laurent83844cc2011-11-18 16:43:31 -080083 virtual status_t setStreamVolumeIndex(audio_stream_type_t stream,
84 int index,
85 audio_devices_t device) = 0;
86 virtual status_t getStreamVolumeIndex(audio_stream_type_t stream,
87 int *index,
88 audio_devices_t device) = 0;
Dima Zavinfce7a472011-04-19 22:30:36 -070089 virtual uint32_t getStrategyForStream(audio_stream_type_t stream) = 0;
Eric Laurent63742522012-03-08 13:42:42 -080090 virtual audio_devices_t getDevicesForStream(audio_stream_type_t stream) = 0;
Glenn Kasten58e5aa32012-06-20 14:08:14 -070091 virtual audio_io_handle_t getOutputForEffect(const effect_descriptor_t *desc) = 0;
92 virtual status_t registerEffect(const effect_descriptor_t *desc,
Eric Laurent7c7f10b2011-06-17 21:29:58 -070093 audio_io_handle_t io,
Eric Laurentde070132010-07-13 04:45:46 -070094 uint32_t strategy,
95 int session,
96 int id) = 0;
97 virtual status_t unregisterEffect(int id) = 0;
Eric Laurentdb7c0792011-08-10 10:37:50 -070098 virtual status_t setEffectEnabled(int id, bool enabled) = 0;
Glenn Kastenfff6d712012-01-12 16:38:12 -080099 virtual bool isStreamActive(audio_stream_type_t stream, uint32_t inPastMs = 0) const = 0;
Jean-Michel Trivi272ab542013-02-04 16:26:02 -0800100 virtual bool isStreamActiveRemotely(audio_stream_type_t stream, uint32_t inPastMs = 0)
101 const = 0;
Jean-Michel Trivid7086032012-10-10 12:11:16 -0700102 virtual bool isSourceActive(audio_source_t source) const = 0;
Eric Laurent57dae992011-07-24 13:36:09 -0700103 virtual status_t queryDefaultPreProcessing(int audioSession,
104 effect_descriptor_t *descriptors,
105 uint32_t *count) = 0;
Richard Fitzgeraldad3af332013-03-25 16:54:37 +0000106 // Check if offload is possible for given format, stream type, sample rate,
107 // bit rate, duration, video and streaming or offload property is enabled
108 virtual bool isOffloadSupported(const audio_offload_info_t& info) = 0;
Eric Laurent203b1a12014-04-01 10:34:16 -0700109
110 /* List available audio ports and their attributes */
111 virtual status_t listAudioPorts(audio_port_role_t role,
112 audio_port_type_t type,
113 unsigned int *num_ports,
114 struct audio_port *ports,
115 unsigned int *generation) = 0;
116
117 /* Get attributes for a given audio port */
118 virtual status_t getAudioPort(struct audio_port *port) = 0;
119
120 /* Create an audio patch between several source and sink ports */
121 virtual status_t createAudioPatch(const struct audio_patch *patch,
122 audio_patch_handle_t *handle) = 0;
123
124 /* Release an audio patch */
125 virtual status_t releaseAudioPatch(audio_patch_handle_t handle) = 0;
126
127 /* List existing audio patches */
128 virtual status_t listAudioPatches(unsigned int *num_patches,
129 struct audio_patch *patches,
130 unsigned int *generation) = 0;
131 /* Set audio port configuration */
132 virtual status_t setAudioPortConfig(const struct audio_port_config *config) = 0;
133
Eric Laurentb52c1522014-05-20 11:27:36 -0700134 virtual void registerClient(const sp<IAudioPolicyServiceClient>& client) = 0;
Eric Laurentc2f1f072009-07-17 12:17:14 -0700135};
136
137
138// ----------------------------------------------------------------------------
139
140class BnAudioPolicyService : public BnInterface<IAudioPolicyService>
141{
142public:
143 virtual status_t onTransact( uint32_t code,
144 const Parcel& data,
145 Parcel* reply,
146 uint32_t flags = 0);
147};
148
149// ----------------------------------------------------------------------------
150
151}; // namespace android
152
153#endif // ANDROID_IAUDIOPOLICYSERVICE_H