From 197eec258d04e74e6e4ab68fddd14e8c5474bc59 Mon Sep 17 00:00:00 2001 From: Steve Kondik Date: Mon, 26 Oct 2015 11:16:23 -0700 Subject: bootanimation: Fix compilation warnings Change-Id: Iaf7e66811f3cecf8b5b1fa690941489a7a07f7fd --- cmds/bootanimation/BootAnimation.cpp | 103 +++++++++++++++++------------------ cmds/bootanimation/BootAnimation.h | 5 +- 2 files changed, 53 insertions(+), 55 deletions(-) (limited to 'cmds') diff --git a/cmds/bootanimation/BootAnimation.cpp b/cmds/bootanimation/BootAnimation.cpp index 5c60008..64208d9 100644 --- a/cmds/bootanimation/BootAnimation.cpp +++ b/cmds/bootanimation/BootAnimation.cpp @@ -94,7 +94,7 @@ static bool isMPlayerCompleted = false; class MPlayerListener : public MediaPlayerListener { - void notify(int msg, int ext1, int ext2, const Parcel *obj) + void notify(int msg, int /*ext1*/, int /*ext2*/, const Parcel * /*obj*/) { switch (msg) { case MEDIA_NOP: // interface test message @@ -117,12 +117,12 @@ class MPlayerListener : public MediaPlayerListener } }; -static long getFreeMemory(void) +static unsigned long getFreeMemory(void) { int fd = open("/proc/meminfo", O_RDONLY); const char* const sums[] = { "MemFree:", "Cached:", NULL }; - const int sumsLen[] = { strlen("MemFree:"), strlen("Cached:"), 0 }; - int num = 2; + const size_t sumsLen[] = { strlen("MemFree:"), strlen("Cached:"), 0 }; + unsigned int num = 2; if (fd < 0) { ALOGW("Unable to open /proc/meminfo"); @@ -140,7 +140,7 @@ static long getFreeMemory(void) buffer[len] = 0; size_t numFound = 0; - long mem = 0; + unsigned long mem = 0; char* p = buffer; while (*p && numFound < num) { @@ -894,9 +894,9 @@ bool BootAnimation::movie() return false; } -char *BootAnimation::getAnimationFileName(ImageID image) +const char *BootAnimation::getAnimationFileName(ImageID image) { - char *fileName[2][3] = { { OEM_BOOTANIMATION_FILE, + const char *fileName[2][3] = { { OEM_BOOTANIMATION_FILE, SYSTEM_BOOTANIMATION_FILE, SYSTEM_ENCRYPTED_BOOTANIMATION_FILE }, { OEM_SHUTDOWN_ANIMATION_FILE, @@ -920,13 +920,13 @@ char *BootAnimation::getAnimationFileName(ImageID image) return fileName[state][image]; } -char *BootAnimation::getBootRingtoneFileName(ImageID image) +const char *BootAnimation::getBootRingtoneFileName(ImageID image) { if (image == IMG_ENC) { return NULL; } - char *fileName[2][2] = { { OEM_BOOT_MUSIC_FILE, + const char *fileName[2][2] = { { OEM_BOOT_MUSIC_FILE, SYSTEM_BOOT_MUSIC_FILE }, { OEM_SHUTDOWN_MUSIC_FILE, SYSTEM_SHUTDOWN_MUSIC_FILE } }; @@ -937,6 +937,46 @@ char *BootAnimation::getBootRingtoneFileName(ImageID image) return fileName[state][image]; } +static void* playMusic(void* arg) +{ + int index = 0; + char *fileName = (char *)arg; + sp mp = new MediaPlayer(); + sp mListener = new MPlayerListener(); + if (mp != NULL) { + ALOGD("starting to play %s", fileName); + mp->setListener(mListener); + + if (mp->setDataSource(NULL, fileName, NULL) == NO_ERROR) { + mp->setAudioStreamType(AUDIO_STREAM_ENFORCED_AUDIBLE); + mp->prepare(); + } else { + ALOGE("failed to setDataSource for %s", fileName); + return NULL; + } + + //waiting for media player is prepared. + pthread_mutex_lock(&mp_lock); + while (!isMPlayerPrepared) { + pthread_cond_wait(&mp_cond, &mp_lock); + } + pthread_mutex_unlock(&mp_lock); + + audio_devices_t device = AudioSystem::getDevicesForStream(AUDIO_STREAM_ENFORCED_AUDIBLE); + AudioSystem::initStreamVolume(AUDIO_STREAM_ENFORCED_AUDIBLE,0,7); + AudioSystem::setStreamVolumeIndex(AUDIO_STREAM_ENFORCED_AUDIBLE, 7, device); + + AudioSystem::getStreamVolumeIndex(AUDIO_STREAM_ENFORCED_AUDIBLE, &index, device); + if (index != 0) { + ALOGD("playing %s", fileName); + mp->seekTo(0); + mp->start(); + } else { + ALOGW("current volume is zero."); + } + } + return NULL; +} void BootAnimation::playBackgroundMusic(void) { @@ -959,7 +999,7 @@ void BootAnimation::playBackgroundMusic(void) fclose(fp); - char *fileName; + const char *fileName; if (((fileName = getBootRingtoneFileName(IMG_DATA)) != NULL && access(fileName, R_OK) == 0) || ((fileName = getBootRingtoneFileName(IMG_SYS)) != NULL && access(fileName, R_OK) == 0)) { @@ -981,47 +1021,6 @@ bool BootAnimation::checkBootState(void) return ret; } -void* playMusic(void* arg) -{ - int index = 0; - char *fileName = (char *)arg; - sp mp = new MediaPlayer(); - sp mListener = new MPlayerListener(); - if (mp != NULL) { - ALOGD("starting to play %s", fileName); - mp->setListener(mListener); - - if (mp->setDataSource(NULL, fileName, NULL) == NO_ERROR) { - mp->setAudioStreamType(AUDIO_STREAM_ENFORCED_AUDIBLE); - mp->prepare(); - } else { - ALOGE("failed to setDataSource for %s", fileName); - return NULL; - } - - //waiting for media player is prepared. - pthread_mutex_lock(&mp_lock); - while (!isMPlayerPrepared) { - pthread_cond_wait(&mp_cond, &mp_lock); - } - pthread_mutex_unlock(&mp_lock); - - audio_devices_t device = AudioSystem::getDevicesForStream(AUDIO_STREAM_ENFORCED_AUDIBLE); - AudioSystem::initStreamVolume(AUDIO_STREAM_ENFORCED_AUDIBLE,0,7); - AudioSystem::setStreamVolumeIndex(AUDIO_STREAM_ENFORCED_AUDIBLE, 7, device); - - AudioSystem::getStreamVolumeIndex(AUDIO_STREAM_ENFORCED_AUDIBLE, &index, device); - if (index != 0) { - ALOGD("playing %s", fileName); - mp->seekTo(0); - mp->start(); - } else { - ALOGW("current volume is zero."); - } - } - return NULL; -} // --------------------------------------------------------------------------- -} -; // namespace android +}; // namespace android diff --git a/cmds/bootanimation/BootAnimation.h b/cmds/bootanimation/BootAnimation.h index 09ea484..5bc1e8a 100644 --- a/cmds/bootanimation/BootAnimation.h +++ b/cmds/bootanimation/BootAnimation.h @@ -94,8 +94,8 @@ private: bool movie(); enum ImageID { IMG_DATA = 0, IMG_SYS = 1, IMG_ENC = 2 }; - char *getAnimationFileName(ImageID image); - char *getBootRingtoneFileName(ImageID image); + const char *getAnimationFileName(ImageID image); + const char *getBootRingtoneFileName(ImageID image); void playBackgroundMusic(); bool checkBootState(); void checkExit(); @@ -115,7 +115,6 @@ private: ZipFileRO *mZip; }; -static void* playMusic(void* arg); // --------------------------------------------------------------------------- }; // namespace android -- cgit v1.1