summaryrefslogtreecommitdiffstats
path: root/libs/surfaceflinger/LayerBuffer.h
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2009-09-08 23:52:08 -0700
committerMathias Agopian <mathias@google.com>2009-09-09 00:50:29 -0700
commit454ea681398a23a45e2a9c4f3b12d7c30fec8e3c (patch)
tree288ba2ee6823f0227257be410abb880cd799a259 /libs/surfaceflinger/LayerBuffer.h
parent4d2de2c7696feccb9e5ecc05ac3281cdaae45418 (diff)
downloadframeworks_native-454ea681398a23a45e2a9c4f3b12d7c30fec8e3c.zip
frameworks_native-454ea681398a23a45e2a9c4f3b12d7c30fec8e3c.tar.gz
frameworks_native-454ea681398a23a45e2a9c4f3b12d7c30fec8e3c.tar.bz2
fix [2037525] Fail to start camera after adb sync new Camera
we ended-up locking a Mutex that had been destroyed. This happened because we gave an sp<Source> to the outside world, and were called after LayerBuffer had been destroyed. Instead we now give a wp<LayerBuffer> to the outside and have it do the destruction.
Diffstat (limited to 'libs/surfaceflinger/LayerBuffer.h')
-rw-r--r--libs/surfaceflinger/LayerBuffer.h34
1 files changed, 15 insertions, 19 deletions
diff --git a/libs/surfaceflinger/LayerBuffer.h b/libs/surfaceflinger/LayerBuffer.h
index 3b09998..0452818 100644
--- a/libs/surfaceflinger/LayerBuffer.h
+++ b/libs/surfaceflinger/LayerBuffer.h
@@ -49,6 +49,7 @@ class LayerBuffer : public LayerBaseClient
virtual void postBuffer(ssize_t offset);
virtual void unregisterBuffers();
virtual bool transformed() const;
+ virtual void destroy() { }
protected:
LayerBuffer& mLayer;
};
@@ -81,10 +82,12 @@ public:
sp<Source> getSource() const;
sp<Source> clearSource();
void setNeedsBlending(bool blending);
- const Rect& getTransformedBounds() const {
+ Rect getTransformedBounds() const {
return mTransformedBounds;
}
+ void serverDestroy();
+
private:
struct NativeBuffer {
copybit_image_t img;
@@ -123,6 +126,7 @@ private:
virtual void postBuffer(ssize_t offset);
virtual void unregisterBuffers();
virtual bool transformed() const;
+ virtual void destroy() { }
private:
mutable Mutex mBufferSourceLock;
sp<Buffer> mBuffer;
@@ -143,29 +147,21 @@ private:
virtual void onDraw(const Region& clip) const;
virtual void onTransaction(uint32_t flags);
virtual void onVisibilityResolved(const Transform& planeTransform);
+ virtual void destroy();
private:
- void serverDestroy();
- void destroyOverlay();
-
+
class OverlayChannel : public BnOverlay {
- public:
- OverlayChannel(const sp<OverlaySource>& source)
- : mSource(source) {
- }
- private:
+ wp<LayerBuffer> mLayer;
virtual void destroy() {
- sp<OverlaySource> source;
- { // scope for the lock;
- Mutex::Autolock _l(mDestroyLock);
- source = mSource;
- mSource.clear();
- }
- if (source != 0) {
- source->serverDestroy();
+ sp<LayerBuffer> layer(mLayer.promote());
+ if (layer != 0) {
+ layer->serverDestroy();
}
}
- mutable Mutex mDestroyLock;
- sp<OverlaySource> mSource;
+ public:
+ OverlayChannel(const sp<LayerBuffer>& layer)
+ : mLayer(layer) {
+ }
};
friend class OverlayChannel;