libmediaplayerservice: offload playback support
Main change is to how recycled tracks are used for gapless
playback. If we are playing offloaded tracks that can't be
recycled we don't open a new offloaded output until we have
closed the previous one. This is because offloaded tracks
are a limited resource so we don't want to spuriously create
unnecessary instances. If the tracks cannot be recycled
this means that the formats are incompatible and so the
hardware most likely will also be unable to use the existing
output channel for the new track. If we already have the
maximum number of hardware offload channels open (which could
be only one) then creation of the next output would fail if
we attempted it while the previous output was still open.
Change-Id: I4f5958074e7ffd2e17108157fee86329506730ea
Signed-off-by: Eric Laurent <elaurent@google.com>
diff --git a/libvideoeditor/lvpp/VideoEditorPlayer.cpp b/libvideoeditor/lvpp/VideoEditorPlayer.cpp
index 3384e34..5aeba4f 100755
--- a/libvideoeditor/lvpp/VideoEditorPlayer.cpp
+++ b/libvideoeditor/lvpp/VideoEditorPlayer.cpp
@@ -468,14 +468,18 @@
return NO_ERROR;
}
-void VideoEditorPlayer::VeAudioOutput::start() {
+status_t VideoEditorPlayer::VeAudioOutput::start() {
ALOGV("start");
if (mTrack != 0) {
mTrack->setVolume(mLeftVolume, mRightVolume);
- mTrack->start();
- mTrack->getPosition(&mNumFramesWritten);
+ status_t status = mTrack->start();
+ if (status == NO_ERROR) {
+ mTrack->getPosition(&mNumFramesWritten);
+ }
+ return status;
}
+ return NO_INIT;
}
void VideoEditorPlayer::VeAudioOutput::snoopWrite(
diff --git a/libvideoeditor/lvpp/VideoEditorPlayer.h b/libvideoeditor/lvpp/VideoEditorPlayer.h
index 69323c3..ab6d731 100755
--- a/libvideoeditor/lvpp/VideoEditorPlayer.h
+++ b/libvideoeditor/lvpp/VideoEditorPlayer.h
@@ -55,7 +55,7 @@
AudioCallback cb, void *cookie, audio_output_flags_t flags,
const audio_offload_info_t *offloadInfo);
- virtual void start();
+ virtual status_t start();
virtual ssize_t write(const void* buffer, size_t size);
virtual void stop();
virtual void flush();