The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* //device/extlibs/pv/android/IAudioflinger.cpp |
| 2 | ** |
| 3 | ** Copyright 2007, The Android Open Source Project |
| 4 | ** |
| 5 | ** Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | ** you may not use this file except in compliance with the License. |
| 7 | ** You may obtain a copy of the License at |
| 8 | ** |
| 9 | ** http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | ** |
| 11 | ** Unless required by applicable law or agreed to in writing, software |
| 12 | ** distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | ** See the License for the specific language governing permissions and |
| 15 | ** limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | #define LOG_TAG "IAudioFlinger" |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 19 | //#define LOG_NDEBUG 0 |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 20 | #include <utils/Log.h> |
| 21 | |
| 22 | #include <stdint.h> |
| 23 | #include <sys/types.h> |
| 24 | |
Mathias Agopian | 0795272 | 2009-05-19 19:08:10 -0700 | [diff] [blame] | 25 | #include <binder/Parcel.h> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 26 | |
| 27 | #include <media/IAudioFlinger.h> |
| 28 | |
| 29 | namespace android { |
| 30 | |
| 31 | enum { |
| 32 | CREATE_TRACK = IBinder::FIRST_CALL_TRANSACTION, |
| 33 | OPEN_RECORD, |
| 34 | SAMPLE_RATE, |
| 35 | CHANNEL_COUNT, |
| 36 | FORMAT, |
| 37 | FRAME_COUNT, |
| 38 | LATENCY, |
| 39 | SET_MASTER_VOLUME, |
| 40 | SET_MASTER_MUTE, |
| 41 | MASTER_VOLUME, |
| 42 | MASTER_MUTE, |
| 43 | SET_STREAM_VOLUME, |
| 44 | SET_STREAM_MUTE, |
| 45 | STREAM_VOLUME, |
| 46 | STREAM_MUTE, |
| 47 | SET_MODE, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 48 | SET_MIC_MUTE, |
| 49 | GET_MIC_MUTE, |
| 50 | IS_MUSIC_ACTIVE, |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 51 | SET_PARAMETERS, |
| 52 | GET_PARAMETERS, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 53 | REGISTER_CLIENT, |
| 54 | GET_INPUTBUFFERSIZE, |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 55 | OPEN_OUTPUT, |
| 56 | OPEN_DUPLICATE_OUTPUT, |
| 57 | CLOSE_OUTPUT, |
| 58 | SUSPEND_OUTPUT, |
| 59 | RESTORE_OUTPUT, |
| 60 | OPEN_INPUT, |
| 61 | CLOSE_INPUT, |
Eric Laurent | 415f3e2 | 2009-10-21 08:14:22 -0700 | [diff] [blame^] | 62 | SET_STREAM_OUTPUT, |
| 63 | SET_VOICE_VOLUME |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 64 | }; |
| 65 | |
| 66 | class BpAudioFlinger : public BpInterface<IAudioFlinger> |
| 67 | { |
| 68 | public: |
| 69 | BpAudioFlinger(const sp<IBinder>& impl) |
| 70 | : BpInterface<IAudioFlinger>(impl) |
| 71 | { |
| 72 | } |
| 73 | |
| 74 | virtual sp<IAudioTrack> createTrack( |
| 75 | pid_t pid, |
| 76 | int streamType, |
| 77 | uint32_t sampleRate, |
| 78 | int format, |
| 79 | int channelCount, |
| 80 | int frameCount, |
| 81 | uint32_t flags, |
| 82 | const sp<IMemory>& sharedBuffer, |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 83 | int output, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 84 | status_t *status) |
| 85 | { |
| 86 | Parcel data, reply; |
Eric Laurent | 8a77a99 | 2009-09-09 05:16:08 -0700 | [diff] [blame] | 87 | sp<IAudioTrack> track; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 88 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 89 | data.writeInt32(pid); |
| 90 | data.writeInt32(streamType); |
| 91 | data.writeInt32(sampleRate); |
| 92 | data.writeInt32(format); |
| 93 | data.writeInt32(channelCount); |
| 94 | data.writeInt32(frameCount); |
| 95 | data.writeInt32(flags); |
| 96 | data.writeStrongBinder(sharedBuffer->asBinder()); |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 97 | data.writeInt32(output); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 98 | status_t lStatus = remote()->transact(CREATE_TRACK, data, &reply); |
| 99 | if (lStatus != NO_ERROR) { |
| 100 | LOGE("createTrack error: %s", strerror(-lStatus)); |
Eric Laurent | 8a77a99 | 2009-09-09 05:16:08 -0700 | [diff] [blame] | 101 | } else { |
| 102 | lStatus = reply.readInt32(); |
| 103 | track = interface_cast<IAudioTrack>(reply.readStrongBinder()); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 104 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 105 | if (status) { |
| 106 | *status = lStatus; |
| 107 | } |
Eric Laurent | 8a77a99 | 2009-09-09 05:16:08 -0700 | [diff] [blame] | 108 | return track; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | virtual sp<IAudioRecord> openRecord( |
| 112 | pid_t pid, |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 113 | int input, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 114 | uint32_t sampleRate, |
| 115 | int format, |
| 116 | int channelCount, |
| 117 | int frameCount, |
| 118 | uint32_t flags, |
| 119 | status_t *status) |
| 120 | { |
| 121 | Parcel data, reply; |
Eric Laurent | 8a77a99 | 2009-09-09 05:16:08 -0700 | [diff] [blame] | 122 | sp<IAudioRecord> record; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 123 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 124 | data.writeInt32(pid); |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 125 | data.writeInt32(input); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 126 | data.writeInt32(sampleRate); |
| 127 | data.writeInt32(format); |
| 128 | data.writeInt32(channelCount); |
| 129 | data.writeInt32(frameCount); |
| 130 | data.writeInt32(flags); |
Eric Laurent | 8a77a99 | 2009-09-09 05:16:08 -0700 | [diff] [blame] | 131 | status_t lStatus = remote()->transact(OPEN_RECORD, data, &reply); |
| 132 | if (lStatus != NO_ERROR) { |
| 133 | LOGE("openRecord error: %s", strerror(-lStatus)); |
| 134 | } else { |
| 135 | lStatus = reply.readInt32(); |
| 136 | record = interface_cast<IAudioRecord>(reply.readStrongBinder()); |
| 137 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 138 | if (status) { |
| 139 | *status = lStatus; |
| 140 | } |
Eric Laurent | 8a77a99 | 2009-09-09 05:16:08 -0700 | [diff] [blame] | 141 | return record; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 142 | } |
| 143 | |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 144 | virtual uint32_t sampleRate(int output) const |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 145 | { |
| 146 | Parcel data, reply; |
| 147 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 148 | data.writeInt32(output); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 149 | remote()->transact(SAMPLE_RATE, data, &reply); |
| 150 | return reply.readInt32(); |
| 151 | } |
| 152 | |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 153 | virtual int channelCount(int output) const |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 154 | { |
| 155 | Parcel data, reply; |
| 156 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 157 | data.writeInt32(output); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 158 | remote()->transact(CHANNEL_COUNT, data, &reply); |
| 159 | return reply.readInt32(); |
| 160 | } |
| 161 | |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 162 | virtual int format(int output) const |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 163 | { |
| 164 | Parcel data, reply; |
| 165 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 166 | data.writeInt32(output); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 167 | remote()->transact(FORMAT, data, &reply); |
| 168 | return reply.readInt32(); |
| 169 | } |
| 170 | |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 171 | virtual size_t frameCount(int output) const |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 172 | { |
| 173 | Parcel data, reply; |
| 174 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 175 | data.writeInt32(output); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 176 | remote()->transact(FRAME_COUNT, data, &reply); |
| 177 | return reply.readInt32(); |
| 178 | } |
| 179 | |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 180 | virtual uint32_t latency(int output) const |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 181 | { |
| 182 | Parcel data, reply; |
| 183 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 184 | data.writeInt32(output); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 185 | remote()->transact(LATENCY, data, &reply); |
| 186 | return reply.readInt32(); |
| 187 | } |
| 188 | |
| 189 | virtual status_t setMasterVolume(float value) |
| 190 | { |
| 191 | Parcel data, reply; |
| 192 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 193 | data.writeFloat(value); |
| 194 | remote()->transact(SET_MASTER_VOLUME, data, &reply); |
| 195 | return reply.readInt32(); |
| 196 | } |
| 197 | |
| 198 | virtual status_t setMasterMute(bool muted) |
| 199 | { |
| 200 | Parcel data, reply; |
| 201 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 202 | data.writeInt32(muted); |
| 203 | remote()->transact(SET_MASTER_MUTE, data, &reply); |
| 204 | return reply.readInt32(); |
| 205 | } |
| 206 | |
| 207 | virtual float masterVolume() const |
| 208 | { |
| 209 | Parcel data, reply; |
| 210 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 211 | remote()->transact(MASTER_VOLUME, data, &reply); |
| 212 | return reply.readFloat(); |
| 213 | } |
| 214 | |
| 215 | virtual bool masterMute() const |
| 216 | { |
| 217 | Parcel data, reply; |
| 218 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 219 | remote()->transact(MASTER_MUTE, data, &reply); |
| 220 | return reply.readInt32(); |
| 221 | } |
| 222 | |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 223 | virtual status_t setStreamVolume(int stream, float value, int output) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 224 | { |
| 225 | Parcel data, reply; |
| 226 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 227 | data.writeInt32(stream); |
| 228 | data.writeFloat(value); |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 229 | data.writeInt32(output); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 230 | remote()->transact(SET_STREAM_VOLUME, data, &reply); |
| 231 | return reply.readInt32(); |
| 232 | } |
| 233 | |
| 234 | virtual status_t setStreamMute(int stream, bool muted) |
| 235 | { |
| 236 | Parcel data, reply; |
| 237 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 238 | data.writeInt32(stream); |
| 239 | data.writeInt32(muted); |
| 240 | remote()->transact(SET_STREAM_MUTE, data, &reply); |
| 241 | return reply.readInt32(); |
| 242 | } |
| 243 | |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 244 | virtual float streamVolume(int stream, int output) const |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 245 | { |
| 246 | Parcel data, reply; |
| 247 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 248 | data.writeInt32(stream); |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 249 | data.writeInt32(output); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 250 | remote()->transact(STREAM_VOLUME, data, &reply); |
| 251 | return reply.readFloat(); |
| 252 | } |
| 253 | |
| 254 | virtual bool streamMute(int stream) const |
| 255 | { |
| 256 | Parcel data, reply; |
| 257 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 258 | data.writeInt32(stream); |
| 259 | remote()->transact(STREAM_MUTE, data, &reply); |
| 260 | return reply.readInt32(); |
| 261 | } |
| 262 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 263 | virtual status_t setMode(int mode) |
| 264 | { |
| 265 | Parcel data, reply; |
| 266 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 267 | data.writeInt32(mode); |
| 268 | remote()->transact(SET_MODE, data, &reply); |
| 269 | return reply.readInt32(); |
| 270 | } |
| 271 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 272 | virtual status_t setMicMute(bool state) |
| 273 | { |
| 274 | Parcel data, reply; |
| 275 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 276 | data.writeInt32(state); |
| 277 | remote()->transact(SET_MIC_MUTE, data, &reply); |
| 278 | return reply.readInt32(); |
| 279 | } |
| 280 | |
| 281 | virtual bool getMicMute() const |
| 282 | { |
| 283 | Parcel data, reply; |
| 284 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 285 | remote()->transact(GET_MIC_MUTE, data, &reply); |
| 286 | return reply.readInt32(); |
| 287 | } |
| 288 | |
| 289 | virtual bool isMusicActive() const |
| 290 | { |
| 291 | Parcel data, reply; |
| 292 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 293 | remote()->transact(IS_MUSIC_ACTIVE, data, &reply); |
| 294 | return reply.readInt32(); |
| 295 | } |
| 296 | |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 297 | virtual status_t setParameters(int ioHandle, const String8& keyValuePairs) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 298 | { |
| 299 | Parcel data, reply; |
| 300 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 301 | data.writeInt32(ioHandle); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 302 | data.writeString8(keyValuePairs); |
| 303 | remote()->transact(SET_PARAMETERS, data, &reply); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 304 | return reply.readInt32(); |
| 305 | } |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 306 | |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 307 | virtual String8 getParameters(int ioHandle, const String8& keys) |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 308 | { |
| 309 | Parcel data, reply; |
| 310 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 311 | data.writeInt32(ioHandle); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 312 | data.writeString8(keys); |
| 313 | remote()->transact(GET_PARAMETERS, data, &reply); |
| 314 | return reply.readString8(); |
| 315 | } |
| 316 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 317 | virtual void registerClient(const sp<IAudioFlingerClient>& client) |
| 318 | { |
| 319 | Parcel data, reply; |
| 320 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 321 | data.writeStrongBinder(client->asBinder()); |
| 322 | remote()->transact(REGISTER_CLIENT, data, &reply); |
| 323 | } |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 324 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 325 | virtual size_t getInputBufferSize(uint32_t sampleRate, int format, int channelCount) |
| 326 | { |
| 327 | Parcel data, reply; |
| 328 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 329 | data.writeInt32(sampleRate); |
| 330 | data.writeInt32(format); |
| 331 | data.writeInt32(channelCount); |
| 332 | remote()->transact(GET_INPUTBUFFERSIZE, data, &reply); |
| 333 | return reply.readInt32(); |
| 334 | } |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 335 | |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 336 | virtual int openOutput(uint32_t *pDevices, |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 337 | uint32_t *pSamplingRate, |
| 338 | uint32_t *pFormat, |
| 339 | uint32_t *pChannels, |
| 340 | uint32_t *pLatencyMs, |
| 341 | uint32_t flags) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 342 | { |
| 343 | Parcel data, reply; |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 344 | uint32_t devices = pDevices ? *pDevices : 0; |
| 345 | uint32_t samplingRate = pSamplingRate ? *pSamplingRate : 0; |
| 346 | uint32_t format = pFormat ? *pFormat : 0; |
| 347 | uint32_t channels = pChannels ? *pChannels : 0; |
| 348 | uint32_t latency = pLatencyMs ? *pLatencyMs : 0; |
| 349 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 350 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 351 | data.writeInt32(devices); |
| 352 | data.writeInt32(samplingRate); |
| 353 | data.writeInt32(format); |
| 354 | data.writeInt32(channels); |
| 355 | data.writeInt32(latency); |
| 356 | data.writeInt32(flags); |
| 357 | remote()->transact(OPEN_OUTPUT, data, &reply); |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 358 | int output = reply.readInt32(); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 359 | LOGV("openOutput() returned output, %p", output); |
| 360 | devices = reply.readInt32(); |
| 361 | if (pDevices) *pDevices = devices; |
| 362 | samplingRate = reply.readInt32(); |
| 363 | if (pSamplingRate) *pSamplingRate = samplingRate; |
| 364 | format = reply.readInt32(); |
| 365 | if (pFormat) *pFormat = format; |
| 366 | channels = reply.readInt32(); |
| 367 | if (pChannels) *pChannels = channels; |
| 368 | latency = reply.readInt32(); |
| 369 | if (pLatencyMs) *pLatencyMs = latency; |
| 370 | return output; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 371 | } |
| 372 | |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 373 | virtual int openDuplicateOutput(int output1, int output2) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 374 | { |
| 375 | Parcel data, reply; |
| 376 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 377 | data.writeInt32(output1); |
| 378 | data.writeInt32(output2); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 379 | remote()->transact(OPEN_DUPLICATE_OUTPUT, data, &reply); |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 380 | return reply.readInt32(); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 381 | } |
| 382 | |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 383 | virtual status_t closeOutput(int output) |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 384 | { |
| 385 | Parcel data, reply; |
| 386 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 387 | data.writeInt32(output); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 388 | remote()->transact(CLOSE_OUTPUT, data, &reply); |
| 389 | return reply.readInt32(); |
| 390 | } |
| 391 | |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 392 | virtual status_t suspendOutput(int output) |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 393 | { |
| 394 | Parcel data, reply; |
| 395 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 396 | data.writeInt32(output); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 397 | remote()->transact(SUSPEND_OUTPUT, data, &reply); |
| 398 | return reply.readInt32(); |
| 399 | } |
| 400 | |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 401 | virtual status_t restoreOutput(int output) |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 402 | { |
| 403 | Parcel data, reply; |
| 404 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 405 | data.writeInt32(output); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 406 | remote()->transact(RESTORE_OUTPUT, data, &reply); |
| 407 | return reply.readInt32(); |
| 408 | } |
| 409 | |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 410 | virtual int openInput(uint32_t *pDevices, |
| 411 | uint32_t *pSamplingRate, |
| 412 | uint32_t *pFormat, |
| 413 | uint32_t *pChannels, |
| 414 | uint32_t acoustics) |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 415 | { |
| 416 | Parcel data, reply; |
| 417 | uint32_t devices = pDevices ? *pDevices : 0; |
| 418 | uint32_t samplingRate = pSamplingRate ? *pSamplingRate : 0; |
| 419 | uint32_t format = pFormat ? *pFormat : 0; |
| 420 | uint32_t channels = pChannels ? *pChannels : 0; |
| 421 | |
| 422 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 423 | data.writeInt32(devices); |
| 424 | data.writeInt32(samplingRate); |
| 425 | data.writeInt32(format); |
| 426 | data.writeInt32(channels); |
| 427 | data.writeInt32(acoustics); |
| 428 | remote()->transact(OPEN_INPUT, data, &reply); |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 429 | int input = reply.readInt32(); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 430 | devices = reply.readInt32(); |
| 431 | if (pDevices) *pDevices = devices; |
| 432 | samplingRate = reply.readInt32(); |
| 433 | if (pSamplingRate) *pSamplingRate = samplingRate; |
| 434 | format = reply.readInt32(); |
| 435 | if (pFormat) *pFormat = format; |
| 436 | channels = reply.readInt32(); |
| 437 | if (pChannels) *pChannels = channels; |
| 438 | return input; |
| 439 | } |
| 440 | |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 441 | virtual status_t closeInput(int input) |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 442 | { |
| 443 | Parcel data, reply; |
| 444 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 445 | data.writeInt32(input); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 446 | remote()->transact(CLOSE_INPUT, data, &reply); |
| 447 | return reply.readInt32(); |
| 448 | } |
| 449 | |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 450 | virtual status_t setStreamOutput(uint32_t stream, int output) |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 451 | { |
| 452 | Parcel data, reply; |
| 453 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 454 | data.writeInt32(stream); |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 455 | data.writeInt32(output); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 456 | remote()->transact(SET_STREAM_OUTPUT, data, &reply); |
| 457 | return reply.readInt32(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 458 | } |
Eric Laurent | 415f3e2 | 2009-10-21 08:14:22 -0700 | [diff] [blame^] | 459 | |
| 460 | virtual status_t setVoiceVolume(float volume) |
| 461 | { |
| 462 | Parcel data, reply; |
| 463 | data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor()); |
| 464 | data.writeFloat(volume); |
| 465 | remote()->transact(SET_VOICE_VOLUME, data, &reply); |
| 466 | return reply.readInt32(); |
| 467 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 468 | }; |
| 469 | |
| 470 | IMPLEMENT_META_INTERFACE(AudioFlinger, "android.media.IAudioFlinger"); |
| 471 | |
| 472 | // ---------------------------------------------------------------------- |
| 473 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 474 | status_t BnAudioFlinger::onTransact( |
| 475 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) |
| 476 | { |
| 477 | switch(code) { |
| 478 | case CREATE_TRACK: { |
| 479 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 480 | pid_t pid = data.readInt32(); |
| 481 | int streamType = data.readInt32(); |
| 482 | uint32_t sampleRate = data.readInt32(); |
| 483 | int format = data.readInt32(); |
| 484 | int channelCount = data.readInt32(); |
| 485 | size_t bufferCount = data.readInt32(); |
| 486 | uint32_t flags = data.readInt32(); |
| 487 | sp<IMemory> buffer = interface_cast<IMemory>(data.readStrongBinder()); |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 488 | int output = data.readInt32(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 489 | status_t status; |
| 490 | sp<IAudioTrack> track = createTrack(pid, |
| 491 | streamType, sampleRate, format, |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 492 | channelCount, bufferCount, flags, buffer, output, &status); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 493 | reply->writeInt32(status); |
| 494 | reply->writeStrongBinder(track->asBinder()); |
| 495 | return NO_ERROR; |
| 496 | } break; |
| 497 | case OPEN_RECORD: { |
| 498 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 499 | pid_t pid = data.readInt32(); |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 500 | int input = data.readInt32(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 501 | uint32_t sampleRate = data.readInt32(); |
| 502 | int format = data.readInt32(); |
| 503 | int channelCount = data.readInt32(); |
| 504 | size_t bufferCount = data.readInt32(); |
| 505 | uint32_t flags = data.readInt32(); |
| 506 | status_t status; |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 507 | sp<IAudioRecord> record = openRecord(pid, input, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 508 | sampleRate, format, channelCount, bufferCount, flags, &status); |
| 509 | reply->writeInt32(status); |
| 510 | reply->writeStrongBinder(record->asBinder()); |
| 511 | return NO_ERROR; |
| 512 | } break; |
| 513 | case SAMPLE_RATE: { |
| 514 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 515 | reply->writeInt32( sampleRate(data.readInt32()) ); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 516 | return NO_ERROR; |
| 517 | } break; |
| 518 | case CHANNEL_COUNT: { |
| 519 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 520 | reply->writeInt32( channelCount(data.readInt32()) ); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 521 | return NO_ERROR; |
| 522 | } break; |
| 523 | case FORMAT: { |
| 524 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 525 | reply->writeInt32( format(data.readInt32()) ); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 526 | return NO_ERROR; |
| 527 | } break; |
| 528 | case FRAME_COUNT: { |
| 529 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 530 | reply->writeInt32( frameCount(data.readInt32()) ); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 531 | return NO_ERROR; |
| 532 | } break; |
| 533 | case LATENCY: { |
| 534 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 535 | reply->writeInt32( latency(data.readInt32()) ); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 536 | return NO_ERROR; |
| 537 | } break; |
| 538 | case SET_MASTER_VOLUME: { |
| 539 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 540 | reply->writeInt32( setMasterVolume(data.readFloat()) ); |
| 541 | return NO_ERROR; |
| 542 | } break; |
| 543 | case SET_MASTER_MUTE: { |
| 544 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 545 | reply->writeInt32( setMasterMute(data.readInt32()) ); |
| 546 | return NO_ERROR; |
| 547 | } break; |
| 548 | case MASTER_VOLUME: { |
| 549 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 550 | reply->writeFloat( masterVolume() ); |
| 551 | return NO_ERROR; |
| 552 | } break; |
| 553 | case MASTER_MUTE: { |
| 554 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 555 | reply->writeInt32( masterMute() ); |
| 556 | return NO_ERROR; |
| 557 | } break; |
| 558 | case SET_STREAM_VOLUME: { |
| 559 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 560 | int stream = data.readInt32(); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 561 | float volume = data.readFloat(); |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 562 | int output = data.readInt32(); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 563 | reply->writeInt32( setStreamVolume(stream, volume, output) ); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 564 | return NO_ERROR; |
| 565 | } break; |
| 566 | case SET_STREAM_MUTE: { |
| 567 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 568 | int stream = data.readInt32(); |
| 569 | reply->writeInt32( setStreamMute(stream, data.readInt32()) ); |
| 570 | return NO_ERROR; |
| 571 | } break; |
| 572 | case STREAM_VOLUME: { |
| 573 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 574 | int stream = data.readInt32(); |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 575 | int output = data.readInt32(); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 576 | reply->writeFloat( streamVolume(stream, output) ); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 577 | return NO_ERROR; |
| 578 | } break; |
| 579 | case STREAM_MUTE: { |
| 580 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 581 | int stream = data.readInt32(); |
| 582 | reply->writeInt32( streamMute(stream) ); |
| 583 | return NO_ERROR; |
| 584 | } break; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 585 | case SET_MODE: { |
| 586 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 587 | int mode = data.readInt32(); |
| 588 | reply->writeInt32( setMode(mode) ); |
| 589 | return NO_ERROR; |
| 590 | } break; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 591 | case SET_MIC_MUTE: { |
| 592 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 593 | int state = data.readInt32(); |
| 594 | reply->writeInt32( setMicMute(state) ); |
| 595 | return NO_ERROR; |
| 596 | } break; |
| 597 | case GET_MIC_MUTE: { |
| 598 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 599 | reply->writeInt32( getMicMute() ); |
| 600 | return NO_ERROR; |
| 601 | } break; |
| 602 | case IS_MUSIC_ACTIVE: { |
| 603 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 604 | reply->writeInt32( isMusicActive() ); |
| 605 | return NO_ERROR; |
| 606 | } break; |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 607 | case SET_PARAMETERS: { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 608 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 609 | int ioHandle = data.readInt32(); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 610 | String8 keyValuePairs(data.readString8()); |
| 611 | reply->writeInt32(setParameters(ioHandle, keyValuePairs)); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 612 | return NO_ERROR; |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 613 | } break; |
| 614 | case GET_PARAMETERS: { |
| 615 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 616 | int ioHandle = data.readInt32(); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 617 | String8 keys(data.readString8()); |
| 618 | reply->writeString8(getParameters(ioHandle, keys)); |
| 619 | return NO_ERROR; |
| 620 | } break; |
| 621 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 622 | case REGISTER_CLIENT: { |
| 623 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 624 | sp<IAudioFlingerClient> client = interface_cast<IAudioFlingerClient>(data.readStrongBinder()); |
| 625 | registerClient(client); |
| 626 | return NO_ERROR; |
| 627 | } break; |
| 628 | case GET_INPUTBUFFERSIZE: { |
| 629 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 630 | uint32_t sampleRate = data.readInt32(); |
| 631 | int format = data.readInt32(); |
| 632 | int channelCount = data.readInt32(); |
| 633 | reply->writeInt32( getInputBufferSize(sampleRate, format, channelCount) ); |
| 634 | return NO_ERROR; |
| 635 | } break; |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 636 | case OPEN_OUTPUT: { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 637 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 638 | uint32_t devices = data.readInt32(); |
| 639 | uint32_t samplingRate = data.readInt32(); |
| 640 | uint32_t format = data.readInt32(); |
| 641 | uint32_t channels = data.readInt32(); |
| 642 | uint32_t latency = data.readInt32(); |
| 643 | uint32_t flags = data.readInt32(); |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 644 | int output = openOutput(&devices, |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 645 | &samplingRate, |
| 646 | &format, |
| 647 | &channels, |
| 648 | &latency, |
| 649 | flags); |
| 650 | LOGV("OPEN_OUTPUT output, %p", output); |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 651 | reply->writeInt32(output); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 652 | reply->writeInt32(devices); |
| 653 | reply->writeInt32(samplingRate); |
| 654 | reply->writeInt32(format); |
| 655 | reply->writeInt32(channels); |
| 656 | reply->writeInt32(latency); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 657 | return NO_ERROR; |
| 658 | } break; |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 659 | case OPEN_DUPLICATE_OUTPUT: { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 660 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 661 | int output1 = data.readInt32(); |
| 662 | int output2 = data.readInt32(); |
| 663 | reply->writeInt32(openDuplicateOutput(output1, output2)); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 664 | return NO_ERROR; |
| 665 | } break; |
| 666 | case CLOSE_OUTPUT: { |
| 667 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 668 | reply->writeInt32(closeOutput(data.readInt32())); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 669 | return NO_ERROR; |
| 670 | } break; |
| 671 | case SUSPEND_OUTPUT: { |
| 672 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 673 | reply->writeInt32(suspendOutput(data.readInt32())); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 674 | return NO_ERROR; |
| 675 | } break; |
| 676 | case RESTORE_OUTPUT: { |
| 677 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 678 | reply->writeInt32(restoreOutput(data.readInt32())); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 679 | return NO_ERROR; |
| 680 | } break; |
| 681 | case OPEN_INPUT: { |
| 682 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 683 | uint32_t devices = data.readInt32(); |
| 684 | uint32_t samplingRate = data.readInt32(); |
| 685 | uint32_t format = data.readInt32(); |
| 686 | uint32_t channels = data.readInt32(); |
| 687 | uint32_t acoutics = data.readInt32(); |
| 688 | |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 689 | int input = openInput(&devices, |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 690 | &samplingRate, |
| 691 | &format, |
| 692 | &channels, |
| 693 | acoutics); |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 694 | reply->writeInt32(input); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 695 | reply->writeInt32(devices); |
| 696 | reply->writeInt32(samplingRate); |
| 697 | reply->writeInt32(format); |
| 698 | reply->writeInt32(channels); |
| 699 | return NO_ERROR; |
| 700 | } break; |
| 701 | case CLOSE_INPUT: { |
| 702 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 703 | reply->writeInt32(closeInput(data.readInt32())); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 704 | return NO_ERROR; |
| 705 | } break; |
| 706 | case SET_STREAM_OUTPUT: { |
| 707 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 708 | uint32_t stream = data.readInt32(); |
Eric Laurent | ddb78e7 | 2009-07-28 08:44:33 -0700 | [diff] [blame] | 709 | int output = data.readInt32(); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 710 | reply->writeInt32(setStreamOutput(stream, output)); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 711 | return NO_ERROR; |
| 712 | } break; |
Eric Laurent | 415f3e2 | 2009-10-21 08:14:22 -0700 | [diff] [blame^] | 713 | case SET_VOICE_VOLUME: { |
| 714 | CHECK_INTERFACE(IAudioFlinger, data, reply); |
| 715 | float volume = data.readFloat(); |
| 716 | reply->writeInt32( setVoiceVolume(volume) ); |
| 717 | return NO_ERROR; |
| 718 | } break; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 719 | default: |
| 720 | return BBinder::onTransact(code, data, reply, flags); |
| 721 | } |
| 722 | } |
| 723 | |
| 724 | // ---------------------------------------------------------------------------- |
| 725 | |
| 726 | }; // namespace android |