blob: 09b9ea69bdae8d0b430bd12326c05edaa9ce49e7 [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>
28
Dima Zavin7394a4f2011-06-13 18:16:26 -070029#include <system/audio_policy.h>
Eric Laurentc2f1f072009-07-17 12:17:14 -070030
31namespace android {
32
33// ----------------------------------------------------------------------------
34
35class IAudioPolicyService : public IInterface
36{
37public:
38 DECLARE_META_INTERFACE(AudioPolicyService);
39
40 //
41 // IAudioPolicyService interface (see AudioPolicyInterface for method descriptions)
42 //
Dima Zavinfce7a472011-04-19 22:30:36 -070043 virtual status_t setDeviceConnectionState(audio_devices_t device,
44 audio_policy_dev_state_t state,
Eric Laurentc2f1f072009-07-17 12:17:14 -070045 const char *device_address) = 0;
Dima Zavinfce7a472011-04-19 22:30:36 -070046 virtual audio_policy_dev_state_t getDeviceConnectionState(audio_devices_t device,
Glenn Kasten85ab62c2012-11-01 11:11:38 -070047 const char *device_address) = 0;
Glenn Kastenf78aee72012-01-04 11:00:47 -080048 virtual status_t setPhoneState(audio_mode_t state) = 0;
Glenn Kasten85ab62c2012-11-01 11:11:38 -070049 virtual status_t setForceUse(audio_policy_force_use_t usage,
50 audio_policy_forced_cfg_t config) = 0;
Dima Zavinfce7a472011-04-19 22:30:36 -070051 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 Laurentc2f1f072009-07-17 12:17:14 -070053 uint32_t samplingRate = 0,
Glenn Kasten58f30212012-01-12 12:27:51 -080054 audio_format_t format = AUDIO_FORMAT_DEFAULT,
Glenn Kasten254af182012-07-03 14:59:05 -070055 audio_channel_mask_t channelMask = 0,
Richard Fitzgeraldad3af332013-03-25 16:54:37 +000056 audio_output_flags_t flags = AUDIO_OUTPUT_FLAG_NONE,
57 const audio_offload_info_t *offloadInfo = NULL) = 0;
Eric Laurentde070132010-07-13 04:45:46 -070058 virtual status_t startOutput(audio_io_handle_t output,
Dima Zavinfce7a472011-04-19 22:30:36 -070059 audio_stream_type_t stream,
Eric Laurentde070132010-07-13 04:45:46 -070060 int session = 0) = 0;
61 virtual status_t stopOutput(audio_io_handle_t output,
Dima Zavinfce7a472011-04-19 22:30:36 -070062 audio_stream_type_t stream,
Eric Laurentde070132010-07-13 04:45:46 -070063 int session = 0) = 0;
Eric Laurentc2f1f072009-07-17 12:17:14 -070064 virtual void releaseOutput(audio_io_handle_t output) = 0;
Glenn Kasteneba51fb2012-01-23 13:58:49 -080065 virtual audio_io_handle_t getInput(audio_source_t inputSource,
Eric Laurentc2f1f072009-07-17 12:17:14 -070066 uint32_t samplingRate = 0,
Glenn Kasten58f30212012-01-12 12:27:51 -080067 audio_format_t format = AUDIO_FORMAT_DEFAULT,
Glenn Kasten254af182012-07-03 14:59:05 -070068 audio_channel_mask_t channelMask = 0,
Eric Laurent7c7f10b2011-06-17 21:29:58 -070069 int audioSession = 0) = 0;
Eric Laurentc2f1f072009-07-17 12:17:14 -070070 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 Zavinfce7a472011-04-19 22:30:36 -070073 virtual status_t initStreamVolume(audio_stream_type_t stream,
Eric Laurentc2f1f072009-07-17 12:17:14 -070074 int indexMin,
75 int indexMax) = 0;
Eric Laurent83844cc2011-11-18 16:43:31 -080076 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 Zavinfce7a472011-04-19 22:30:36 -070082 virtual uint32_t getStrategyForStream(audio_stream_type_t stream) = 0;
Eric Laurent63742522012-03-08 13:42:42 -080083 virtual audio_devices_t getDevicesForStream(audio_stream_type_t stream) = 0;
Glenn Kasten58e5aa32012-06-20 14:08:14 -070084 virtual audio_io_handle_t getOutputForEffect(const effect_descriptor_t *desc) = 0;
85 virtual status_t registerEffect(const effect_descriptor_t *desc,
Eric Laurent7c7f10b2011-06-17 21:29:58 -070086 audio_io_handle_t io,
Eric Laurentde070132010-07-13 04:45:46 -070087 uint32_t strategy,
88 int session,
89 int id) = 0;
90 virtual status_t unregisterEffect(int id) = 0;
Eric Laurentdb7c0792011-08-10 10:37:50 -070091 virtual status_t setEffectEnabled(int id, bool enabled) = 0;
Glenn Kastenfff6d712012-01-12 16:38:12 -080092 virtual bool isStreamActive(audio_stream_type_t stream, uint32_t inPastMs = 0) const = 0;
Jean-Michel Trivi272ab542013-02-04 16:26:02 -080093 virtual bool isStreamActiveRemotely(audio_stream_type_t stream, uint32_t inPastMs = 0)
94 const = 0;
Jean-Michel Trivid7086032012-10-10 12:11:16 -070095 virtual bool isSourceActive(audio_source_t source) const = 0;
Eric Laurent57dae992011-07-24 13:36:09 -070096 virtual status_t queryDefaultPreProcessing(int audioSession,
97 effect_descriptor_t *descriptors,
98 uint32_t *count) = 0;
Richard Fitzgeraldad3af332013-03-25 16:54:37 +000099 // 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 Laurentc2f1f072009-07-17 12:17:14 -0700102};
103
104
105// ----------------------------------------------------------------------------
106
107class BnAudioPolicyService : public BnInterface<IAudioPolicyService>
108{
109public:
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