Home | History | Annotate | Download | only in media
      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 
     29 #include <system/audio_policy.h>
     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     //
     43     virtual status_t setDeviceConnectionState(audio_devices_t device,
     44                                               audio_policy_dev_state_t state,
     45                                               const char *device_address) = 0;
     46     virtual audio_policy_dev_state_t getDeviceConnectionState(audio_devices_t device,
     47                                                                   const char *device_address) = 0;
     48     virtual status_t setPhoneState(audio_mode_t state) = 0;
     49     virtual status_t setForceUse(audio_policy_force_use_t usage,
     50                                     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,
     53                                         uint32_t samplingRate = 0,
     54                                         audio_format_t format = AUDIO_FORMAT_DEFAULT,
     55                                         audio_channel_mask_t channelMask = 0,
     56                                         audio_output_flags_t flags = AUDIO_OUTPUT_FLAG_NONE) = 0;
     57     virtual status_t startOutput(audio_io_handle_t output,
     58                                  audio_stream_type_t stream,
     59                                  int session = 0) = 0;
     60     virtual status_t stopOutput(audio_io_handle_t output,
     61                                 audio_stream_type_t stream,
     62                                 int session = 0) = 0;
     63     virtual void releaseOutput(audio_io_handle_t output) = 0;
     64     virtual audio_io_handle_t getInput(audio_source_t inputSource,
     65                                     uint32_t samplingRate = 0,
     66                                     audio_format_t format = AUDIO_FORMAT_DEFAULT,
     67                                     audio_channel_mask_t channelMask = 0,
     68                                     int audioSession = 0) = 0;
     69     virtual status_t startInput(audio_io_handle_t input) = 0;
     70     virtual status_t stopInput(audio_io_handle_t input) = 0;
     71     virtual void releaseInput(audio_io_handle_t input) = 0;
     72     virtual status_t initStreamVolume(audio_stream_type_t stream,
     73                                       int indexMin,
     74                                       int indexMax) = 0;
     75     virtual status_t setStreamVolumeIndex(audio_stream_type_t stream,
     76                                           int index,
     77                                           audio_devices_t device) = 0;
     78     virtual status_t getStreamVolumeIndex(audio_stream_type_t stream,
     79                                           int *index,
     80                                           audio_devices_t device) = 0;
     81     virtual uint32_t getStrategyForStream(audio_stream_type_t stream) = 0;
     82     virtual audio_devices_t getDevicesForStream(audio_stream_type_t stream) = 0;
     83     virtual audio_io_handle_t getOutputForEffect(const effect_descriptor_t *desc) = 0;
     84     virtual status_t registerEffect(const effect_descriptor_t *desc,
     85                                     audio_io_handle_t io,
     86                                     uint32_t strategy,
     87                                     int session,
     88                                     int id) = 0;
     89     virtual status_t unregisterEffect(int id) = 0;
     90     virtual status_t setEffectEnabled(int id, bool enabled) = 0;
     91     virtual bool     isStreamActive(audio_stream_type_t stream, uint32_t inPastMs = 0) const = 0;
     92     virtual bool     isStreamActiveRemotely(audio_stream_type_t stream, uint32_t inPastMs = 0)
     93                              const = 0;
     94     virtual bool     isSourceActive(audio_source_t source) const = 0;
     95     virtual status_t queryDefaultPreProcessing(int audioSession,
     96                                               effect_descriptor_t *descriptors,
     97                                               uint32_t *count) = 0;
     98 };
     99 
    100 
    101 // ----------------------------------------------------------------------------
    102 
    103 class BnAudioPolicyService : public BnInterface<IAudioPolicyService>
    104 {
    105 public:
    106     virtual status_t    onTransact( uint32_t code,
    107                                     const Parcel& data,
    108                                     Parcel* reply,
    109                                     uint32_t flags = 0);
    110 };
    111 
    112 // ----------------------------------------------------------------------------
    113 
    114 }; // namespace android
    115 
    116 #endif // ANDROID_IAUDIOPOLICYSERVICE_H
    117