Skip to content

Commit

Permalink
added audio to the bootanimation - credit Team Bamf
Browse files Browse the repository at this point in the history
  • Loading branch information
kejar31 committed Apr 4, 2012
1 parent baa008f commit 472dc46
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
3 changes: 2 additions & 1 deletion cmds/bootanimation/Android.mk
Expand Up @@ -15,7 +15,8 @@ LOCAL_SHARED_LIBRARIES := \
libskia \
libEGL \
libGLESv1_CM \
libgui
libgui \
libmedia

LOCAL_C_INCLUDES := \
$(call include-path-for, corecg graphics)
Expand Down
31 changes: 28 additions & 3 deletions cmds/bootanimation/BootAnimation.cpp
Expand Up @@ -45,6 +45,8 @@
#include <core/SkStream.h>
#include <images/SkImageDecoder.h>

#include <media/mediaplayer.h>

#include <GLES/gl.h>
#include <GLES/glext.h>
#include <EGL/eglext.h>
Expand Down Expand Up @@ -369,6 +371,30 @@ bool BootAnimation::android()

bool BootAnimation::movie()
{

char bootenabled[PROPERTY_VALUE_MAX];
char bootsound[PROPERTY_VALUE_MAX];
char bootvolume[PROPERTY_VALUE_MAX];
property_get("persist.sys.boot_enabled", bootenabled, "1");
property_get("persist.sys.boot_sound", bootsound, "1");
property_get("persist.sys.boot_volume", bootvolume, "0.2");

bool bootEnabled = atoi(bootenabled) != 0;
bool enableSound = atoi(bootsound) != 0;
float bootVolume = strtof(bootvolume, NULL);

if(!bootEnabled) {
return false;
}

if(enableSound){
sp<MediaPlayer> mediaplay = new MediaPlayer();
mediaplay->setDataSource ("/system/media/boot_audio.mp3", NULL);
mediaplay->setVolume (bootVolume, bootVolume);
mediaplay->prepare();
mediaplay->start();
}

ZipFileRO& zip(mZip);

size_t numEntries = zip.getNumEntries();
Expand Down Expand Up @@ -467,12 +493,11 @@ bool BootAnimation::movie()

Region clearReg(Rect(mWidth, mHeight));
clearReg.subtractSelf(Rect(xc, yc, xc+animation.width, yc+animation.height));

for (int i=0 ; i<pcount && !exitPending() ; i++) {
const Animation::Part& part(animation.parts[i]);
const size_t fcount = part.frames.size();
glBindTexture(GL_TEXTURE_2D, 0);

glBindTexture(GL_TEXTURE_2D, 0);
for (int r=0 ; !part.count || r<part.count ; r++) {
for (int j=0 ; j<fcount && !exitPending(); j++) {
const Animation::Frame& frame(part.frames[j]);
Expand Down
4 changes: 4 additions & 0 deletions cmds/bootanimation/BootAnimation.h
Expand Up @@ -26,6 +26,8 @@
#include <surfaceflinger/ISurfaceComposer.h>
#include <surfaceflinger/SurfaceComposerClient.h>

#include <media/mediaplayer.h>

#include <EGL/egl.h>
#include <GLES/gl.h>

Expand All @@ -44,6 +46,7 @@ class BootAnimation : public Thread, public IBinder::DeathRecipient
virtual ~BootAnimation();

sp<SurfaceComposerClient> session() const;
sp<MediaPlayer> mediaplay;

private:
virtual bool threadLoop();
Expand Down Expand Up @@ -93,6 +96,7 @@ class BootAnimation : public Thread, public IBinder::DeathRecipient
EGLDisplay mSurface;
sp<SurfaceControl> mFlingerSurfaceControl;
sp<Surface> mFlingerSurface;

bool mAndroidAnimation;
ZipFileRO mZip;
};
Expand Down
1 change: 1 addition & 0 deletions cmds/bootanimation/bootanimation_main.cpp
Expand Up @@ -26,6 +26,7 @@
#include <utils/threads.h>

#include <surfaceflinger/ISurfaceComposer.h>
#include <media/mediaplayer.h>

#if defined(HAVE_PTHREADS)
# include <pthread.h>
Expand Down

0 comments on commit 472dc46

Please sign in to comment.