本文整理汇总了C++中sp::dataCallback方法的典型用法代码示例。如果您正苦于以下问题:C++ sp::dataCallback方法的具体用法?C++ sp::dataCallback怎么用?C++ sp::dataCallback使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sp
的用法示例。
在下文中一共展示了sp::dataCallback方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: copyFrameAndPostCopiedFrame
void CameraClient::copyFrameAndPostCopiedFrame(
int32_t msgType, const sp<ICameraClient>& client,
const sp<IMemoryHeap>& heap, size_t offset, size_t size,
camera_frame_metadata_t *metadata) {
LOG2("copyFrameAndPostCopiedFrame");
// It is necessary to copy out of pmem before sending this to
// the callback. For efficiency, reuse the same MemoryHeapBase
// provided it's big enough. Don't allocate the memory or
// perform the copy if there's no callback.
// hold the preview lock while we grab a reference to the preview buffer
sp<MemoryHeapBase> previewBuffer;
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) {
ALOGE("failed to allocate space for preview buffer");
mLock.unlock();
return;
}
previewBuffer = mPreviewBuffer;
void* previewBufferBase = previewBuffer->base();
void* heapBase = heap->base();
if (heapBase == MAP_FAILED) {
ALOGE("%s: Failed to mmap heap for preview frame.", __FUNCTION__);
mLock.unlock();
return;
} else if (previewBufferBase == MAP_FAILED) {
ALOGE("%s: Failed to mmap preview buffer for preview frame.", __FUNCTION__);
mLock.unlock();
return;
}
memcpy(previewBufferBase, (uint8_t *) heapBase + offset, size);
sp<MemoryBase> frame = new MemoryBase(previewBuffer, 0, size);
if (frame == 0) {
ALOGE("failed to allocate space for frame callback");
mLock.unlock();
return;
}
mLock.unlock();
client->dataCallback(msgType, frame, metadata);
}
示例2: MemoryHeapBase
void CameraService::Client::copyFrameAndPostCopiedFrame(
const sp<ICameraClient>& client, const sp<IMemoryHeap>& heap,
size_t offset, size_t size) {
LOG2("copyFrameAndPostCopiedFrame");
// It is necessary to copy out of pmem before sending this to
// the callback. For efficiency, reuse the same MemoryHeapBase
// provided it's big enough. Don't allocate the memory or
// perform the copy if there's no callback.
// hold the preview lock while we grab a reference to the preview buffer
sp<MemoryHeapBase> previewBuffer;
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) {
LOGE("failed to allocate space for preview buffer");
mLock.unlock();
return;
}
previewBuffer = mPreviewBuffer;
memcpy(previewBuffer->base(), (uint8_t *)heap->base() + offset, size);
sp<MemoryBase> frame = new MemoryBase(previewBuffer, 0, size);
if (frame == 0) {
LOGE("failed to allocate space for frame callback");
mLock.unlock();
return;
}
mLock.unlock();
client->dataCallback(CAMERA_MSG_PREVIEW_FRAME, frame);
}