blob: 6f13fe0b52c25c300564ec78dd9bc7e21bb2073c [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>
26#include <utils/IInterface.h>
27#include <media/IAudioTrack.h>
28#include <media/IAudioRecord.h>
29#include <media/IAudioFlingerClient.h>
30
31
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,
53 status_t *status) = 0;
54
55 virtual sp<IAudioRecord> openRecord(
56 pid_t pid,
57 int streamType,
58 uint32_t sampleRate,
59 int format,
60 int channelCount,
61 int frameCount,
62 uint32_t flags,
63 status_t *status) = 0;
64
65 /* query the audio hardware state. This state never changes,
66 * and therefore can be cached.
67 */
68 virtual uint32_t sampleRate(int output) const = 0;
69 virtual int channelCount(int output) const = 0;
70 virtual int format(int output) const = 0;
71 virtual size_t frameCount(int output) const = 0;
72 virtual uint32_t latency(int output) const = 0;
73
74 /* set/get the audio hardware state. This will probably be used by
75 * the preference panel, mostly.
76 */
77 virtual status_t setMasterVolume(float value) = 0;
78 virtual status_t setMasterMute(bool muted) = 0;
79
80 virtual float masterVolume() const = 0;
81 virtual bool masterMute() const = 0;
82
83 /* set/get stream type state. This will probably be used by
84 * the preference panel, mostly.
85 */
86 virtual status_t setStreamVolume(int stream, float value) = 0;
87 virtual status_t setStreamMute(int stream, bool muted) = 0;
88
89 virtual float streamVolume(int stream) const = 0;
90 virtual bool streamMute(int stream) const = 0;
91
92 // set/get audio routing
93 virtual status_t setRouting(int mode, uint32_t routes, uint32_t mask) = 0;
94 virtual uint32_t getRouting(int mode) const = 0;
95
96 // set/get audio mode
97 virtual status_t setMode(int mode) = 0;
98 virtual int getMode() const = 0;
99
100 // mic mute/state
101 virtual status_t setMicMute(bool state) = 0;
102 virtual bool getMicMute() const = 0;
103
104 // is a music stream active?
105 virtual bool isMusicActive() const = 0;
106
107 // pass a generic configuration parameter to libaudio
108 // Temporary interface, do not use
109 // TODO: Replace with a more generic key:value get/set mechanism
110 virtual status_t setParameter(const char* key, const char* value) = 0;
111
112 // register a current process for audio output change notifications
113 virtual void registerClient(const sp<IAudioFlingerClient>& client) = 0;
114
115 // retrieve the audio recording buffer size
116 virtual size_t getInputBufferSize(uint32_t sampleRate, int format, int channelCount) = 0;
117
118 // force AudioFlinger thread out of standby
119 virtual void wakeUp() = 0;
120
121 // is A2DP output enabled
122 virtual bool isA2dpEnabled() const = 0;
123};
124
125
126// ----------------------------------------------------------------------------
127
128class BnAudioFlinger : public BnInterface<IAudioFlinger>
129{
130public:
131 virtual status_t onTransact( uint32_t code,
132 const Parcel& data,
133 Parcel* reply,
134 uint32_t flags = 0);
135};
136
137// ----------------------------------------------------------------------------
138
139}; // namespace android
140
141#endif // ANDROID_IAUDIOFLINGER_H