diff options
| author | Mathias Agopian <mathias@google.com> | 2009-09-08 23:52:08 -0700 |
|---|---|---|
| committer | Mathias Agopian <mathias@google.com> | 2009-09-09 00:50:29 -0700 |
| commit | a280496bd2ce04d6beff4536f2115a9a4d7568e4 (patch) | |
| tree | d796ce8eae898c35617bd3501b44c778e129fbfa /libs/surfaceflinger/LayerBuffer.cpp | |
| parent | b34d143bce3905c23aa5c1b2b147ec6df48cf9d7 (diff) | |
| download | frameworks_base-a280496bd2ce04d6beff4536f2115a9a4d7568e4.zip frameworks_base-a280496bd2ce04d6beff4536f2115a9a4d7568e4.tar.gz frameworks_base-a280496bd2ce04d6beff4536f2115a9a4d7568e4.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.cpp')
| -rw-r--r-- | libs/surfaceflinger/LayerBuffer.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/libs/surfaceflinger/LayerBuffer.cpp b/libs/surfaceflinger/LayerBuffer.cpp index 0945571..bbfc54b 100644 --- a/libs/surfaceflinger/LayerBuffer.cpp +++ b/libs/surfaceflinger/LayerBuffer.cpp @@ -133,6 +133,14 @@ bool LayerBuffer::transformed() const return false; } +void LayerBuffer::serverDestroy() +{ + sp<Source> source(clearSource()); + if (source != 0) { + source->destroy(); + } +} + /** * This creates a "buffer" source for this surface */ @@ -413,7 +421,7 @@ void LayerBuffer::BufferSource::onDraw(const Region& clip) const status_t err = NO_ERROR; NativeBuffer src(ourBuffer->getBuffer()); - const Rect& transformedBounds = mLayer.getTransformedBounds(); + const Rect transformedBounds(mLayer.getTransformedBounds()); copybit_device_t* copybit = mBlitEngine; if (copybit) { @@ -493,7 +501,7 @@ void LayerBuffer::BufferSource::onDraw(const Region& clip) const } } - const Rect& transformedBounds = mLayer.getTransformedBounds(); + const Rect transformedBounds(mLayer.getTransformedBounds()); const copybit_rect_t& drect = reinterpret_cast<const copybit_rect_t&>(transformedBounds); const State& s(mLayer.drawingState()); @@ -583,9 +591,7 @@ LayerBuffer::OverlaySource::OverlaySource(LayerBuffer& layer, mOverlayHandle = overlay->getHandleRef(overlay); - // NOTE: here it's okay to acquire a reference to "this" as long as - // the reference is not released before we leave the ctor. - sp<OverlayChannel> channel = new OverlayChannel(this); + sp<OverlayChannel> channel = new OverlayChannel( &layer ); *overlayRef = new OverlayRef(mOverlayHandle, channel, mWidth, mHeight, mFormat, mWidthStride, mHeightStride); @@ -625,7 +631,7 @@ void LayerBuffer::OverlaySource::onVisibilityResolved( if (mVisibilityChanged || !mInitialized) { mVisibilityChanged = false; mInitialized = true; - const Rect& bounds = mLayer.getTransformedBounds(); + const Rect bounds(mLayer.getTransformedBounds()); int x = bounds.left; int y = bounds.top; int w = bounds.width(); @@ -644,17 +650,11 @@ void LayerBuffer::OverlaySource::onVisibilityResolved( } } -void LayerBuffer::OverlaySource::serverDestroy() -{ - mLayer.clearSource(); - destroyOverlay(); -} - -void LayerBuffer::OverlaySource::destroyOverlay() +void LayerBuffer::OverlaySource::destroy() { // we need a lock here to protect "onVisibilityResolved" Mutex::Autolock _l(mOverlaySourceLock); - if (mOverlay) { + if (mOverlay && mOverlayDevice) { overlay_control_device_t* overlay_dev = mOverlayDevice; overlay_dev->destroyOverlay(overlay_dev, mOverlay); mOverlay = 0; |
