本文整理汇总了C++中Stream::Init方法的典型用法代码示例。如果您正苦于以下问题:C++ Stream::Init方法的具体用法?C++ Stream::Init怎么用?C++ Stream::Init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stream
的用法示例。
在下文中一共展示了Stream::Init方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _
status_t
AVFormatReader::AllocateCookie(int32 streamIndex, void** _cookie)
{
TRACE("AVFormatReader::AllocateCookie(%ld)\n", streamIndex);
BAutolock _(fSourceLock);
if (fStreams == NULL)
return B_NO_INIT;
if (streamIndex < 0 || streamIndex >= fStreams[0]->CountStreams())
return B_BAD_INDEX;
if (_cookie == NULL)
return B_BAD_VALUE;
Stream* cookie = fStreams[streamIndex];
if (cookie == NULL) {
// Allocate the cookie
BPositionIO* source = dynamic_cast<BPositionIO*>(Source());
if (source == NULL) {
TRACE(" not a BPositionIO, but we need it to be one.\n");
return B_NOT_SUPPORTED;
}
cookie = new(std::nothrow) Stream(source, &fSourceLock);
if (cookie == NULL) {
ERROR("AVFormatReader::Sniff() - failed to allocate "
"Stream\n");
return B_NO_MEMORY;
}
status_t ret = cookie->Open();
if (ret != B_OK) {
TRACE(" stream failed to open: %s\n", strerror(ret));
delete cookie;
return ret;
}
}
status_t ret = cookie->Init(streamIndex);
if (ret != B_OK) {
TRACE(" stream failed to initialize: %s\n", strerror(ret));
// NOTE: Never delete the first stream!
if (streamIndex != 0)
delete cookie;
return ret;
}
fStreams[streamIndex] = cookie;
*_cookie = cookie;
return B_OK;
}
示例2: Stream
status_t
Device::_SetupEndpoints()
{
const usb_configuration_info *config
= gUSBModule->get_nth_configuration(fDevice, 0);
if (config == NULL) {
TRACE_ALWAYS("Error of getting USB device configuration.\n");
return B_ERROR;
}
if (config->interface_count <= 0) {
TRACE_ALWAYS("Error:no interfaces found in USB device configuration\n");
return B_ERROR;
}
for (size_t i = 0; i < config->interface_count; i++) {
usb_interface_info *Interface = config->interface[i].active;
if (Interface->descr->interface_class != UAS_AUDIO) {
continue;
}
switch (Interface->descr->interface_subclass) {
case UAS_AUDIOCONTROL:
fAudioControl.Init(i, Interface);
break;
case UAS_AUDIOSTREAMING:
{
Stream *stream = new Stream(this, i, &config->interface[i]);
if (B_OK == stream->Init()) {
// put the stream in the correct order:
// first output that input ones.
if (stream->IsInput()) {
fStreams.PushBack(stream);
} else {
fStreams.PushFront(stream);
}
} else {
delete stream;
}
}
break;
default:
TRACE_ALWAYS("Ignore interface of unsupported subclass %#x.\n",
Interface->descr->interface_subclass);
break;
}
}
if (fAudioControl.InitCheck() == B_OK && fStreams.Count() > 0) {
TRACE("Found device %#06x:%#06x\n", fVendorID, fProductID);
gUSBModule->set_configuration(fDevice, config);
for (int i = 0; i < fStreams.Count(); i++) {
fStreams[i]->OnSetConfiguration(fDevice, config);
}
return B_OK;
}
return B_NO_INIT;
}