Merge "SoundPool: Fix verbose logging compilation" into rvc-dev

This commit is contained in:
Andy Hung
2020-06-01 21:04:33 +00:00
committed by Android (Google) Code Review
4 changed files with 13 additions and 8 deletions

View File

@@ -107,7 +107,8 @@ void SoundDecoder::loadSound(int32_t soundID)
} }
// Launch threads as needed. The "as needed" is weakly consistent as we release mLock. // Launch threads as needed. The "as needed" is weakly consistent as we release mLock.
if (pendingSounds > mThreadPool->getActiveThreadCount()) { 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); ALOGV_IF(id != 0, "%s: launched thread %d", __func__, id);
} }
} }

View File

@@ -203,7 +203,7 @@ void Stream::stop()
void Stream::stop_l() void Stream::stop_l()
{ {
if (mState != IDLE) { 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) { if (mAudioTrack != nullptr) {
mAudioTrack->stop(); mAudioTrack->stop();
} }
@@ -232,7 +232,7 @@ Stream* Stream::playPairStream() {
LOG_ALWAYS_FATAL_IF(pairStream == nullptr, "No pair stream!"); LOG_ALWAYS_FATAL_IF(pairStream == nullptr, "No pair stream!");
sp<AudioTrack> releaseTracks[2]; sp<AudioTrack> 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 // TODO: Do we really want to force a simultaneous synchronization between
// the stream and its pair? // 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) void Stream::callback(int event, void* info, int toggle, int tries)
{ {
ALOGV("%s streamID %d", __func__, (int)mStreamID);
int32_t activeStreamIDToRestart = 0; int32_t activeStreamIDToRestart = 0;
{ {
std::unique_lock lock(mLock); std::unique_lock lock(mLock);
ALOGV("%s track(%p) streamID %d", __func__, mAudioTrack.get(), (int)mStreamID);
if (mAudioTrack == nullptr) { if (mAudioTrack == nullptr) {
// The AudioTrack is either with this stream or its pair. // 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. // logic here.
if (tries < 3) { if (tries < 3) {
lock.unlock(); lock.unlock();
ALOGV("%s streamID %d going to pair stream", __func__, (int)mStreamID);
getPairStream()->callback(event, info, toggle, tries + 1); getPairStream()->callback(event, info, toggle, tries + 1);
} else { } else {
ALOGW("%s streamID %d cannot find track", __func__, (int)mStreamID); 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 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", 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 } // namespace android::soundpool

View File

@@ -88,7 +88,7 @@ public:
void resume(int32_t streamID); void resume(int32_t streamID);
void autoResume(); void autoResume();
void mute(bool muting); 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 // returns the pair stream if successful, nullptr otherwise
Stream* playPairStream(); Stream* playPairStream();

View File

@@ -249,7 +249,8 @@ int32_t StreamManager::queueForPlay(const std::shared_ptr<Sound> &sound,
} // lock } // lock
if (launchThread) { 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_IF(id != 0, "%s: launched thread %d", __func__, id);
} }
ALOGV("%s: returning %d", __func__, streamID); ALOGV("%s: returning %d", __func__, streamID);
@@ -277,7 +278,8 @@ void StreamManager::moveToRestartQueue(
sanityCheckQueue_l(); sanityCheckQueue_l();
} }
if (restart) { 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); ALOGV_IF(id != 0, "%s: launched thread %d", __func__, id);
} }
} }