blob: 9807cbe56430790e5b47ee7db2b04bfc9302dbff [file] [log] [blame]
Eric Laurenta553c252009-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 Zavin290029d2011-06-13 18:16:26 -070029#include <system/audio_policy.h>
Eric Laurenta553c252009-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 Zavin24fc2fb2011-04-19 22:30:36 -070043 virtual status_t setDeviceConnectionState(audio_devices_t device,
44 audio_policy_dev_state_t state,
Eric Laurenta553c252009-07-17 12:17:14 -070045 const char *device_address) = 0;
Dima Zavin24fc2fb2011-04-19 22:30:36 -070046 virtual audio_policy_dev_state_t getDeviceConnectionState(audio_devices_t device,
Eric Laurenta553c252009-07-17 12:17:14 -070047 const char *device_address) = 0;
48 virtual status_t setPhoneState(int state) = 0;
49 virtual status_t setRingerMode(uint32_t mode, uint32_t mask) = 0;
Dima Zavin24fc2fb2011-04-19 22:30:36 -070050 virtual status_t setForceUse(audio_policy_force_use_t usage, audio_policy_forced_cfg_t config) = 0;
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 Laurenta553c252009-07-17 12:17:14 -070053 uint32_t samplingRate = 0,
Dima Zavin24fc2fb2011-04-19 22:30:36 -070054 uint32_t format = AUDIO_FORMAT_DEFAULT,
Eric Laurenta553c252009-07-17 12:17:14 -070055 uint32_t channels = 0,
Dima Zavin24fc2fb2011-04-19 22:30:36 -070056 audio_policy_output_flags_t flags = AUDIO_POLICY_OUTPUT_FLAG_INDIRECT) = 0;
Eric Laurent8ed6ed02010-07-13 04:45:46 -070057 virtual status_t startOutput(audio_io_handle_t output,
Dima Zavin24fc2fb2011-04-19 22:30:36 -070058 audio_stream_type_t stream,
Eric Laurent8ed6ed02010-07-13 04:45:46 -070059 int session = 0) = 0;
60 virtual status_t stopOutput(audio_io_handle_t output,
Dima Zavin24fc2fb2011-04-19 22:30:36 -070061 audio_stream_type_t stream,
Eric Laurent8ed6ed02010-07-13 04:45:46 -070062 int session = 0) = 0;
Eric Laurenta553c252009-07-17 12:17:14 -070063 virtual void releaseOutput(audio_io_handle_t output) = 0;
64 virtual audio_io_handle_t getInput(int inputSource,
65 uint32_t samplingRate = 0,
Dima Zavin24fc2fb2011-04-19 22:30:36 -070066 uint32_t format = AUDIO_FORMAT_DEFAULT,
Eric Laurenta553c252009-07-17 12:17:14 -070067 uint32_t channels = 0,
Eric Laurent464d5b32011-06-17 21:29:58 -070068 audio_in_acoustics_t acoustics = (audio_in_acoustics_t)0,
69 int audioSession = 0) = 0;
Eric Laurenta553c252009-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 Zavin24fc2fb2011-04-19 22:30:36 -070073 virtual status_t initStreamVolume(audio_stream_type_t stream,
Eric Laurenta553c252009-07-17 12:17:14 -070074 int indexMin,
75 int indexMax) = 0;
Dima Zavin24fc2fb2011-04-19 22:30:36 -070076 virtual status_t setStreamVolumeIndex(audio_stream_type_t stream, int index) = 0;
77 virtual status_t getStreamVolumeIndex(audio_stream_type_t stream, int *index) = 0;
78 virtual uint32_t getStrategyForStream(audio_stream_type_t stream) = 0;
79 virtual uint32_t getDevicesForStream(audio_stream_type_t stream) = 0;
Eric Laurent8ed6ed02010-07-13 04:45:46 -070080 virtual audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc) = 0;
81 virtual status_t registerEffect(effect_descriptor_t *desc,
Eric Laurent464d5b32011-06-17 21:29:58 -070082 audio_io_handle_t io,
Eric Laurent8ed6ed02010-07-13 04:45:46 -070083 uint32_t strategy,
84 int session,
85 int id) = 0;
86 virtual status_t unregisterEffect(int id) = 0;
Eric Laurent6752ec82011-08-10 10:37:50 -070087 virtual status_t setEffectEnabled(int id, bool enabled) = 0;
Eric Laurent25101b02011-02-02 09:33:30 -080088 virtual bool isStreamActive(int stream, uint32_t inPastMs = 0) const = 0;
Eric Laurent0f7f4ec2011-07-24 13:36:09 -070089 virtual status_t queryDefaultPreProcessing(int audioSession,
90 effect_descriptor_t *descriptors,
91 uint32_t *count) = 0;
Eric Laurenta553c252009-07-17 12:17:14 -070092};
93
94
95// ----------------------------------------------------------------------------
96
97class BnAudioPolicyService : public BnInterface<IAudioPolicyService>
98{
99public:
100 virtual status_t onTransact( uint32_t code,
101 const Parcel& data,
102 Parcel* reply,
103 uint32_t flags = 0);
104};
105
106// ----------------------------------------------------------------------------
107
108}; // namespace android
109
110#endif // ANDROID_IAUDIOPOLICYSERVICE_H