Merge commit '461af5c8db02ecbf81b0e57934f86a7ab6c4e8b6' into eclair-mr2-plus-aosp * commit '461af5c8db02ecbf81b0e57934f86a7ab6c4e8b6': Hold a lock while we access the preview heap.
This commit is contained in:
@@ -1215,20 +1215,27 @@ void CameraService::Client::copyFrameAndPostCopiedFrame(const sp<ICameraClient>&
|
|||||||
// the callback. For efficiency, reuse the same MemoryHeapBase
|
// the callback. For efficiency, reuse the same MemoryHeapBase
|
||||||
// provided it's big enough. Don't allocate the memory or
|
// provided it's big enough. Don't allocate the memory or
|
||||||
// perform the copy if there's no callback.
|
// perform the copy if there's no callback.
|
||||||
if (mPreviewBuffer == 0) {
|
|
||||||
mPreviewBuffer = new MemoryHeapBase(size, 0, NULL);
|
// hold the lock while we grab a reference to the preview buffer
|
||||||
} else if (size > mPreviewBuffer->virtualSize()) {
|
sp<MemoryHeapBase> previewBuffer;
|
||||||
mPreviewBuffer.clear();
|
{
|
||||||
mPreviewBuffer = new MemoryHeapBase(size, 0, NULL);
|
Mutex::Autolock lock(mLock);
|
||||||
|
if (mPreviewBuffer == 0) {
|
||||||
|
mPreviewBuffer = new MemoryHeapBase(size, 0, NULL);
|
||||||
|
} else if (size > mPreviewBuffer->virtualSize()) {
|
||||||
|
mPreviewBuffer.clear();
|
||||||
|
mPreviewBuffer = new MemoryHeapBase(size, 0, NULL);
|
||||||
|
}
|
||||||
if (mPreviewBuffer == 0) {
|
if (mPreviewBuffer == 0) {
|
||||||
LOGE("failed to allocate space for preview buffer");
|
LOGE("failed to allocate space for preview buffer");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
previewBuffer = mPreviewBuffer;
|
||||||
}
|
}
|
||||||
memcpy(mPreviewBuffer->base(),
|
memcpy(previewBuffer->base(),
|
||||||
(uint8_t *)heap->base() + offset, size);
|
(uint8_t *)heap->base() + offset, size);
|
||||||
|
|
||||||
sp<MemoryBase> frame = new MemoryBase(mPreviewBuffer, 0, size);
|
sp<MemoryBase> frame = new MemoryBase(previewBuffer, 0, size);
|
||||||
if (frame == 0) {
|
if (frame == 0) {
|
||||||
LOGE("failed to allocate space for frame callback");
|
LOGE("failed to allocate space for frame callback");
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user