blob: 7343a48a7f42e6477e4f80ef4c201869f9f1431b [file] [log] [blame]
The Android Open Source Project89fa4ad2009-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_IAUDIOTRACK_H
18#define ANDROID_IAUDIOTRACK_H
19
20#include <stdint.h>
21#include <sys/types.h>
22
23#include <utils/RefBase.h>
24#include <utils/Errors.h>
Mathias Agopian75624082009-05-19 19:08:10 -070025#include <binder/IInterface.h>
26#include <binder/IMemory.h>
Mike J. Chen500e5102011-08-15 13:28:26 -070027#include <utils/LinearTransform.h>
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080028
29namespace android {
30
31// ----------------------------------------------------------------------------
32
33class IAudioTrack : public IInterface
34{
35public:
36 DECLARE_META_INTERFACE(AudioTrack);
37
38 /* After it's created the track is not active. Call start() to
39 * make it active. If set, the callback will start being called.
40 */
41 virtual status_t start() = 0;
42
43 /* Stop a track. If set, the callback will cease being called and
44 * obtainBuffer will return an error. Buffers that are already released
45 * will be processed, unless flush() is called.
46 */
47 virtual void stop() = 0;
48
49 /* flush a stopped track. All pending buffers are discarded.
50 * This function has no effect if the track is not stoped.
51 */
52 virtual void flush() = 0;
53
54 /* mute or unmutes this track.
55 * While mutted, the callback, if set, is still called.
56 */
57 virtual void mute(bool) = 0;
58
59 /* Pause a track. If set, the callback will cease being called and
60 * obtainBuffer will return an error. Buffers that are already released
61 * will be processed, unless flush() is called.
62 */
63 virtual void pause() = 0;
64
Eric Laurentbe916aa2010-06-01 23:49:17 -070065 /* Attach track auxiliary output to specified effect. Use effectId = 0
66 * to detach track from effect.
67 */
68 virtual status_t attachAuxEffect(int effectId) = 0;
69
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080070 /* get this tracks control block */
71 virtual sp<IMemory> getCblk() const = 0;
Mike J. Chen500e5102011-08-15 13:28:26 -070072
73 /* Allocate a shared memory buffer suitable for holding timed audio
74 samples */
75 virtual status_t allocateTimedBuffer(size_t size,
76 sp<IMemory>* buffer) = 0;
77
78 /* Queue a buffer obtained via allocateTimedBuffer for playback at the given
79 timestamp */
80 virtual status_t queueTimedBuffer(const sp<IMemory>& buffer,
81 int64_t pts) = 0;
82
83 /* Define the linear transform that will be applied to the timestamps
84 given to queueTimedBuffer (which are expressed in media time).
85 Target specifies whether this transform converts media time to local time
86 or Tungsten time. The values for target are defined in AudioTrack.h */
87 virtual status_t setMediaTimeTransform(const LinearTransform& xform,
88 int target) = 0;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080089};
90
91// ----------------------------------------------------------------------------
92
93class BnAudioTrack : public BnInterface<IAudioTrack>
94{
95public:
96 virtual status_t onTransact( uint32_t code,
97 const Parcel& data,
98 Parcel* reply,
99 uint32_t flags = 0);
100};
101
102// ----------------------------------------------------------------------------
103
104}; // namespace android
105
106#endif // ANDROID_IAUDIOTRACK_H