blob: bddd23e3461f6c7e9b33390ddcc70edc1f0a6258 [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 Laurentddb78e72009-07-28 08:44:33 -070053 int 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 Laurentddb78e72009-07-28 08:44:33 -070058 int 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 Laurentddb78e72009-07-28 08:44:33 -070069 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 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 Laurentddb78e72009-07-28 08:44:33 -070087 virtual status_t setStreamVolume(int stream, float value, int output) = 0;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080088 virtual status_t setStreamMute(int stream, bool muted) = 0;
89
Eric Laurentddb78e72009-07-28 08:44:33 -070090 virtual float streamVolume(int stream, int 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
Eric Laurent23f25cd2010-01-25 08:49:09 -0800100 // is any track active on this stream?
101 virtual bool isStreamActive(int stream) const = 0;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800102
Eric Laurentddb78e72009-07-28 08:44:33 -0700103 virtual status_t setParameters(int ioHandle, const String8& keyValuePairs) = 0;
104 virtual String8 getParameters(int ioHandle, const String8& keys) = 0;
Eric Laurent415f3e22009-10-21 08:14:22 -0700105
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800106 // register a current process for audio output change notifications
107 virtual void registerClient(const sp<IAudioFlingerClient>& client) = 0;
Eric Laurent415f3e22009-10-21 08:14:22 -0700108
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800109 // 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 Laurentddb78e72009-07-28 08:44:33 -0700112 virtual int openOutput(uint32_t *pDevices,
Eric Laurenta553c252009-07-17 12:17:14 -0700113 uint32_t *pSamplingRate,
114 uint32_t *pFormat,
115 uint32_t *pChannels,
116 uint32_t *pLatencyMs,
117 uint32_t flags) = 0;
Eric Laurentddb78e72009-07-28 08:44:33 -0700118 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 Laurenta553c252009-07-17 12:17:14 -0700122
Eric Laurentddb78e72009-07-28 08:44:33 -0700123 virtual int openInput(uint32_t *pDevices,
Eric Laurenta553c252009-07-17 12:17:14 -0700124 uint32_t *pSamplingRate,
125 uint32_t *pFormat,
126 uint32_t *pChannels,
127 uint32_t acoustics) = 0;
Eric Laurentddb78e72009-07-28 08:44:33 -0700128 virtual status_t closeInput(int input) = 0;
Eric Laurenta553c252009-07-17 12:17:14 -0700129
Eric Laurentddb78e72009-07-28 08:44:33 -0700130 virtual status_t setStreamOutput(uint32_t stream, int output) = 0;
Eric Laurent415f3e22009-10-21 08:14:22 -0700131
132 virtual status_t setVoiceVolume(float volume) = 0;
Eric Laurent0986e792010-01-19 17:37:09 -0800133 virtual status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames, int output) = 0;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800134};
135
136
137// ----------------------------------------------------------------------------
138
139class BnAudioFlinger : public BnInterface<IAudioFlinger>
140{
141public:
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