diff --git a/media/jni/soundpool/SoundDecoder.cpp b/media/jni/soundpool/SoundDecoder.cpp index 6614fdb5af531..5ed10b0d785f1 100644 --- a/media/jni/soundpool/SoundDecoder.cpp +++ b/media/jni/soundpool/SoundDecoder.cpp @@ -107,7 +107,8 @@ void SoundDecoder::loadSound(int32_t soundID) } // Launch threads as needed. The "as needed" is weakly consistent as we release mLock. if (pendingSounds > mThreadPool->getActiveThreadCount()) { - const int32_t id __unused = mThreadPool->launch([this](int32_t id) { run(id); }); + const int32_t id = mThreadPool->launch([this](int32_t id) { run(id); }); + (void)id; // avoid clang warning -Wunused-variable -Wused-but-marked-unused ALOGV_IF(id != 0, "%s: launched thread %d", __func__, id); } } diff --git a/media/jni/soundpool/Stream.cpp b/media/jni/soundpool/Stream.cpp index a6d975851619e..e7042d0562a4c 100644 --- a/media/jni/soundpool/Stream.cpp +++ b/media/jni/soundpool/Stream.cpp @@ -203,7 +203,7 @@ void Stream::stop() void Stream::stop_l() { if (mState != IDLE) { - ALOGV("%s: track streamID: %d", __func__, (int)mStreamID); + ALOGV("%s: track(%p) streamID: %d", __func__, mAudioTrack.get(), (int)mStreamID); if (mAudioTrack != nullptr) { mAudioTrack->stop(); } @@ -232,7 +232,7 @@ Stream* Stream::playPairStream() { LOG_ALWAYS_FATAL_IF(pairStream == nullptr, "No pair stream!"); sp releaseTracks[2]; { - ALOGV("%s: track streamID: %d", __func__, (int)mStreamID); + ALOGV("%s: track streamID: %d", __func__, (int)getStreamID()); // TODO: Do we really want to force a simultaneous synchronization between // the stream and its pair? @@ -390,10 +390,10 @@ void Stream::staticCallback(int event, void* user, void* info) void Stream::callback(int event, void* info, int toggle, int tries) { - ALOGV("%s streamID %d", __func__, (int)mStreamID); int32_t activeStreamIDToRestart = 0; { std::unique_lock lock(mLock); + ALOGV("%s track(%p) streamID %d", __func__, mAudioTrack.get(), (int)mStreamID); if (mAudioTrack == nullptr) { // The AudioTrack is either with this stream or its pair. @@ -403,6 +403,7 @@ void Stream::callback(int event, void* info, int toggle, int tries) // logic here. if (tries < 3) { lock.unlock(); + ALOGV("%s streamID %d going to pair stream", __func__, (int)mStreamID); getPairStream()->callback(event, info, toggle, tries + 1); } else { ALOGW("%s streamID %d cannot find track", __func__, (int)mStreamID); @@ -449,8 +450,9 @@ void Stream::callback(int event, void* info, int toggle, int tries) void Stream::dump() const { + // TODO: consider std::try_lock() - ok for now for ALOGV. ALOGV("mPairStream=%p, mState=%d, mStreamID=%d, mSoundID=%d, mPriority=%d, mLoop=%d", - getPairStream(), mState, (int)mStreamID, mSoundID, mPriority, mLoop); + getPairStream(), mState, (int)getStreamID(), getSoundID(), mPriority, mLoop); } } // namespace android::soundpool diff --git a/media/jni/soundpool/Stream.h b/media/jni/soundpool/Stream.h index fd929210eb463..d4e5c9fe7f8ab 100644 --- a/media/jni/soundpool/Stream.h +++ b/media/jni/soundpool/Stream.h @@ -88,7 +88,7 @@ public: void resume(int32_t streamID); void autoResume(); void mute(bool muting); - void dump() const; + void dump() const NO_THREAD_SAFETY_ANALYSIS; // disable for ALOGV (see func for details). // returns the pair stream if successful, nullptr otherwise Stream* playPairStream(); diff --git a/media/jni/soundpool/StreamManager.cpp b/media/jni/soundpool/StreamManager.cpp index 9ff4254284dc9..5b6494d4947eb 100644 --- a/media/jni/soundpool/StreamManager.cpp +++ b/media/jni/soundpool/StreamManager.cpp @@ -249,7 +249,8 @@ int32_t StreamManager::queueForPlay(const std::shared_ptr &sound, } // lock if (launchThread) { - const int32_t id __unused = mThreadPool->launch([this](int32_t id) { run(id); }); + const int32_t id = mThreadPool->launch([this](int32_t id) { run(id); }); + (void)id; // avoid clang warning -Wunused-variable -Wused-but-marked-unused ALOGV_IF(id != 0, "%s: launched thread %d", __func__, id); } ALOGV("%s: returning %d", __func__, streamID); @@ -277,7 +278,8 @@ void StreamManager::moveToRestartQueue( sanityCheckQueue_l(); } if (restart) { - const int32_t id __unused = mThreadPool->launch([this](int32_t id) { run(id); }); + const int32_t id = mThreadPool->launch([this](int32_t id) { run(id); }); + (void)id; // avoid clang warning -Wunused-variable -Wused-but-marked-unused ALOGV_IF(id != 0, "%s: launched thread %d", __func__, id); } }