• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <binder/IInterface.h>
27 #include <media/IAudioTrack.h>
28 #include <media/IAudioRecord.h>
29 #include <media/IAudioFlingerClient.h>
30 #include <utils/String8.h>
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,
53                                 int output,
54                                 status_t *status) = 0;
55 
56     virtual sp<IAudioRecord> openRecord(
57                                 pid_t pid,
58                                 int input,
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      */
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;
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      */
87     virtual     status_t    setStreamVolume(int stream, float value, int output) = 0;
88     virtual     status_t    setStreamMute(int stream, bool muted) = 0;
89 
90     virtual     float       streamVolume(int stream, int output) const = 0;
91     virtual     bool        streamMute(int stream) const = 0;
92 
93     // set audio mode
94     virtual     status_t    setMode(int mode) = 0;
95 
96     // mic mute/state
97     virtual     status_t    setMicMute(bool state) = 0;
98     virtual     bool        getMicMute() const = 0;
99 
100     // is a music stream active?
101     virtual     bool        isMusicActive() const = 0;
102 
103     virtual     status_t    setParameters(int ioHandle, const String8& keyValuePairs) = 0;
104     virtual     String8     getParameters(int ioHandle, const String8& keys) = 0;
105 
106     // register a current process for audio output change notifications
107     virtual void registerClient(const sp<IAudioFlingerClient>& client) = 0;
108 
109     // retrieve the audio recording buffer size
110     virtual size_t getInputBufferSize(uint32_t sampleRate, int format, int channelCount) = 0;
111 
112     virtual int openOutput(uint32_t *pDevices,
113                                     uint32_t *pSamplingRate,
114                                     uint32_t *pFormat,
115                                     uint32_t *pChannels,
116                                     uint32_t *pLatencyMs,
117                                     uint32_t flags) = 0;
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;
122 
123     virtual int openInput(uint32_t *pDevices,
124                                     uint32_t *pSamplingRate,
125                                     uint32_t *pFormat,
126                                     uint32_t *pChannels,
127                                     uint32_t acoustics) = 0;
128     virtual status_t closeInput(int input) = 0;
129 
130     virtual status_t setStreamOutput(uint32_t stream, int output) = 0;
131 
132     virtual status_t setVoiceVolume(float volume) = 0;
133 };
134 
135 
136 // ----------------------------------------------------------------------------
137 
138 class BnAudioFlinger : public BnInterface<IAudioFlinger>
139 {
140 public:
141     virtual status_t    onTransact( uint32_t code,
142                                     const Parcel& data,
143                                     Parcel* reply,
144                                     uint32_t flags = 0);
145 };
146 
147 // ----------------------------------------------------------------------------
148 
149 }; // namespace android
150 
151 #endif // ANDROID_IAUDIOFLINGER_H
152