本文整理汇总了C++中nsAutoPtr::acquire_buffer方法的典型用法代码示例。如果您正苦于以下问题:C++ nsAutoPtr::acquire_buffer方法的具体用法?C++ nsAutoPtr::acquire_buffer怎么用?C++ nsAutoPtr::acquire_buffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsAutoPtr
的用法示例。
在下文中一共展示了nsAutoPtr::acquire_buffer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mon
status_t
RtspMediaSource::read(MediaBuffer** out, const ReadOptions* options)
{
ReentrantMonitorAutoEnter mon(mMonitor);
NS_ENSURE_TRUE(mIsStarted, MEDIA_ERROR_BASE);
NS_ENSURE_TRUE(out, MEDIA_ERROR_BASE);
*out = nullptr;
// Video/audio track's initial frame size is FRAME_DEFAULT_SIZE.
// We need to realloc the mBuffer if the mBuffer doesn't have enough space
// for next ReadFrameFromTrack function. (actualFrameSize > mFrameMaxSize)
status_t err;
uint32_t readCount;
uint32_t actualFrameSize;
uint64_t time;
nsresult rv;
while (1) {
err = mGroup->acquire_buffer(&mBuffer);
NS_ENSURE_TRUE(err == OK, err);
rv = mRtspResource->ReadFrameFromTrack((uint8_t *)mBuffer->data(),
mFrameMaxSize, mTrackIdx, readCount,
time, actualFrameSize);
if (NS_FAILED(rv)) {
// Release mGroup and mBuffer.
stop();
// Since RtspMediaSource is an implementation of Android media source,
// it's held by OMXCodec and isn't released yet. So we have to re-construct
// mGroup and mBuffer.
start();
NS_WARNING("ReadFrameFromTrack failed; releasing buffers and returning.");
return ERROR_END_OF_STREAM;
}
if (actualFrameSize > mFrameMaxSize) {
// release mGroup and mBuffer
stop();
// re-construct mGroup and mBuffer
mFrameMaxSize = actualFrameSize;
err = start();
NS_ENSURE_TRUE(err == OK, err);
} else {
// ReadFrameFromTrack success, break the while loop.
break;
}
}
mBuffer->set_range(0, readCount);
if (NS_SUCCEEDED(rv)) {
mBuffer->meta_data()->clear();
// fill the meta data
mBuffer->meta_data()->setInt64(kKeyTime, time);
*out = mBuffer;
mBuffer = nullptr;
return OK;
}
return ERROR_END_OF_STREAM;
}