The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 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_IAUDIOFLINGER_H |
| 18 | #define ANDROID_IAUDIOFLINGER_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> |
Mathias Agopian | 0795272 | 2009-05-19 19:08:10 -0700 | [diff] [blame] | 26 | #include <binder/IInterface.h> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 27 | #include <media/IAudioTrack.h> |
| 28 | #include <media/IAudioRecord.h> |
| 29 | #include <media/IAudioFlingerClient.h> |
Eric Laurent | 0fb66c2 | 2011-05-17 19:16:02 -0700 | [diff] [blame] | 30 | #include <hardware/audio_effect.h> |
Eric Laurent | 65b6545 | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 31 | #include <media/IEffect.h> |
| 32 | #include <media/IEffectClient.h> |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 33 | #include <utils/String8.h> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 34 | |
| 35 | namespace android { |
| 36 | |
| 37 | // ---------------------------------------------------------------------------- |
| 38 | |
| 39 | class IAudioFlinger : public IInterface |
| 40 | { |
| 41 | public: |
| 42 | DECLARE_META_INTERFACE(AudioFlinger); |
| 43 | |
| 44 | /* create an audio track and registers it with AudioFlinger. |
| 45 | * return null if the track cannot be created. |
| 46 | */ |
| 47 | virtual sp<IAudioTrack> createTrack( |
| 48 | pid_t pid, |
| 49 | int streamType, |
| 50 | uint32_t sampleRate, |
Jean-Michel Trivi | 5439223 | 2011-05-24 15:53:33 -0700 | [diff] [blame] | 51 | uint32_t format, |
| 52 | uint32_t channelMask, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 53 | int frameCount, |
| 54 | uint32_t flags, |
| 55 | const sp<IMemory>& sharedBuffer, |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 56 | int output, |
Eric Laurent | 65b6545 | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 57 | int *sessionId, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 58 | status_t *status) = 0; |
| 59 | |
| 60 | virtual sp<IAudioRecord> openRecord( |
| 61 | pid_t pid, |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 62 | int input, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 63 | uint32_t sampleRate, |
Jean-Michel Trivi | 5439223 | 2011-05-24 15:53:33 -0700 | [diff] [blame] | 64 | uint32_t format, |
| 65 | uint32_t channelMask, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 66 | int frameCount, |
| 67 | uint32_t flags, |
Eric Laurent | 65b6545 | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 68 | int *sessionId, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 69 | status_t *status) = 0; |
| 70 | |
| 71 | /* query the audio hardware state. This state never changes, |
| 72 | * and therefore can be cached. |
| 73 | */ |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 74 | virtual uint32_t sampleRate(int output) const = 0; |
| 75 | virtual int channelCount(int output) const = 0; |
Jean-Michel Trivi | 5439223 | 2011-05-24 15:53:33 -0700 | [diff] [blame] | 76 | virtual uint32_t format(int output) const = 0; |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 77 | virtual size_t frameCount(int output) const = 0; |
| 78 | virtual uint32_t latency(int output) const = 0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 79 | |
| 80 | /* set/get the audio hardware state. This will probably be used by |
| 81 | * the preference panel, mostly. |
| 82 | */ |
| 83 | virtual status_t setMasterVolume(float value) = 0; |
| 84 | virtual status_t setMasterMute(bool muted) = 0; |
| 85 | |
| 86 | virtual float masterVolume() const = 0; |
| 87 | virtual bool masterMute() const = 0; |
| 88 | |
| 89 | /* set/get stream type state. This will probably be used by |
| 90 | * the preference panel, mostly. |
| 91 | */ |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 92 | virtual status_t setStreamVolume(int stream, float value, int output) = 0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 93 | virtual status_t setStreamMute(int stream, bool muted) = 0; |
| 94 | |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 95 | virtual float streamVolume(int stream, int output) const = 0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 96 | virtual bool streamMute(int stream) const = 0; |
| 97 | |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 98 | // set audio mode |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 99 | virtual status_t setMode(int mode) = 0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 100 | |
| 101 | // mic mute/state |
| 102 | virtual status_t setMicMute(bool state) = 0; |
| 103 | virtual bool getMicMute() const = 0; |
| 104 | |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 105 | virtual status_t setParameters(int ioHandle, const String8& keyValuePairs) = 0; |
| 106 | virtual String8 getParameters(int ioHandle, const String8& keys) = 0; |
Eric Laurent | 415f3e2 | 2009-10-21 08:14:22 -0700 | [diff] [blame] | 107 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 108 | // register a current process for audio output change notifications |
| 109 | virtual void registerClient(const sp<IAudioFlingerClient>& client) = 0; |
Eric Laurent | 415f3e2 | 2009-10-21 08:14:22 -0700 | [diff] [blame] | 110 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 111 | // retrieve the audio recording buffer size |
| 112 | virtual size_t getInputBufferSize(uint32_t sampleRate, int format, int channelCount) = 0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 113 | |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 114 | virtual int openOutput(uint32_t *pDevices, |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 115 | uint32_t *pSamplingRate, |
| 116 | uint32_t *pFormat, |
| 117 | uint32_t *pChannels, |
| 118 | uint32_t *pLatencyMs, |
| 119 | uint32_t flags) = 0; |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 120 | virtual int openDuplicateOutput(int output1, int output2) = 0; |
| 121 | virtual status_t closeOutput(int output) = 0; |
| 122 | virtual status_t suspendOutput(int output) = 0; |
| 123 | virtual status_t restoreOutput(int output) = 0; |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 124 | |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 125 | virtual int openInput(uint32_t *pDevices, |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 126 | uint32_t *pSamplingRate, |
| 127 | uint32_t *pFormat, |
| 128 | uint32_t *pChannels, |
| 129 | uint32_t acoustics) = 0; |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 130 | virtual status_t closeInput(int input) = 0; |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 131 | |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 132 | virtual status_t setStreamOutput(uint32_t stream, int output) = 0; |
Eric Laurent | 415f3e2 | 2009-10-21 08:14:22 -0700 | [diff] [blame] | 133 | |
| 134 | virtual status_t setVoiceVolume(float volume) = 0; |
Eric Laurent | 47d0a92 | 2010-02-26 02:47:27 -0800 | [diff] [blame] | 135 | |
Eric Laurent | 0986e79 | 2010-01-19 17:37:09 -0800 | [diff] [blame] | 136 | virtual status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames, int output) = 0; |
Eric Laurent | 47d0a92 | 2010-02-26 02:47:27 -0800 | [diff] [blame] | 137 | |
| 138 | virtual unsigned int getInputFramesLost(int ioHandle) = 0; |
Eric Laurent | 65b6545 | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 139 | |
| 140 | virtual int newAudioSessionId() = 0; |
| 141 | |
Marco Nelissen | c74b93f | 2011-08-02 13:33:41 -0700 | [diff] [blame] | 142 | virtual void acquireAudioSessionId(int audioSession) = 0; |
| 143 | virtual void releaseAudioSessionId(int audioSession) = 0; |
| 144 | |
Eric Laurent | 65b6545 | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 145 | virtual status_t queryNumberEffects(uint32_t *numEffects) = 0; |
| 146 | |
Eric Laurent | 53334cd | 2010-06-23 17:38:20 -0700 | [diff] [blame] | 147 | virtual status_t queryEffect(uint32_t index, effect_descriptor_t *pDescriptor) = 0; |
Eric Laurent | 65b6545 | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 148 | |
| 149 | virtual status_t getEffectDescriptor(effect_uuid_t *pEffectUUID, effect_descriptor_t *pDescriptor) = 0; |
| 150 | |
| 151 | virtual sp<IEffect> createEffect(pid_t pid, |
| 152 | effect_descriptor_t *pDesc, |
| 153 | const sp<IEffectClient>& client, |
| 154 | int32_t priority, |
| 155 | int output, |
| 156 | int sessionId, |
| 157 | status_t *status, |
| 158 | int *id, |
| 159 | int *enabled) = 0; |
Eric Laurent | 8ed6ed0 | 2010-07-13 04:45:46 -0700 | [diff] [blame] | 160 | |
| 161 | virtual status_t moveEffects(int session, int srcOutput, int dstOutput) = 0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 162 | }; |
| 163 | |
| 164 | |
| 165 | // ---------------------------------------------------------------------------- |
| 166 | |
| 167 | class BnAudioFlinger : public BnInterface<IAudioFlinger> |
| 168 | { |
| 169 | public: |
| 170 | virtual status_t onTransact( uint32_t code, |
| 171 | const Parcel& data, |
| 172 | Parcel* reply, |
| 173 | uint32_t flags = 0); |
| 174 | }; |
| 175 | |
| 176 | // ---------------------------------------------------------------------------- |
| 177 | |
| 178 | }; // namespace android |
| 179 | |
| 180 | #endif // ANDROID_IAUDIOFLINGER_H |