本文整理汇总了C++中sp::capacity方法的典型用法代码示例。如果您正苦于以下问题:C++ sp::capacity方法的具体用法?C++ sp::capacity怎么用?C++ sp::capacity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sp
的用法示例。
在下文中一共展示了sp::capacity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: convert
status_t DataConverter::convert(const sp<MediaCodecBuffer> &source, sp<MediaCodecBuffer> &target) {
CHECK(source->base() != target->base());
size_t size = targetSize(source->size());
status_t err = OK;
if (size > target->capacity()) {
ALOGE("data size (%zu) is greater than buffer capacity (%zu)",
size, // this is the data received/to be converted
target->capacity()); // this is out buffer size
err = FAILED_TRANSACTION;
} else {
err = safeConvert(source, target);
}
target->setRange(0, err == OK ? size : 0);
return err;
}
示例2: readSampleData
status_t NuMediaExtractor::readSampleData(const sp<ABuffer> &buffer) {
Mutex::Autolock autoLock(mLock);
ssize_t minIndex = fetchTrackSamples();
if (minIndex < 0) {
return ERROR_END_OF_STREAM;
}
TrackInfo *info = &mSelectedTracks.editItemAt(minIndex);
size_t sampleSize = info->mSample->range_length();
if (info->mTrackFlags & kIsVorbis) {
// Each sample's data is suffixed by the number of page samples
// or -1 if not available.
sampleSize += sizeof(int32_t);
}
if (buffer->capacity() < sampleSize) {
return -ENOMEM;
}
const uint8_t *src =
(const uint8_t *)info->mSample->data()
+ info->mSample->range_offset();
memcpy((uint8_t *)buffer->data(), src, info->mSample->range_length());
if (info->mTrackFlags & kIsVorbis) {
int32_t numPageSamples;
if (!info->mSample->meta_data()->findInt32(
kKeyValidSamples, &numPageSamples)) {
numPageSamples = -1;
}
memcpy((uint8_t *)buffer->data() + info->mSample->range_length(),
&numPageSamples,
sizeof(numPageSamples));
}
buffer->setRange(0, sampleSize);
return OK;
}