diff options
author | Diogo Ferreira <defer@cyngn.com> | 2014-12-04 11:26:43 +0000 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2015-10-26 16:09:10 -0700 |
commit | b2ac9d7f1d33aa795f6c3827b120f7591678ab3b (patch) | |
tree | 00bdaaf1365fc4a7c998dcaf4c47f30cf9b521db | |
parent | d869f6d3b606e68ff9c6a5944639efb72748ca7d (diff) | |
download | frameworks_base-b2ac9d7f1d33aa795f6c3827b120f7591678ab3b.zip frameworks_base-b2ac9d7f1d33aa795f6c3827b120f7591678ab3b.tar.gz frameworks_base-b2ac9d7f1d33aa795f6c3827b120f7591678ab3b.tar.bz2 |
bootanimation: Only try to shutdown the mediaplayer if it was prepared
The bootanimation tries to shutdown the mediaplayer gracefully by waiting
on an asynchronous shutdown event for 5 seconds.
If, however, there is no boot sound, that asynchronous shutdown event will
never happen and the animation will be stopped for 5 seconds before shutting
down.
Visibly, this fixes the issue where the bootanimation would simply stop near
the end for exactly 5 seconds.
Change-Id: I77f5631368c7d9b9fef7941a6278af9c36032044
-rw-r--r-- | cmds/bootanimation/BootAnimation.cpp | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/cmds/bootanimation/BootAnimation.cpp b/cmds/bootanimation/BootAnimation.cpp index 9d9b20b..e92e826 100644 --- a/cmds/bootanimation/BootAnimation.cpp +++ b/cmds/bootanimation/BootAnimation.cpp @@ -827,20 +827,22 @@ bool BootAnimation::movie() } - ALOGD("waiting for media player to complete."); - struct timespec timeout; - clock_gettime(CLOCK_REALTIME, &timeout); - timeout.tv_sec += 5; //timeout after 5s. - - pthread_mutex_lock(&mp_lock); - while (!isMPlayerCompleted) { - int err = pthread_cond_timedwait(&mp_cond, &mp_lock, &timeout); - if (err == ETIMEDOUT) { - break; + if (isMPlayerPrepared) { + ALOGD("waiting for media player to complete."); + struct timespec timeout; + clock_gettime(CLOCK_REALTIME, &timeout); + timeout.tv_sec += 5; //timeout after 5s. + + pthread_mutex_lock(&mp_lock); + while (!isMPlayerCompleted) { + int err = pthread_cond_timedwait(&mp_cond, &mp_lock, &timeout); + if (err == ETIMEDOUT) { + break; + } } + pthread_mutex_unlock(&mp_lock); + ALOGD("media player is completed."); } - pthread_mutex_unlock(&mp_lock); - ALOGD("media player is completed."); pthread_cond_destroy(&mp_cond); pthread_mutex_destroy(&mp_lock); |