blob: 26e6972fa812c3e146979ff7f2599d54e5fca797 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
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 Agopian07952722009-05-19 19:08:10 -070026#include <binder/IInterface.h>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080027#include <media/IAudioTrack.h>
28#include <media/IAudioRecord.h>
29#include <media/IAudioFlingerClient.h>
Eric Laurenta553c252009-07-17 12:17:14 -070030#include <utils/String8.h>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080031
32namespace android {
33
34// ----------------------------------------------------------------------------
35
36class IAudioFlinger : public IInterface
37{
38public:
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 Laurenta553c252009-07-17 12:17:14 -070053 void *output,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080054 status_t *status) = 0;
55
56 virtual sp<IAudioRecord> openRecord(
57 pid_t pid,
Eric Laurenta553c252009-07-17 12:17:14 -070058 void *input,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080059 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 Laurenta553c252009-07-17 12:17:14 -070069 virtual uint32_t sampleRate(void *output) const = 0;
70 virtual int channelCount(void *output) const = 0;
71 virtual int format(void *output) const = 0;
72 virtual size_t frameCount(void *output) const = 0;
73 virtual uint32_t latency(void *output) const = 0;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080074
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 Laurenta553c252009-07-17 12:17:14 -070087 virtual status_t setStreamVolume(int stream, float value, void *output) = 0;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080088 virtual status_t setStreamMute(int stream, bool muted) = 0;
89
Eric Laurenta553c252009-07-17 12:17:14 -070090 virtual float streamVolume(int stream, void *output) const = 0;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080091 virtual bool streamMute(int stream) const = 0;
92
Eric Laurenta553c252009-07-17 12:17:14 -070093 // set audio mode
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080094 virtual status_t setMode(int mode) = 0;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080095
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
Eric Laurenta553c252009-07-17 12:17:14 -0700103 virtual status_t setParameters(void *ioHandle, const String8& keyValuePairs) = 0;
104 virtual String8 getParameters(void *ioHandle, const String8& keys) = 0;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800105
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;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800111
Eric Laurenta553c252009-07-17 12:17:14 -0700112 virtual void *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 void *openDuplicateOutput(void *output1, void *output2) = 0;
119 virtual status_t closeOutput(void *output) = 0;
120 virtual status_t suspendOutput(void *output) = 0;
121 virtual status_t restoreOutput(void *output) = 0;
122
123 virtual void *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(void *input) = 0;
129
130 virtual status_t setStreamOutput(uint32_t stream, void *output) = 0;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800131};
132
133
134// ----------------------------------------------------------------------------
135
136class BnAudioFlinger : public BnInterface<IAudioFlinger>
137{
138public:
139 virtual status_t onTransact( uint32_t code,
140 const Parcel& data,
141 Parcel* reply,
142 uint32_t flags = 0);
143};
144
145// ----------------------------------------------------------------------------
146
147}; // namespace android
148
149#endif // ANDROID_IAUDIOFLINGER_H