IAudioPolicyService.h revision 203b1a18a806e2c56c701aac49cda963bccfad5b
1c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent/*
2c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent * Copyright (C) 2009 The Android Open Source Project
3c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent *
4c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent * Licensed under the Apache License, Version 2.0 (the "License");
5c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent * you may not use this file except in compliance with the License.
6c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent * You may obtain a copy of the License at
7c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent *
8c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent *      http://www.apache.org/licenses/LICENSE-2.0
9c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent *
10c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent * Unless required by applicable law or agreed to in writing, software
11c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent * distributed under the License is distributed on an "AS IS" BASIS,
12c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent * See the License for the specific language governing permissions and
14c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent * limitations under the License.
15c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent */
16c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
17c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent#ifndef ANDROID_IAUDIOPOLICYSERVICE_H
18c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent#define ANDROID_IAUDIOPOLICYSERVICE_H
19c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
20c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent#include <stdint.h>
21c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent#include <sys/types.h>
22c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent#include <unistd.h>
23c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
24c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent#include <utils/RefBase.h>
25c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent#include <utils/Errors.h>
26c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent#include <binder/IInterface.h>
27c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent#include <media/AudioSystem.h>
28c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
297394a4f358fa9908a9f0a7c954b65c399f4268e6Dima Zavin#include <system/audio_policy.h>
30c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
31c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentnamespace android {
32c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
33c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent// ----------------------------------------------------------------------------
34c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
35c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentclass IAudioPolicyService : public IInterface
36c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent{
37c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentpublic:
38c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    DECLARE_META_INTERFACE(AudioPolicyService);
39c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
40c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    //
41c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    // IAudioPolicyService interface (see AudioPolicyInterface for method descriptions)
42c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    //
43fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    virtual status_t setDeviceConnectionState(audio_devices_t device,
44fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                                              audio_policy_dev_state_t state,
45c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                              const char *device_address) = 0;
46fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    virtual audio_policy_dev_state_t getDeviceConnectionState(audio_devices_t device,
4785ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten                                                                  const char *device_address) = 0;
48f78aee70d15daf4690de7e7b4983ee68b0d1381dGlenn Kasten    virtual status_t setPhoneState(audio_mode_t state) = 0;
4985ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten    virtual status_t setForceUse(audio_policy_force_use_t usage,
5085ab62c4b433df3f1a9826bed1c9bec07a86c750Glenn Kasten                                    audio_policy_forced_cfg_t config) = 0;
51fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    virtual audio_policy_forced_cfg_t getForceUse(audio_policy_force_use_t usage) = 0;
52fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    virtual audio_io_handle_t getOutput(audio_stream_type_t stream,
53c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                        uint32_t samplingRate = 0,
5458f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten                                        audio_format_t format = AUDIO_FORMAT_DEFAULT,
55254af180475346b6186b49c297f340c9c4817511Glenn Kasten                                        audio_channel_mask_t channelMask = 0,
56ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald                                        audio_output_flags_t flags = AUDIO_OUTPUT_FLAG_NONE,
57ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald                                        const audio_offload_info_t *offloadInfo = NULL) = 0;
58de070137f11d346fba77605bd76a44c040a618fcEric Laurent    virtual status_t startOutput(audio_io_handle_t output,
59fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                                 audio_stream_type_t stream,
60de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                 int session = 0) = 0;
61de070137f11d346fba77605bd76a44c040a618fcEric Laurent    virtual status_t stopOutput(audio_io_handle_t output,
62fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin                                audio_stream_type_t stream,
63de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                int session = 0) = 0;
64c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual void releaseOutput(audio_io_handle_t output) = 0;
65eba51fb3a361f67a6a64d5a16eba6084fe27d60eGlenn Kasten    virtual audio_io_handle_t getInput(audio_source_t inputSource,
66c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    uint32_t samplingRate = 0,
6758f30210ea540b6ce5aa6a46330cd3499483cb97Glenn Kasten                                    audio_format_t format = AUDIO_FORMAT_DEFAULT,
68254af180475346b6186b49c297f340c9c4817511Glenn Kasten                                    audio_channel_mask_t channelMask = 0,
697c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent                                    int audioSession = 0) = 0;
70c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual status_t startInput(audio_io_handle_t input) = 0;
71c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual status_t stopInput(audio_io_handle_t input) = 0;
72c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual void releaseInput(audio_io_handle_t input) = 0;
73fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    virtual status_t initStreamVolume(audio_stream_type_t stream,
74c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                      int indexMin,
75c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                      int indexMax) = 0;
7683844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent    virtual status_t setStreamVolumeIndex(audio_stream_type_t stream,
7783844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent                                          int index,
7883844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent                                          audio_devices_t device) = 0;
7983844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent    virtual status_t getStreamVolumeIndex(audio_stream_type_t stream,
8083844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent                                          int *index,
8183844cc2f95dc279015b47fd1e18c7cb4eabe9a1Eric Laurent                                          audio_devices_t device) = 0;
82fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin    virtual uint32_t getStrategyForStream(audio_stream_type_t stream) = 0;
836374252107fd6539397598195ea6defd5870fafbEric Laurent    virtual audio_devices_t getDevicesForStream(audio_stream_type_t stream) = 0;
8458e5aa34f01d663654d8bafad65db1dda42161ffGlenn Kasten    virtual audio_io_handle_t getOutputForEffect(const effect_descriptor_t *desc) = 0;
8558e5aa34f01d663654d8bafad65db1dda42161ffGlenn Kasten    virtual status_t registerEffect(const effect_descriptor_t *desc,
867c7f10bd4fda9a084e5e7f0eb3a040dfcbf01745Eric Laurent                                    audio_io_handle_t io,
87de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                    uint32_t strategy,
88de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                    int session,
89de070137f11d346fba77605bd76a44c040a618fcEric Laurent                                    int id) = 0;
90de070137f11d346fba77605bd76a44c040a618fcEric Laurent    virtual status_t unregisterEffect(int id) = 0;
91db7c079f284f6e91266f6653ae0ec198b1c5006eEric Laurent    virtual status_t setEffectEnabled(int id, bool enabled) = 0;
92fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten    virtual bool     isStreamActive(audio_stream_type_t stream, uint32_t inPastMs = 0) const = 0;
93272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi    virtual bool     isStreamActiveRemotely(audio_stream_type_t stream, uint32_t inPastMs = 0)
94272ab546940054ad7991bef4b3a36f15175721cdJean-Michel Trivi                             const = 0;
95d7086030fcf731e4bcef6c033cc6418cd04e6b91Jean-Michel Trivi    virtual bool     isSourceActive(audio_source_t source) const = 0;
9657dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent    virtual status_t queryDefaultPreProcessing(int audioSession,
9757dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent                                              effect_descriptor_t *descriptors,
9857dae99c9fcd6becd2b5ed0c53f277ba4d7dbcfcEric Laurent                                              uint32_t *count) = 0;
99ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald   // Check if offload is possible for given format, stream type, sample rate,
100ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald    // bit rate, duration, video and streaming or offload property is enabled
101ad3af3305f024bcbbd55c894a4995e449498e1baRichard Fitzgerald    virtual bool isOffloadSupported(const audio_offload_info_t& info) = 0;
102203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent
103203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    /* List available audio ports and their attributes */
104203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    virtual status_t listAudioPorts(audio_port_role_t role,
105203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent                                    audio_port_type_t type,
106203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent                                    unsigned int *num_ports,
107203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent                                    struct audio_port *ports,
108203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent                                    unsigned int *generation) = 0;
109203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent
110203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    /* Get attributes for a given audio port */
111203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    virtual status_t getAudioPort(struct audio_port *port) = 0;
112203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent
113203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    /* Create an audio patch between several source and sink ports */
114203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    virtual status_t createAudioPatch(const struct audio_patch *patch,
115203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent                                       audio_patch_handle_t *handle) = 0;
116203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent
117203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    /* Release an audio patch */
118203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    virtual status_t releaseAudioPatch(audio_patch_handle_t handle) = 0;
119203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent
120203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    /* List existing audio patches */
121203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    virtual status_t listAudioPatches(unsigned int *num_patches,
122203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent                                      struct audio_patch *patches,
123203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent                                      unsigned int *generation) = 0;
124203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    /* Set audio port configuration */
125203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent    virtual status_t setAudioPortConfig(const struct audio_port_config *config) = 0;
126203b1a18a806e2c56c701aac49cda963bccfad5bEric Laurent
127c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent};
128c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
129c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
130c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent// ----------------------------------------------------------------------------
131c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
132c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentclass BnAudioPolicyService : public BnInterface<IAudioPolicyService>
133c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent{
134c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurentpublic:
135c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent    virtual status_t    onTransact( uint32_t code,
136c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    const Parcel& data,
137c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    Parcel* reply,
138c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent                                    uint32_t flags = 0);
139c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent};
140c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
141c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent// ----------------------------------------------------------------------------
142c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
143c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent}; // namespace android
144c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent
145c2f1f07084818942352c6bbfb36af9b6b330eb4eEric Laurent#endif // ANDROID_IAUDIOPOLICYSERVICE_H
146