Merge changes Ic448872c,Id4ef1891
* changes:
blast: protect destruction of callback thread
blast: check for buffer before dumping format
diff --git a/services/surfaceflinger/BufferStateLayer.cpp b/services/surfaceflinger/BufferStateLayer.cpp
index 425f5c7..5ffd8ad 100644
--- a/services/surfaceflinger/BufferStateLayer.cpp
+++ b/services/surfaceflinger/BufferStateLayer.cpp
@@ -336,6 +336,9 @@
}
PixelFormat BufferStateLayer::getPixelFormat() const {
+ if (!mActiveBuffer) {
+ return PIXEL_FORMAT_NONE;
+ }
return mActiveBuffer->format;
}
diff --git a/services/surfaceflinger/TransactionCompletedThread.cpp b/services/surfaceflinger/TransactionCompletedThread.cpp
index 9b9dc57..389118a 100644
--- a/services/surfaceflinger/TransactionCompletedThread.cpp
+++ b/services/surfaceflinger/TransactionCompletedThread.cpp
@@ -30,6 +30,8 @@
namespace android {
TransactionCompletedThread::~TransactionCompletedThread() {
+ std::lock_guard lockThread(mThreadMutex);
+
{
std::lock_guard lock(mMutex);
mKeepRunning = false;
@@ -50,11 +52,13 @@
void TransactionCompletedThread::run() {
std::lock_guard lock(mMutex);
- if (mRunning) {
+ if (mRunning || !mKeepRunning) {
return;
}
mDeathRecipient = new ThreadDeathRecipient();
mRunning = true;
+
+ std::lock_guard lockThread(mThreadMutex);
mThread = std::thread(&TransactionCompletedThread::threadMain, this);
}
diff --git a/services/surfaceflinger/TransactionCompletedThread.h b/services/surfaceflinger/TransactionCompletedThread.h
index 5af4097..1612f69 100644
--- a/services/surfaceflinger/TransactionCompletedThread.h
+++ b/services/surfaceflinger/TransactionCompletedThread.h
@@ -90,7 +90,10 @@
}
};
- std::thread mThread;
+ // Protects the creation and destruction of mThread
+ std::mutex mThreadMutex;
+
+ std::thread mThread GUARDED_BY(mThreadMutex);
std::mutex mMutex;
std::condition_variable_any mConditionVariable;