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.
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);
}
}

View File

@@ -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<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
// 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

View File

@@ -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();

View File

@@ -249,7 +249,8 @@ int32_t StreamManager::queueForPlay(const std::shared_ptr<Sound> &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);
}
}