The Android Open Source Project | 2729ea9 | 2008-10-21 07:00:00 -0700 | [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> |
| 26 | #include <utils/IInterface.h> |
| 27 | #include <media/IAudioTrack.h> |
| 28 | #include <media/IAudioRecord.h> |
| 29 | |
| 30 | |
| 31 | namespace android { |
| 32 | |
| 33 | // ---------------------------------------------------------------------------- |
| 34 | |
| 35 | class IAudioFlinger : public IInterface |
| 36 | { |
| 37 | public: |
| 38 | DECLARE_META_INTERFACE(AudioFlinger); |
| 39 | |
| 40 | /* create an audio track and registers it with AudioFlinger. |
| 41 | * return null if the track cannot be created. |
| 42 | */ |
| 43 | virtual sp<IAudioTrack> createTrack( |
| 44 | pid_t pid, |
| 45 | int streamType, |
| 46 | uint32_t sampleRate, |
| 47 | int format, |
| 48 | int channelCount, |
| 49 | int bufferCount, |
| 50 | uint32_t flags) = 0; |
| 51 | |
| 52 | virtual sp<IAudioRecord> openRecord( |
| 53 | pid_t pid, |
| 54 | int streamType, |
| 55 | uint32_t sampleRate, |
| 56 | int format, |
| 57 | int channelCount, |
| 58 | int bufferCount, |
| 59 | uint32_t flags) = 0; |
| 60 | |
| 61 | /* query the audio hardware state. This state never changes, |
| 62 | * and therefore can be cached. |
| 63 | */ |
| 64 | virtual uint32_t sampleRate() const = 0; |
| 65 | virtual int channelCount() const = 0; |
| 66 | virtual int format() const = 0; |
| 67 | virtual size_t frameCount() const = 0; |
| 68 | |
| 69 | /* set/get the audio hardware state. This will probably be used by |
| 70 | * the preference panel, mostly. |
| 71 | */ |
| 72 | virtual status_t setMasterVolume(float value) = 0; |
| 73 | virtual status_t setMasterMute(bool muted) = 0; |
| 74 | |
| 75 | virtual float masterVolume() const = 0; |
| 76 | virtual bool masterMute() const = 0; |
| 77 | |
| 78 | /* set/get stream type state. This will probably be used by |
| 79 | * the preference panel, mostly. |
| 80 | */ |
| 81 | virtual status_t setStreamVolume(int stream, float value) = 0; |
| 82 | virtual status_t setStreamMute(int stream, bool muted) = 0; |
| 83 | |
| 84 | virtual float streamVolume(int stream) const = 0; |
| 85 | virtual bool streamMute(int stream) const = 0; |
| 86 | |
| 87 | // set/get audio routing |
| 88 | virtual status_t setRouting(int mode, uint32_t routes, uint32_t mask) = 0; |
| 89 | virtual uint32_t getRouting(int mode) const = 0; |
| 90 | |
| 91 | // set/get audio mode |
| 92 | virtual status_t setMode(int mode) = 0; |
| 93 | virtual int getMode() const = 0; |
| 94 | |
| 95 | // mic mute/state |
| 96 | virtual status_t setMicMute(bool state) = 0; |
| 97 | virtual bool getMicMute() const = 0; |
| 98 | |
| 99 | // is a music stream active? |
| 100 | virtual bool isMusicActive() const = 0; |
| 101 | |
| 102 | // pass a generic configuration parameter to libaudio |
| 103 | // Temporary interface, do not use |
| 104 | // TODO: Replace with a more generic key:value get/set mechanism |
| 105 | virtual status_t setParameter(const char* key, const char* value) = 0; |
| 106 | }; |
| 107 | |
| 108 | |
| 109 | // ---------------------------------------------------------------------------- |
| 110 | |
| 111 | class BnAudioFlinger : public BnInterface<IAudioFlinger> |
| 112 | { |
| 113 | public: |
| 114 | virtual status_t onTransact( uint32_t code, |
| 115 | const Parcel& data, |
| 116 | Parcel* reply, |
| 117 | uint32_t flags = 0); |
| 118 | }; |
| 119 | |
| 120 | // ---------------------------------------------------------------------------- |
| 121 | |
| 122 | }; // namespace android |
| 123 | |
| 124 | #endif // ANDROID_IAUDIOFLINGER_H |