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 | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 30 | #include <utils/String8.h> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 31 | |
| 32 | namespace android { |
| 33 | |
| 34 | // ---------------------------------------------------------------------------- |
| 35 | |
| 36 | class IAudioFlinger : public IInterface |
| 37 | { |
| 38 | public: |
| 39 | DECLARE_META_INTERFACE(AudioFlinger); |
| 40 | |
| 41 | /* create an audio track and registers it with AudioFlinger. |
| 42 | * return null if the track cannot be created. |
| 43 | */ |
| 44 | virtual sp<IAudioTrack> createTrack( |
| 45 | pid_t pid, |
| 46 | int streamType, |
| 47 | uint32_t sampleRate, |
| 48 | int format, |
| 49 | int channelCount, |
| 50 | int frameCount, |
| 51 | uint32_t flags, |
| 52 | const sp<IMemory>& sharedBuffer, |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 53 | int output, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 54 | status_t *status) = 0; |
| 55 | |
| 56 | virtual sp<IAudioRecord> openRecord( |
| 57 | pid_t pid, |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 58 | int input, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 59 | uint32_t sampleRate, |
| 60 | int format, |
| 61 | int channelCount, |
| 62 | int frameCount, |
| 63 | uint32_t flags, |
| 64 | status_t *status) = 0; |
| 65 | |
| 66 | /* query the audio hardware state. This state never changes, |
| 67 | * and therefore can be cached. |
| 68 | */ |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 69 | virtual uint32_t sampleRate(int output) const = 0; |
| 70 | virtual int channelCount(int output) const = 0; |
| 71 | virtual int format(int output) const = 0; |
| 72 | virtual size_t frameCount(int output) const = 0; |
| 73 | virtual uint32_t latency(int output) const = 0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 74 | |
| 75 | /* set/get the audio hardware state. This will probably be used by |
| 76 | * the preference panel, mostly. |
| 77 | */ |
| 78 | virtual status_t setMasterVolume(float value) = 0; |
| 79 | virtual status_t setMasterMute(bool muted) = 0; |
| 80 | |
| 81 | virtual float masterVolume() const = 0; |
| 82 | virtual bool masterMute() const = 0; |
| 83 | |
| 84 | /* set/get stream type state. This will probably be used by |
| 85 | * the preference panel, mostly. |
| 86 | */ |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 87 | 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] | 88 | virtual status_t setStreamMute(int stream, bool muted) = 0; |
| 89 | |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 90 | virtual float streamVolume(int stream, int output) const = 0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 91 | virtual bool streamMute(int stream) const = 0; |
| 92 | |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 93 | // set audio mode |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 94 | virtual status_t setMode(int mode) = 0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 95 | |
| 96 | // mic mute/state |
| 97 | virtual status_t setMicMute(bool state) = 0; |
| 98 | virtual bool getMicMute() const = 0; |
| 99 | |
Eric Laurent | 23f25cd | 2010-01-25 08:49:09 -0800 | [diff] [blame] | 100 | // is any track active on this stream? |
| 101 | virtual bool isStreamActive(int stream) const = 0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 102 | |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 103 | virtual status_t setParameters(int ioHandle, const String8& keyValuePairs) = 0; |
| 104 | virtual String8 getParameters(int ioHandle, const String8& keys) = 0; |
Eric Laurent | 415f3e2 | 2009-10-21 08:14:22 -0700 | [diff] [blame] | 105 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 106 | // register a current process for audio output change notifications |
| 107 | virtual void registerClient(const sp<IAudioFlingerClient>& client) = 0; |
Eric Laurent | 415f3e2 | 2009-10-21 08:14:22 -0700 | [diff] [blame] | 108 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 109 | // retrieve the audio recording buffer size |
| 110 | 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] | 111 | |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 112 | virtual int openOutput(uint32_t *pDevices, |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 113 | uint32_t *pSamplingRate, |
| 114 | uint32_t *pFormat, |
| 115 | uint32_t *pChannels, |
| 116 | uint32_t *pLatencyMs, |
| 117 | uint32_t flags) = 0; |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 118 | virtual int openDuplicateOutput(int output1, int output2) = 0; |
| 119 | virtual status_t closeOutput(int output) = 0; |
| 120 | virtual status_t suspendOutput(int output) = 0; |
| 121 | virtual status_t restoreOutput(int output) = 0; |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 122 | |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 123 | virtual int openInput(uint32_t *pDevices, |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 124 | uint32_t *pSamplingRate, |
| 125 | uint32_t *pFormat, |
| 126 | uint32_t *pChannels, |
| 127 | uint32_t acoustics) = 0; |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 128 | virtual status_t closeInput(int input) = 0; |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 129 | |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 130 | virtual status_t setStreamOutput(uint32_t stream, int output) = 0; |
Eric Laurent | 415f3e2 | 2009-10-21 08:14:22 -0700 | [diff] [blame] | 131 | |
| 132 | virtual status_t setVoiceVolume(float volume) = 0; |
Eric Laurent | 0986e79 | 2010-01-19 17:37:09 -0800 | [diff] [blame] | 133 | virtual status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames, int output) = 0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 134 | }; |
| 135 | |
| 136 | |
| 137 | // ---------------------------------------------------------------------------- |
| 138 | |
| 139 | class BnAudioFlinger : public BnInterface<IAudioFlinger> |
| 140 | { |
| 141 | public: |
| 142 | virtual status_t onTransact( uint32_t code, |
| 143 | const Parcel& data, |
| 144 | Parcel* reply, |
| 145 | uint32_t flags = 0); |
| 146 | }; |
| 147 | |
| 148 | // ---------------------------------------------------------------------------- |
| 149 | |
| 150 | }; // namespace android |
| 151 | |
| 152 | #endif // ANDROID_IAUDIOFLINGER_H |