blob: 101440322cfb34e5979011d7ba8c73adedb92d27 [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>
John Grossman4ff14ba2012-02-08 16:37:41 -080027#include <utils/LinearTransform.h>
Richard Fitzgeraldad3af332013-03-25 16:54:37 +000028#include <utils/String8.h>
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080029
30namespace android {
31
32// ----------------------------------------------------------------------------
33
34class IAudioTrack : public IInterface
35{
Glenn Kastene53b9ea2012-03-12 16:29:55 -070036public:
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080037 DECLARE_META_INTERFACE(AudioTrack);
38
Glenn Kasten10995862012-01-03 14:50:23 -080039 /* Get this track's control block */
40 virtual sp<IMemory> getCblk() const = 0;
41
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080042 /* After it's created the track is not active. Call start() to
Glenn Kasten3acbd052012-02-28 10:39:56 -080043 * make it active.
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080044 */
Glenn Kasten3acbd052012-02-28 10:39:56 -080045 virtual status_t start() = 0;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080046
47 /* Stop a track. If set, the callback will cease being called and
Glenn Kastene53b9ea2012-03-12 16:29:55 -070048 * obtainBuffer will return an error. Buffers that are already released
Glenn Kasten99e53b82012-01-19 08:59:58 -080049 * will continue to be processed, unless/until flush() is called.
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080050 */
51 virtual void stop() = 0;
52
Glenn Kasten99e53b82012-01-19 08:59:58 -080053 /* Flush a stopped or paused track. All pending/released buffers are discarded.
54 * This function has no effect if the track is not stopped or paused.
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080055 */
56 virtual void flush() = 0;
57
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080058 /* Pause a track. If set, the callback will cease being called and
Glenn Kastene53b9ea2012-03-12 16:29:55 -070059 * obtainBuffer will return an error. Buffers that are already released
Glenn Kasten99e53b82012-01-19 08:59:58 -080060 * will continue to be processed, unless/until flush() is called.
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080061 */
62 virtual void pause() = 0;
63
Eric Laurentbe916aa2010-06-01 23:49:17 -070064 /* Attach track auxiliary output to specified effect. Use effectId = 0
65 * to detach track from effect.
66 */
67 virtual status_t attachAuxEffect(int effectId) = 0;
68
John Grossman4ff14ba2012-02-08 16:37:41 -080069
70 /* Allocate a shared memory buffer suitable for holding timed audio
71 samples */
72 virtual status_t allocateTimedBuffer(size_t size,
73 sp<IMemory>* buffer) = 0;
74
75 /* Queue a buffer obtained via allocateTimedBuffer for playback at the given
76 timestamp */
77 virtual status_t queueTimedBuffer(const sp<IMemory>& buffer,
78 int64_t pts) = 0;
79
80 /* Define the linear transform that will be applied to the timestamps
81 given to queueTimedBuffer (which are expressed in media time).
82 Target specifies whether this transform converts media time to local time
83 or Tungsten time. The values for target are defined in AudioTrack.h */
84 virtual status_t setMediaTimeTransform(const LinearTransform& xform,
85 int target) = 0;
Richard Fitzgeraldad3af332013-03-25 16:54:37 +000086
87 /* Send parameters to the audio hardware */
88 virtual status_t setParameters(const String8& keyValuePairs) = 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