IAudioTrack.h revision e4756fe3a387615acb63c6a05788c8db9b5786cb
1/*
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>
25#include <binder/IInterface.h>
26#include <binder/IMemory.h>
27#include <utils/LinearTransform.h>
28
29namespace android {
30
31// ----------------------------------------------------------------------------
32
33class IAudioTrack : public IInterface
34{
35public:
36    DECLARE_META_INTERFACE(AudioTrack);
37
38    /* Get this track's control block */
39    virtual sp<IMemory> getCblk() const = 0;
40
41    /* After it's created the track is not active. Call start() to
42     * make it active.
43     */
44    virtual status_t    start() = 0;
45
46    /* Stop a track. If set, the callback will cease being called and
47     * obtainBuffer will return an error. Buffers that are already released
48     * will continue to be processed, unless/until flush() is called.
49     */
50    virtual void        stop() = 0;
51
52    /* Flush a stopped or paused track. All pending/released buffers are discarded.
53     * This function has no effect if the track is not stopped or paused.
54     */
55    virtual void        flush() = 0;
56
57    /* Pause a track. If set, the callback will cease being called and
58     * obtainBuffer will return an error. Buffers that are already released
59     * will continue to be processed, unless/until flush() is called.
60     */
61    virtual void        pause() = 0;
62
63    /* Attach track auxiliary output to specified effect. Use effectId = 0
64     * to detach track from effect.
65     */
66    virtual status_t    attachAuxEffect(int effectId) = 0;
67
68
69    /* Allocate a shared memory buffer suitable for holding timed audio
70       samples */
71    virtual status_t    allocateTimedBuffer(size_t size,
72                                            sp<IMemory>* buffer) = 0;
73
74    /* Queue a buffer obtained via allocateTimedBuffer for playback at the given
75       timestamp */
76    virtual status_t    queueTimedBuffer(const sp<IMemory>& buffer,
77                                         int64_t pts) = 0;
78
79    /* Define the linear transform that will be applied to the timestamps
80       given to queueTimedBuffer (which are expressed in media time).
81       Target specifies whether this transform converts media time to local time
82       or Tungsten time. The values for target are defined in AudioTrack.h */
83    virtual status_t    setMediaTimeTransform(const LinearTransform& xform,
84                                              int target) = 0;
85};
86
87// ----------------------------------------------------------------------------
88
89class BnAudioTrack : public BnInterface<IAudioTrack>
90{
91public:
92    virtual status_t    onTransact( uint32_t code,
93                                    const Parcel& data,
94                                    Parcel* reply,
95                                    uint32_t flags = 0);
96};
97
98// ----------------------------------------------------------------------------
99
100}; // namespace android
101
102#endif // ANDROID_IAUDIOTRACK_H
103