diff options
author | Andy Hung <hunga@google.com> | 2015-05-31 21:54:49 -0700 |
---|---|---|
committer | Andy Hung <hunga@google.com> | 2015-06-03 22:26:17 -0700 |
commit | a7f03353d5f172016f324e2a01f301cca6794152 (patch) | |
tree | 50ac6c8e46e5c60624b96008c2de4585f24364c9 /include/media/AudioTrack.h | |
parent | 4170eeec0a2dc2a9543b7e4674a43b3d2faac61d (diff) | |
download | frameworks_av-a7f03353d5f172016f324e2a01f301cca6794152.zip frameworks_av-a7f03353d5f172016f324e2a01f301cca6794152.tar.gz frameworks_av-a7f03353d5f172016f324e2a01f301cca6794152.tar.bz2 |
Compute sleep time when AudioTrack client callback returns no PCM data
Callbacks can go into a sleep-wait cycle if the client/app is unable to
deliver data. This can happen if the buffer is large, or if
the client/app cannot keep the buffer filled, or upon a stream end condition.
We improve the sleep time computation for AudioTrack PCM callbacks.
This minimizes the number of callbacks to NuPlayerRenderer.
Bug: 21198655
Change-Id: I4247798a6638def2f0d8f1b46f60323482065cb2
Diffstat (limited to 'include/media/AudioTrack.h')
-rw-r--r-- | include/media/AudioTrack.h | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/include/media/AudioTrack.h b/include/media/AudioTrack.h index 3efa74c..ec16933 100644 --- a/include/media/AudioTrack.h +++ b/include/media/AudioTrack.h @@ -43,22 +43,30 @@ public: */ enum event_type { EVENT_MORE_DATA = 0, // Request to write more data to buffer. + // This event only occurs for TRANSFER_CALLBACK. // If this event is delivered but the callback handler - // does not want to write more data, the handler must explicitly + // does not want to write more data, the handler must // ignore the event by setting frameCount to zero. - EVENT_UNDERRUN = 1, // Buffer underrun occurred. + // This might occur, for example, if the application is + // waiting for source data or is at the end of stream. + // + // For data filling, it is preferred that the callback + // does not block and instead returns a short count on + // the amount of data actually delivered + // (or 0, if no data is currently available). + EVENT_UNDERRUN = 1, // Buffer underrun occurred. This will not occur for + // static tracks. EVENT_LOOP_END = 2, // Sample loop end was reached; playback restarted from - // loop start if loop count was not 0. + // loop start if loop count was not 0 for a static track. EVENT_MARKER = 3, // Playback head is at the specified marker position // (See setMarkerPosition()). EVENT_NEW_POS = 4, // Playback head is at a new position // (See setPositionUpdatePeriod()). - EVENT_BUFFER_END = 5, // Playback head is at the end of the buffer. - // Not currently used by android.media.AudioTrack. + EVENT_BUFFER_END = 5, // Playback has completed for a static track. EVENT_NEW_IAUDIOTRACK = 6, // IAudioTrack was re-created, either due to re-routing and // voluntary invalidation by mediaserver, or mediaserver crash. EVENT_STREAM_END = 7, // Sent after all the buffers queued in AF and HW are played - // back (after stop is called) + // back (after stop is called) for an offloaded track. #if 0 // FIXME not yet implemented EVENT_NEW_TIMESTAMP = 8, // Delivered periodically and when there's a significant change // in the mapping from frame position to presentation time. |