blob: 06e786d2946b6119a59f3d2ea361d02cc05d7382 [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>
Richard Fitzgeraldad3af332013-03-25 16:54:37 +000027#include <utils/String8.h>
Glenn Kasten53cec222013-08-29 09:01:02 -070028#include <media/AudioTimestamp.h>
Andy Hung9fc8b5c2017-01-24 13:36:48 -080029#include <media/VolumeShaper.h>
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080030
31namespace android {
32
33// ----------------------------------------------------------------------------
34
35class IAudioTrack : public IInterface
36{
Glenn Kastene53b9ea2012-03-12 16:29:55 -070037public:
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080038 DECLARE_META_INTERFACE(AudioTrack);
39
Glenn Kasten10995862012-01-03 14:50:23 -080040 /* Get this track's control block */
41 virtual sp<IMemory> getCblk() const = 0;
42
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080043 /* After it's created the track is not active. Call start() to
Glenn Kasten3acbd052012-02-28 10:39:56 -080044 * make it active.
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080045 */
Glenn Kasten3acbd052012-02-28 10:39:56 -080046 virtual status_t start() = 0;
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080047
48 /* Stop a track. If set, the callback will cease being called and
Glenn Kastene53b9ea2012-03-12 16:29:55 -070049 * obtainBuffer will return an error. Buffers that are already released
Glenn Kasten99e53b82012-01-19 08:59:58 -080050 * will continue to be processed, unless/until flush() is called.
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080051 */
52 virtual void stop() = 0;
53
Glenn Kasten99e53b82012-01-19 08:59:58 -080054 /* Flush a stopped or paused track. All pending/released buffers are discarded.
55 * This function has no effect if the track is not stopped or paused.
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080056 */
57 virtual void flush() = 0;
58
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080059 /* Pause a track. If set, the callback will cease being called and
Glenn Kastene53b9ea2012-03-12 16:29:55 -070060 * obtainBuffer will return an error. Buffers that are already released
Glenn Kasten99e53b82012-01-19 08:59:58 -080061 * will continue to be processed, unless/until flush() is called.
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080062 */
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
Richard Fitzgeraldad3af332013-03-25 16:54:37 +000070 /* Send parameters to the audio hardware */
71 virtual status_t setParameters(const String8& keyValuePairs) = 0;
Glenn Kasten53cec222013-08-29 09:01:02 -070072
Mikhail Naganovac917ac2018-11-28 14:03:52 -080073 /* Selects the presentation (if available) */
74 virtual status_t selectPresentation(int presentationId, int programId) = 0;
75
Glenn Kasten200092b2014-08-15 15:13:30 -070076 /* Return NO_ERROR if timestamp is valid. timestamp is undefined otherwise. */
Glenn Kasten53cec222013-08-29 09:01:02 -070077 virtual status_t getTimestamp(AudioTimestamp& timestamp) = 0;
Eric Laurent59fe0102013-09-27 18:48:26 -070078
79 /* Signal the playback thread for a change in control block */
80 virtual void signal() = 0;
Andy Hung9fc8b5c2017-01-24 13:36:48 -080081
82 /* Sets the volume shaper */
Ivan Lozano8cf3a072017-08-09 09:01:33 -070083 virtual media::VolumeShaper::Status applyVolumeShaper(
84 const sp<media::VolumeShaper::Configuration>& configuration,
85 const sp<media::VolumeShaper::Operation>& operation) = 0;
Andy Hung9fc8b5c2017-01-24 13:36:48 -080086
87 /* gets the volume shaper state */
Ivan Lozano8cf3a072017-08-09 09:01:33 -070088 virtual sp<media::VolumeShaper::State> getVolumeShaperState(int id) = 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