1 /* 2 * Copyright (C) 2020 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 package android.media; 18 19 import android.media.AudioDualMonoMode; 20 import android.media.AudioPlaybackRate; 21 import android.media.AudioTimestampInternal; 22 import android.media.SharedFileRegion; 23 import android.media.VolumeShaperConfiguration; 24 import android.media.VolumeShaperOperation; 25 import android.media.VolumeShaperState; 26 27 /** 28 * Unless otherwise noted, methods returning int expect it to be interpreted as a status_t. 29 * 30 * {@hide} 31 */ 32 interface IAudioTrack { 33 /** Get this track's control block */ getCblk()34 @nullable SharedFileRegion getCblk(); 35 36 /** 37 * After it's created the track is not active. Call start() to 38 * make it active. 39 */ start()40 int start(); 41 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 continue to be processed, unless/until flush() is called. 46 */ stop()47 void stop(); 48 49 /** 50 * Flush a stopped or paused track. All pending/released buffers are discarded. 51 * This function has no effect if the track is not stopped or paused. 52 */ flush()53 void flush(); 54 55 /** 56 * Pause a track. If set, the callback will cease being called and 57 * obtainBuffer will return an error. Buffers that are already released 58 * will continue to be processed, unless/until flush() is called. 59 */ pause()60 void pause(); 61 62 /** 63 * Attach track auxiliary output to specified effect. Use effectId = 0 64 * to detach track from effect. 65 */ attachAuxEffect(int effectId)66 int attachAuxEffect(int effectId); 67 68 /** Send parameters to the audio hardware. */ setParameters(@tf8InCpp String keyValuePairs)69 int setParameters(@utf8InCpp String keyValuePairs); 70 71 /** Selects the presentation (if available). */ selectPresentation(int presentationId, int programId)72 int selectPresentation(int presentationId, int programId); 73 74 /** Return NO_ERROR if timestamp is valid. */ getTimestamp(out AudioTimestampInternal timestamp)75 int getTimestamp(out AudioTimestampInternal timestamp); 76 77 /** Signal the playback thread for a change in control block. */ signal()78 void signal(); 79 80 /** Sets the volume shaper. Returns the volume shaper status. */ applyVolumeShaper(in VolumeShaperConfiguration configuration, in VolumeShaperOperation operation)81 int applyVolumeShaper(in VolumeShaperConfiguration configuration, 82 in VolumeShaperOperation operation); 83 84 /** Gets the volume shaper state. */ getVolumeShaperState(int id)85 @nullable VolumeShaperState getVolumeShaperState(int id); 86 87 /** 88 * Returns DualMonoMode setting associated with this AudioTrack. 89 */ getDualMonoMode()90 AudioDualMonoMode getDualMonoMode(); 91 92 /** 93 * Sets DualMonoMode setting. 94 */ setDualMonoMode(in AudioDualMonoMode mode)95 void setDualMonoMode(in AudioDualMonoMode mode); 96 97 /** 98 * Returns the AudioDescriptionMixLevel. 99 */ getAudioDescriptionMixLevel()100 float getAudioDescriptionMixLevel(); 101 102 /** 103 * Sets the AudioDescriptionMixLevel. 104 */ setAudioDescriptionMixLevel(float leveldB)105 void setAudioDescriptionMixLevel(float leveldB); 106 107 /** 108 * Returns the AudioPlaybackRate. 109 */ getPlaybackRateParameters()110 AudioPlaybackRate getPlaybackRateParameters(); 111 112 /** 113 * Sets the AudioPlaybackRate. 114 */ setPlaybackRateParameters(in AudioPlaybackRate playbackRate)115 void setPlaybackRateParameters(in AudioPlaybackRate playbackRate); 116 } 117