AudioTrack.h revision 083d1c1492d496960d5b28f4664ff02101736677
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_AUDIOTRACK_H 18#define ANDROID_AUDIOTRACK_H 19 20#include <stdint.h> 21#include <sys/types.h> 22 23#include <media/IAudioFlinger.h> 24#include <media/IAudioTrack.h> 25#include <media/AudioSystem.h> 26 27#include <utils/RefBase.h> 28#include <utils/Errors.h> 29#include <binder/IInterface.h> 30#include <binder/IMemory.h> 31#include <cutils/sched_policy.h> 32#include <utils/threads.h> 33 34namespace android { 35 36// ---------------------------------------------------------------------------- 37 38class audio_track_cblk_t; 39 40// ---------------------------------------------------------------------------- 41 42class AudioTrack : virtual public RefBase 43{ 44public: 45 enum channel_index { 46 MONO = 0, 47 LEFT = 0, 48 RIGHT = 1 49 }; 50 51 /* Events used by AudioTrack callback function (audio_track_cblk_t). 52 * Keep in sync with frameworks/base/media/java/android/media/AudioTrack.java NATIVE_EVENT_*. 53 */ 54 enum event_type { 55 EVENT_MORE_DATA = 0, // Request to write more data to buffer. 56 // If this event is delivered but the callback handler 57 // does not want to write more data, the handler must explicitly 58 // ignore the event by setting frameCount to zero. 59 EVENT_UNDERRUN = 1, // Buffer underrun occurred. 60 EVENT_LOOP_END = 2, // Sample loop end was reached; playback restarted from 61 // loop start if loop count was not 0. 62 EVENT_MARKER = 3, // Playback head is at the specified marker position 63 // (See setMarkerPosition()). 64 EVENT_NEW_POS = 4, // Playback head is at a new position 65 // (See setPositionUpdatePeriod()). 66 EVENT_BUFFER_END = 5 // Playback head is at the end of the buffer. 67 }; 68 69 /* Client should declare Buffer on the stack and pass address to obtainBuffer() 70 * and releaseBuffer(). See also callback_t for EVENT_MORE_DATA. 71 */ 72 73 class Buffer 74 { 75 public: 76 size_t frameCount; // number of sample frames corresponding to size; 77 // on input it is the number of frames desired, 78 // on output is the number of frames actually filled 79 80 size_t size; // input/output in byte units 81 union { 82 void* raw; 83 short* i16; // signed 16-bit 84 int8_t* i8; // unsigned 8-bit, offset by 0x80 85 }; 86 }; 87 88 89 /* As a convenience, if a callback is supplied, a handler thread 90 * is automatically created with the appropriate priority. This thread 91 * invokes the callback when a new buffer becomes available or various conditions occur. 92 * Parameters: 93 * 94 * event: type of event notified (see enum AudioTrack::event_type). 95 * user: Pointer to context for use by the callback receiver. 96 * info: Pointer to optional parameter according to event type: 97 * - EVENT_MORE_DATA: pointer to AudioTrack::Buffer struct. The callback must not write 98 * more bytes than indicated by 'size' field and update 'size' if fewer bytes are 99 * written. 100 * - EVENT_UNDERRUN: unused. 101 * - EVENT_LOOP_END: pointer to an int indicating the number of loops remaining. 102 * - EVENT_MARKER: pointer to an uint32_t containing the marker position in frames. 103 * - EVENT_NEW_POS: pointer to an uint32_t containing the new position in frames. 104 * - EVENT_BUFFER_END: unused. 105 */ 106 107 typedef void (*callback_t)(int event, void* user, void *info); 108 109 /* Returns the minimum frame count required for the successful creation of 110 * an AudioTrack object. 111 * Returned status (from utils/Errors.h) can be: 112 * - NO_ERROR: successful operation 113 * - NO_INIT: audio server or audio hardware not initialized 114 */ 115 116 static status_t getMinFrameCount(size_t* frameCount, 117 audio_stream_type_t streamType = AUDIO_STREAM_DEFAULT, 118 uint32_t sampleRate = 0); 119 120 /* Constructs an uninitialized AudioTrack. No connection with 121 * AudioFlinger takes place. Use set() after this. 122 */ 123 AudioTrack(); 124 125 /* Creates an AudioTrack object and registers it with AudioFlinger. 126 * Once created, the track needs to be started before it can be used. 127 * Unspecified values are set to appropriate default values. 128 * With this constructor, the track is configured for streaming mode. 129 * Data to be rendered is supplied by write() or by the callback EVENT_MORE_DATA. 130 * Intermixing a combination of write() and non-ignored EVENT_MORE_DATA is deprecated. 131 * 132 * Parameters: 133 * 134 * streamType: Select the type of audio stream this track is attached to 135 * (e.g. AUDIO_STREAM_MUSIC). 136 * sampleRate: Track sampling rate in Hz. 137 * format: Audio format (e.g AUDIO_FORMAT_PCM_16_BIT for signed 138 * 16 bits per sample). 139 * channelMask: Channel mask. 140 * frameCount: Minimum size of track PCM buffer in frames. This defines the 141 * application's contribution to the 142 * latency of the track. The actual size selected by the AudioTrack could be 143 * larger if the requested size is not compatible with current audio HAL 144 * configuration. Zero means to use a default value. 145 * flags: See comments on audio_output_flags_t in <system/audio.h>. 146 * cbf: Callback function. If not null, this function is called periodically 147 * to provide new data and inform of marker, position updates, etc. 148 * user: Context for use by the callback receiver. 149 * notificationFrames: The callback function is called each time notificationFrames PCM 150 * frames have been consumed from track input buffer. 151 * sessionId: Specific session ID, or zero to use default. 152 * threadCanCallJava: Whether callbacks are made from an attached thread and thus can call JNI. 153 * If not present in parameter list, then fixed at false. 154 */ 155 156 AudioTrack( audio_stream_type_t streamType, 157 uint32_t sampleRate = 0, 158 audio_format_t format = AUDIO_FORMAT_DEFAULT, 159 audio_channel_mask_t channelMask = 0, 160 int frameCount = 0, 161 audio_output_flags_t flags = AUDIO_OUTPUT_FLAG_NONE, 162 callback_t cbf = NULL, 163 void* user = NULL, 164 int notificationFrames = 0, 165 int sessionId = 0); 166 167 /* Creates an audio track and registers it with AudioFlinger. 168 * With this constructor, the track is configured for static buffer mode. 169 * The format must not be 8-bit linear PCM. 170 * Data to be rendered is passed in a shared memory buffer 171 * identified by the argument sharedBuffer, which must be non-0. 172 * The memory should be initialized to the desired data before calling start(). 173 * The write() method is not supported in this case. 174 * It is recommended to pass a callback function to be notified of playback end by an 175 * EVENT_UNDERRUN event. 176 * FIXME EVENT_MORE_DATA still occurs; it must be ignored. 177 */ 178 179 AudioTrack( audio_stream_type_t streamType, 180 uint32_t sampleRate = 0, 181 audio_format_t format = AUDIO_FORMAT_DEFAULT, 182 audio_channel_mask_t channelMask = 0, 183 const sp<IMemory>& sharedBuffer = 0, 184 audio_output_flags_t flags = AUDIO_OUTPUT_FLAG_NONE, 185 callback_t cbf = NULL, 186 void* user = NULL, 187 int notificationFrames = 0, 188 int sessionId = 0); 189 190 /* Terminates the AudioTrack and unregisters it from AudioFlinger. 191 * Also destroys all resources associated with the AudioTrack. 192 */ 193 ~AudioTrack(); 194 195 /* Initialize an uninitialized AudioTrack. 196 * Returned status (from utils/Errors.h) can be: 197 * - NO_ERROR: successful initialization 198 * - INVALID_OPERATION: AudioTrack is already initialized 199 * - BAD_VALUE: invalid parameter (channelMask, format, sampleRate...) 200 * - NO_INIT: audio server or audio hardware not initialized 201 * If sharedBuffer is non-0, the frameCount parameter is ignored and 202 * replaced by the shared buffer's total allocated size in frame units. 203 */ 204 status_t set(audio_stream_type_t streamType = AUDIO_STREAM_DEFAULT, 205 uint32_t sampleRate = 0, 206 audio_format_t format = AUDIO_FORMAT_DEFAULT, 207 audio_channel_mask_t channelMask = 0, 208 int frameCount = 0, 209 audio_output_flags_t flags = AUDIO_OUTPUT_FLAG_NONE, 210 callback_t cbf = NULL, 211 void* user = NULL, 212 int notificationFrames = 0, 213 const sp<IMemory>& sharedBuffer = 0, 214 bool threadCanCallJava = false, 215 int sessionId = 0); 216 217 /* Result of constructing the AudioTrack. This must be checked 218 * before using any AudioTrack API (except for set()), because using 219 * an uninitialized AudioTrack produces undefined results. 220 * See set() method above for possible return codes. 221 */ 222 status_t initCheck() const { return mStatus; } 223 224 /* Returns this track's estimated latency in milliseconds. 225 * This includes the latency due to AudioTrack buffer size, AudioMixer (if any) 226 * and audio hardware driver. 227 */ 228 uint32_t latency() const { return mLatency; } 229 230 /* getters, see constructors and set() */ 231 232 audio_stream_type_t streamType() const { return mStreamType; } 233 audio_format_t format() const { return mFormat; } 234 235 /* Return frame size in bytes, which for linear PCM is channelCount * (bit depth per channel / 8). 236 * channelCount is determined from channelMask, and bit depth comes from format. 237 * For non-linear formats, the frame size is typically 1 byte. 238 */ 239 uint32_t channelCount() const { return mChannelCount; } 240 241 uint32_t frameCount() const { return mFrameCount; } 242 size_t frameSize() const { return mFrameSize; } 243 244 /* Return the static buffer specified in constructor or set(), or 0 for streaming mode */ 245 sp<IMemory> sharedBuffer() const { return mSharedBuffer; } 246 247 /* After it's created the track is not active. Call start() to 248 * make it active. If set, the callback will start being called. 249 * If the track was previously paused, volume is ramped up over the first mix buffer. 250 */ 251 void start(); 252 253 /* Stop a track. 254 * In static buffer mode, the track is stopped immediately. 255 * In streaming mode, the callback will cease being called and 256 * obtainBuffer returns STOPPED. Note that obtainBuffer() still works 257 * and will fill up buffers until the pool is exhausted. 258 * The stop does not occur immediately: any data remaining in the buffer 259 * is first drained, mixed, and output, and only then is the track marked as stopped. 260 */ 261 void stop(); 262 bool stopped() const; 263 264 /* Flush a stopped or paused track. All previously buffered data is discarded immediately. 265 * This has the effect of draining the buffers without mixing or output. 266 * Flush is intended for streaming mode, for example before switching to non-contiguous content. 267 * This function is a no-op if the track is not stopped or paused, or uses a static buffer. 268 */ 269 void flush(); 270 271 /* Pause a track. After pause, the callback will cease being called and 272 * obtainBuffer returns STOPPED. Note that obtainBuffer() still works 273 * and will fill up buffers until the pool is exhausted. 274 * Volume is ramped down over the next mix buffer following the pause request, 275 * and then the track is marked as paused. It can be resumed with ramp up by start(). 276 */ 277 void pause(); 278 279 /* Set volume for this track, mostly used for games' sound effects 280 * left and right volumes. Levels must be >= 0.0 and <= 1.0. 281 * This is the older API. New applications should use setVolume(float) when possible. 282 */ 283 status_t setVolume(float left, float right); 284 285 /* Set volume for all channels. This is the preferred API for new applications, 286 * especially for multi-channel content. 287 */ 288 status_t setVolume(float volume); 289 290 /* Set the send level for this track. An auxiliary effect should be attached 291 * to the track with attachEffect(). Level must be >= 0.0 and <= 1.0. 292 */ 293 status_t setAuxEffectSendLevel(float level); 294 void getAuxEffectSendLevel(float* level) const; 295 296 /* Set sample rate for this track in Hz, mostly used for games' sound effects 297 */ 298 status_t setSampleRate(uint32_t sampleRate); 299 300 /* Return current sample rate in Hz, or 0 if unknown */ 301 uint32_t getSampleRate() const; 302 303 /* Enables looping and sets the start and end points of looping. 304 * Only supported for static buffer mode. 305 * 306 * Parameters: 307 * 308 * loopStart: loop start expressed as the number of PCM frames played since AudioTrack start. 309 * loopEnd: loop end expressed as the number of PCM frames played since AudioTrack start. 310 * loopCount: number of loops to execute. Calling setLoop() with loopCount == 0 cancels any 311 * pending or active loop. loopCount = -1 means infinite looping. 312 * 313 * For proper operation the following condition must be respected: 314 * (loopEnd-loopStart) <= framecount() 315 */ 316 status_t setLoop(uint32_t loopStart, uint32_t loopEnd, int loopCount); 317 318 /* Sets marker position. When playback reaches the number of frames specified, a callback with 319 * event type EVENT_MARKER is called. Calling setMarkerPosition with marker == 0 cancels marker 320 * notification callback. To set a marker at a position which would compute as 0, 321 * a workaround is to the set the marker at a nearby position such as -1 or 1. 322 * If the AudioTrack has been opened with no callback function associated, the operation will 323 * fail. 324 * 325 * Parameters: 326 * 327 * marker: marker position expressed in wrapping (overflow) frame units, 328 * like the return value of getPosition(). 329 * 330 * Returned status (from utils/Errors.h) can be: 331 * - NO_ERROR: successful operation 332 * - INVALID_OPERATION: the AudioTrack has no callback installed. 333 */ 334 status_t setMarkerPosition(uint32_t marker); 335 status_t getMarkerPosition(uint32_t *marker) const; 336 337 /* Sets position update period. Every time the number of frames specified has been played, 338 * a callback with event type EVENT_NEW_POS is called. 339 * Calling setPositionUpdatePeriod with updatePeriod == 0 cancels new position notification 340 * callback. 341 * If the AudioTrack has been opened with no callback function associated, the operation will 342 * fail. 343 * Extremely small values may be rounded up to a value the implementation can support. 344 * 345 * Parameters: 346 * 347 * updatePeriod: position update notification period expressed in frames. 348 * 349 * Returned status (from utils/Errors.h) can be: 350 * - NO_ERROR: successful operation 351 * - INVALID_OPERATION: the AudioTrack has no callback installed. 352 */ 353 status_t setPositionUpdatePeriod(uint32_t updatePeriod); 354 status_t getPositionUpdatePeriod(uint32_t *updatePeriod) const; 355 356 /* Sets playback head position within AudioTrack buffer. The new position is specified 357 * in number of frames. 358 * This method must be called with the AudioTrack in paused or stopped state. 359 * Note that the actual position set is <position> modulo the AudioTrack buffer size in frames. 360 * Therefore using this method makes sense only when playing a "static" audio buffer 361 * as opposed to streaming. 362 * The getPosition() method on the other hand returns the total number of frames played since 363 * playback start. 364 * 365 * Parameters: 366 * 367 * position: New playback head position within AudioTrack buffer. 368 * 369 * Returned status (from utils/Errors.h) can be: 370 * - NO_ERROR: successful operation 371 * - INVALID_OPERATION: the AudioTrack is not stopped or paused, or is streaming mode. 372 * - BAD_VALUE: The specified position is beyond the number of frames present in AudioTrack 373 * buffer 374 */ 375 status_t setPosition(uint32_t position); 376 377 /* Return the total number of frames played since playback start. 378 * The counter will wrap (overflow) periodically, e.g. every ~27 hours at 44.1 kHz. 379 * It is reset to zero by flush(), reload(), and stop(). 380 */ 381 status_t getPosition(uint32_t *position); 382 383 /* Forces AudioTrack buffer full condition. When playing a static buffer, this method avoids 384 * rewriting the buffer before restarting playback after a stop. 385 * This method must be called with the AudioTrack in paused or stopped state. 386 * Not allowed in streaming mode. 387 * 388 * Returned status (from utils/Errors.h) can be: 389 * - NO_ERROR: successful operation 390 * - INVALID_OPERATION: the AudioTrack is not stopped or paused, or is streaming mode. 391 */ 392 status_t reload(); 393 394 /* Returns a handle on the audio output used by this AudioTrack. 395 * 396 * Parameters: 397 * none. 398 * 399 * Returned value: 400 * handle on audio hardware output 401 */ 402 audio_io_handle_t getOutput(); 403 404 /* Returns the unique session ID associated with this track. 405 * 406 * Parameters: 407 * none. 408 * 409 * Returned value: 410 * AudioTrack session ID. 411 */ 412 int getSessionId() const { return mSessionId; } 413 414 /* Attach track auxiliary output to specified effect. Use effectId = 0 415 * to detach track from effect. 416 * 417 * Parameters: 418 * 419 * effectId: effectId obtained from AudioEffect::id(). 420 * 421 * Returned status (from utils/Errors.h) can be: 422 * - NO_ERROR: successful operation 423 * - INVALID_OPERATION: the effect is not an auxiliary effect. 424 * - BAD_VALUE: The specified effect ID is invalid 425 */ 426 status_t attachAuxEffect(int effectId); 427 428 /* Obtains a buffer of "frameCount" frames. The buffer must be 429 * filled entirely, and then released with releaseBuffer(). 430 * If the track is stopped, obtainBuffer() returns 431 * STOPPED instead of NO_ERROR as long as there are buffers available, 432 * at which point NO_MORE_BUFFERS is returned. 433 * Buffers will be returned until the pool 434 * is exhausted, at which point obtainBuffer() will either block 435 * or return WOULD_BLOCK depending on the value of the "blocking" 436 * parameter. 437 * 438 * obtainBuffer() and releaseBuffer() are deprecated for direct use by applications, 439 * which should use write() or callback EVENT_MORE_DATA instead. 440 * 441 * Interpretation of waitCount: 442 * +n limits wait time to n * WAIT_PERIOD_MS, 443 * -1 causes an (almost) infinite wait time, 444 * 0 non-blocking. 445 * 446 * Buffer fields 447 * On entry: 448 * frameCount number of frames requested 449 * After error return: 450 * frameCount 0 451 * size 0 452 * raw undefined 453 * After successful return: 454 * frameCount actual number of frames available, <= number requested 455 * size actual number of bytes available 456 * raw pointer to the buffer 457 */ 458 459 enum { 460 NO_MORE_BUFFERS = 0x80000001, // same name in AudioFlinger.h, ok to be different value 461 STOPPED = 1 462 }; 463 464 status_t obtainBuffer(Buffer* audioBuffer, int32_t waitCount); 465 466 /* Release a filled buffer of "frameCount" frames for AudioFlinger to process. */ 467 void releaseBuffer(Buffer* audioBuffer); 468 469 /* As a convenience we provide a write() interface to the audio buffer. 470 * This is implemented on top of obtainBuffer/releaseBuffer. For best 471 * performance use callbacks. Returns actual number of bytes written >= 0, 472 * or one of the following negative status codes: 473 * INVALID_OPERATION AudioTrack is configured for shared buffer mode 474 * BAD_VALUE size is invalid 475 * STOPPED AudioTrack was stopped during the write 476 * NO_MORE_BUFFERS when obtainBuffer() returns same 477 * or any other error code returned by IAudioTrack::start() or restoreTrack_l(). 478 * Not supported for static buffer mode. 479 */ 480 ssize_t write(const void* buffer, size_t size); 481 482 /* 483 * Dumps the state of an audio track. 484 */ 485 status_t dump(int fd, const Vector<String16>& args) const; 486 487protected: 488 /* copying audio tracks is not allowed */ 489 AudioTrack(const AudioTrack& other); 490 AudioTrack& operator = (const AudioTrack& other); 491 492 /* a small internal class to handle the callback */ 493 class AudioTrackThread : public Thread 494 { 495 public: 496 AudioTrackThread(AudioTrack& receiver, bool bCanCallJava = false); 497 498 // Do not call Thread::requestExitAndWait() without first calling requestExit(). 499 // Thread::requestExitAndWait() is not virtual, and the implementation doesn't do enough. 500 virtual void requestExit(); 501 502 void pause(); // suspend thread from execution at next loop boundary 503 void resume(); // allow thread to execute, if not requested to exit 504 505 private: 506 friend class AudioTrack; 507 virtual bool threadLoop(); 508 AudioTrack& mReceiver; 509 ~AudioTrackThread(); 510 Mutex mMyLock; // Thread::mLock is private 511 Condition mMyCond; // Thread::mThreadExitedCondition is private 512 bool mPaused; // whether thread is currently paused 513 }; 514 515 // body of AudioTrackThread::threadLoop() 516 bool processAudioBuffer(const sp<AudioTrackThread>& thread); 517 518 // caller must hold lock on mLock for all _l methods 519 status_t createTrack_l(audio_stream_type_t streamType, 520 uint32_t sampleRate, 521 audio_format_t format, 522 size_t frameCount, 523 audio_output_flags_t flags, 524 const sp<IMemory>& sharedBuffer, 525 audio_io_handle_t output); 526 527 // can only be called when !mActive 528 void flush_l(); 529 530 status_t setLoop_l(uint32_t loopStart, uint32_t loopEnd, int loopCount); 531 audio_io_handle_t getOutput_l(); 532 status_t restoreTrack_l(audio_track_cblk_t*& cblk, bool fromStart); 533 bool stopped_l() const { return !mActive; } 534 535 sp<IAudioTrack> mAudioTrack; 536 sp<IMemory> mCblkMemory; 537 sp<AudioTrackThread> mAudioTrackThread; 538 539 float mVolume[2]; 540 float mSendLevel; 541 size_t mFrameCount; // corresponds to current IAudioTrack 542 size_t mReqFrameCount; // frame count to request the next time a new 543 // IAudioTrack is needed 544 545 audio_track_cblk_t* mCblk; // re-load after mLock.unlock() 546 547 // Starting address of buffers in shared memory. If there is a shared buffer, mBuffers 548 // is the value of pointer() for the shared buffer, otherwise mBuffers points 549 // immediately after the control block. This address is for the mapping within client 550 // address space. AudioFlinger::TrackBase::mBuffer is for the server address space. 551 void* mBuffers; 552 553 audio_format_t mFormat; // as requested by client, not forced to 16-bit 554 audio_stream_type_t mStreamType; 555 uint32_t mChannelCount; 556 audio_channel_mask_t mChannelMask; 557 558 // mFrameSize is equal to mFrameSizeAF for non-PCM or 16-bit PCM data. 559 // For 8-bit PCM data, mFrameSizeAF is 560 // twice as large because data is expanded to 16-bit before being stored in buffer. 561 size_t mFrameSize; // app-level frame size 562 size_t mFrameSizeAF; // AudioFlinger frame size 563 564 status_t mStatus; 565 uint32_t mLatency; 566 567 bool mActive; // protected by mLock 568 569 callback_t mCbf; // callback handler for events, or NULL 570 void* mUserData; // for client callback handler 571 572 // for notification APIs 573 uint32_t mNotificationFramesReq; // requested number of frames between each 574 // notification callback 575 uint32_t mNotificationFramesAct; // actual number of frames between each 576 // notification callback 577 sp<IMemory> mSharedBuffer; 578 int mLoopCount; 579 uint32_t mRemainingFrames; 580 uint32_t mMarkerPosition; // in wrapping (overflow) frame units 581 bool mMarkerReached; 582 uint32_t mNewPosition; // in frames 583 uint32_t mUpdatePeriod; // in frames 584 585 bool mFlushed; // FIXME will be made obsolete by making flush() synchronous 586 audio_output_flags_t mFlags; 587 int mSessionId; 588 int mAuxEffectId; 589 590 // When locking both mLock and mCblk->lock, must lock in this order to avoid deadlock: 591 // 1. mLock 592 // 2. mCblk->lock 593 // It is OK to lock only mCblk->lock. 594 mutable Mutex mLock; 595 596 bool mIsTimed; 597 int mPreviousPriority; // before start() 598 SchedPolicy mPreviousSchedulingGroup; 599}; 600 601class TimedAudioTrack : public AudioTrack 602{ 603public: 604 TimedAudioTrack(); 605 606 /* allocate a shared memory buffer that can be passed to queueTimedBuffer */ 607 status_t allocateTimedBuffer(size_t size, sp<IMemory>* buffer); 608 609 /* queue a buffer obtained via allocateTimedBuffer for playback at the 610 given timestamp. PTS units are microseconds on the media time timeline. 611 The media time transform (set with setMediaTimeTransform) set by the 612 audio producer will handle converting from media time to local time 613 (perhaps going through the common time timeline in the case of 614 synchronized multiroom audio case) */ 615 status_t queueTimedBuffer(const sp<IMemory>& buffer, int64_t pts); 616 617 /* define a transform between media time and either common time or 618 local time */ 619 enum TargetTimeline {LOCAL_TIME, COMMON_TIME}; 620 status_t setMediaTimeTransform(const LinearTransform& xform, 621 TargetTimeline target); 622}; 623 624}; // namespace android 625 626#endif // ANDROID_AUDIOTRACK_H 627