diff options
author | Geoffrey Pitsch <gpitsch@google.com> | 2016-07-12 14:46:19 -0400 |
---|---|---|
committer | Geoffrey Pitsch <gpitsch@google.com> | 2016-07-13 15:51:24 -0400 |
commit | a91a2d737586ebd0040129333055d8093899751b (patch) | |
tree | 0ca3a04b3397357204fc39d968a3d6968aaf52f1 /cmds/bootanimation/BootAnimation.cpp | |
parent | f6d766020f9b4d082ee38c38e6496655e1e56c61 (diff) |
Fixes delay when playing first sound in BootAnimation
audioplay is initialized with an example of the type of clip it
will play.
Also remove asserts and debug compile settings from BootAnimation.
BUG:24800792
Change-Id: Icb78489417aee0549c340c746b25e57ccdb3427e
Diffstat (limited to 'cmds/bootanimation/BootAnimation.cpp')
-rw-r--r-- | cmds/bootanimation/BootAnimation.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/cmds/bootanimation/BootAnimation.cpp b/cmds/bootanimation/BootAnimation.cpp index 4098772bba12..ebcc9ff0451f 100644 --- a/cmds/bootanimation/BootAnimation.cpp +++ b/cmds/bootanimation/BootAnimation.cpp @@ -588,7 +588,7 @@ bool BootAnimation::preloadZip(Animation& animation) return false; } - bool hasAudio = false; + Animation::Part* partWithAudio = NULL; ZipEntryRO entry; char name[ANIM_ENTRY_NAME_MAX]; while ((entry = zip->nextEntry(cookie)) != NULL) { @@ -612,10 +612,10 @@ bool BootAnimation::preloadZip(Animation& animation) if (map) { Animation::Part& part(animation.parts.editItemAt(j)); if (leaf == "audio.wav") { - hasAudio = true; // a part may have at most one audio file part.audioData = (uint8_t *)map->getDataPtr(); part.audioLength = map->getDataLength(); + partWithAudio = ∂ } else if (leaf == "trim.txt") { part.trimData.setTo((char const*)map->getDataPtr(), map->getDataLength()); @@ -666,9 +666,11 @@ bool BootAnimation::preloadZip(Animation& animation) } // Create and initialize audioplay if there is a wav file in any of the animations. - if (hasAudio) { + if (partWithAudio != NULL) { ALOGD("found audio.wav, creating playback engine"); - audioplay::create(); + if (!audioplay::create(partWithAudio->audioData, partWithAudio->audioLength)) { + return false; + } } zip->endIteration(cookie); @@ -904,7 +906,10 @@ BootAnimation::Animation* BootAnimation::loadAnimation(const String8& fn) mLoadedFiles.add(animation->fileName); parseAnimationDesc(*animation); - preloadZip(*animation); + if (!preloadZip(*animation)) { + return NULL; + } + mLoadedFiles.remove(fn); return animation; |