summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Hung <hunga@google.com>2015-06-08 13:26:10 -0700
committerAndy Hung <hunga@google.com>2015-06-18 14:38:32 -0700
commit1f1db8356b599bc40703c907fb69e6e539343532 (patch)
treebee3a3cc00e5577a7d847871e77f9d3712c92d25
parentbd974011599b6d4ff47c1cee36d617f191dc0c2f (diff)
downloadframeworks_av-1f1db8356b599bc40703c907fb69e6e539343532.zip
frameworks_av-1f1db8356b599bc40703c907fb69e6e539343532.tar.gz
frameworks_av-1f1db8356b599bc40703c907fb69e6e539343532.tar.bz2
Fix AudioTrack comments relating to use of restoreTrack_l()
Bug: 21699132 Change-Id: Ib0d029a5e28676aeffbbbafc88c52a17367a413c
-rw-r--r--include/media/AudioTrack.h6
-rw-r--r--media/libmedia/AudioTrack.cpp12
2 files changed, 14 insertions, 4 deletions
diff --git a/include/media/AudioTrack.h b/include/media/AudioTrack.h
index c0bc516..b897f2a 100644
--- a/include/media/AudioTrack.h
+++ b/include/media/AudioTrack.h
@@ -644,6 +644,12 @@ public:
* BAD_VALUE size is invalid
* WOULD_BLOCK when obtainBuffer() returns same, or
* AudioTrack was stopped during the write
+ * DEAD_OBJECT when AudioFlinger dies or the output device changes and
+ * the track cannot be automatically restored.
+ * The application needs to recreate the AudioTrack
+ * because the audio device changed or AudioFlinger died.
+ * This typically occurs for direct or offload tracks
+ * or if mDoNotReconnect is true.
* or any other error code returned by IAudioTrack::start() or restoreTrack_l().
* Default behavior is to only return when all data has been transferred. Set 'blocking' to
* false for the method to return immediately without waiting to try multiple times to write
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp
index 81ae6d7..949bc21 100644
--- a/media/libmedia/AudioTrack.cpp
+++ b/media/libmedia/AudioTrack.cpp
@@ -986,15 +986,18 @@ status_t AudioTrack::getPosition(uint32_t *position)
}
if (mOutput != AUDIO_IO_HANDLE_NONE) {
- uint32_t halFrames;
- AudioSystem::getRenderPosition(mOutput, &halFrames, &dspFrames);
+ uint32_t halFrames; // actually unused
+ (void) AudioSystem::getRenderPosition(mOutput, &halFrames, &dspFrames);
+ // FIXME: on getRenderPosition() error, we return OK with frame position 0.
}
// FIXME: dspFrames may not be zero in (mState == STATE_STOPPED || mState == STATE_FLUSHED)
// due to hardware latency. We leave this behavior for now.
*position = dspFrames;
} else {
if (mCblk->mFlags & CBLK_INVALID) {
- restoreTrack_l("getPosition");
+ (void) restoreTrack_l("getPosition");
+ // FIXME: for compatibility with the Java API we ignore the restoreTrack_l()
+ // error here (e.g. DEAD_OBJECT) and return OK with the last recorded server position.
}
// IAudioTrack::stop() isn't synchronous; we don't know when presentation completes
@@ -2080,7 +2083,8 @@ status_t AudioTrack::restoreTrack_l(const char *from)
AudioSystem::clearAudioConfigCache();
if (isOffloadedOrDirect_l() || mDoNotReconnect) {
- // FIXME re-creation of offloaded tracks is not yet implemented
+ // FIXME re-creation of offloaded and direct tracks is not yet implemented;
+ // reconsider enabling for linear PCM encodings when position can be preserved.
return DEAD_OBJECT;
}