diff options
-rw-r--r-- | cmds/bootanimation/audioplay.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/cmds/bootanimation/audioplay.cpp b/cmds/bootanimation/audioplay.cpp index da85a1c572a5..9b95b04149bf 100644 --- a/cmds/bootanimation/audioplay.cpp +++ b/cmds/bootanimation/audioplay.cpp @@ -20,6 +20,8 @@ #define CHATTY ALOGD #define LOG_TAG "audioplay" +#include <binder/IServiceManager.h> + #include "audioplay.h" #include <string.h> @@ -316,8 +318,13 @@ public: : Thread(false), mExampleAudioData(exampleAudioData), mExampleAudioLength(exampleAudioLength) {} + private: virtual bool threadLoop() { + if (defaultServiceManager()->checkService(String16("audio")) == nullptr) { + ALOGW("Audio service is not ready yet, ignore creating playback engine"); + return false; + } audioplay::create(mExampleAudioData, mExampleAudioLength); // Exit immediately return false; @@ -406,14 +413,14 @@ bool create(const uint8_t* exampleClipBuf, int exampleClipBufSize) { } bool playClip(const uint8_t* buf, int size) { - // Parse the WAV header - const ChunkFormat* chunkFormat; - if (!parseClipBuf(buf, size, &chunkFormat, &nextBuffer, &nextSize)) { + if (!hasPlayer()) { + ALOGE("cannot play clip %p without a player", buf); return false; } - if (!hasPlayer()) { - ALOGD("cannot play clip %p without a player", buf); + // Parse the WAV header + const ChunkFormat* chunkFormat; + if (!parseClipBuf(buf, size, &chunkFormat, &nextBuffer, &nextSize)) { return false; } @@ -438,11 +445,9 @@ bool playClip(const uint8_t* buf, int size) { void setPlaying(bool isPlaying) { if (!hasPlayer()) return; - SLresult result; - if (nullptr != bqPlayerPlay) { // set the player's state - result = (*bqPlayerPlay)->SetPlayState(bqPlayerPlay, + (*bqPlayerPlay)->SetPlayState(bqPlayerPlay, isPlaying ? SL_PLAYSTATE_PLAYING : SL_PLAYSTATE_STOPPED); } |