blob: 69703b2b003af785ec9367c4f804a53032384a96 [file] [log] [blame]
The Android Open Source Project2729ea92008-10-21 07:00:00 -07001/*
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
31namespace android {
32
33// ----------------------------------------------------------------------------
34
35class IAudioFlinger : public IInterface
36{
37public:
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,
The Android Open Source Project7b5eb022008-12-17 18:05:43 -080049 int frameCount,
50 uint32_t flags,
51 const sp<IMemory>& sharedBuffer,
52 status_t *status) = 0;
The Android Open Source Project2729ea92008-10-21 07:00:00 -070053
54 virtual sp<IAudioRecord> openRecord(
55 pid_t pid,
56 int streamType,
57 uint32_t sampleRate,
58 int format,
59 int channelCount,
The Android Open Source Project7b5eb022008-12-17 18:05:43 -080060 int frameCount,
61 uint32_t flags,
62 status_t *status) = 0;
The Android Open Source Project2729ea92008-10-21 07:00:00 -070063
64 /* query the audio hardware state. This state never changes,
65 * and therefore can be cached.
66 */
67 virtual uint32_t sampleRate() const = 0;
68 virtual int channelCount() const = 0;
69 virtual int format() const = 0;
70 virtual size_t frameCount() const = 0;
The Android Open Source Project7b5eb022008-12-17 18:05:43 -080071 virtual uint32_t latency() const = 0;
The Android Open Source Project2729ea92008-10-21 07:00:00 -070072
73 /* set/get the audio hardware state. This will probably be used by
74 * the preference panel, mostly.
75 */
76 virtual status_t setMasterVolume(float value) = 0;
77 virtual status_t setMasterMute(bool muted) = 0;
78
79 virtual float masterVolume() const = 0;
80 virtual bool masterMute() const = 0;
81
82 /* set/get stream type state. This will probably be used by
83 * the preference panel, mostly.
84 */
85 virtual status_t setStreamVolume(int stream, float value) = 0;
86 virtual status_t setStreamMute(int stream, bool muted) = 0;
87
88 virtual float streamVolume(int stream) const = 0;
89 virtual bool streamMute(int stream) const = 0;
90
91 // set/get audio routing
92 virtual status_t setRouting(int mode, uint32_t routes, uint32_t mask) = 0;
93 virtual uint32_t getRouting(int mode) const = 0;
94
95 // set/get audio mode
96 virtual status_t setMode(int mode) = 0;
97 virtual int getMode() const = 0;
98
99 // mic mute/state
100 virtual status_t setMicMute(bool state) = 0;
101 virtual bool getMicMute() const = 0;
102
103 // is a music stream active?
104 virtual bool isMusicActive() const = 0;
105
106 // pass a generic configuration parameter to libaudio
107 // Temporary interface, do not use
108 // TODO: Replace with a more generic key:value get/set mechanism
109 virtual status_t setParameter(const char* key, const char* value) = 0;
110};
111
112
113// ----------------------------------------------------------------------------
114
115class BnAudioFlinger : public BnInterface<IAudioFlinger>
116{
117public:
118 virtual status_t onTransact( uint32_t code,
119 const Parcel& data,
120 Parcel* reply,
121 uint32_t flags = 0);
122};
123
124// ----------------------------------------------------------------------------
125
126}; // namespace android
127
128#endif // ANDROID_IAUDIOFLINGER_H