当前位置: 首页>>代码示例>>C++>>正文


C++ BMediaRoster::GetDormantNodes方法代码示例

本文整理汇总了C++中BMediaRoster::GetDormantNodes方法的典型用法代码示例。如果您正苦于以下问题:C++ BMediaRoster::GetDormantNodes方法的具体用法?C++ BMediaRoster::GetDormantNodes怎么用?C++ BMediaRoster::GetDormantNodes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BMediaRoster的用法示例。


在下文中一共展示了BMediaRoster::GetDormantNodes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: _populateList

void DormantNodeView::_populateList() {
	D_INTERNAL(("DormantNodeView::_populateList()\n"));

	// init the resizable node-info buffer
	BMediaRoster *roster = BMediaRoster::CurrentRoster();
	const int32 bufferInc = 64;
	int32 bufferSize = bufferInc;
	dormant_node_info *infoBuffer = new dormant_node_info[bufferSize];
	int32 numNodes;
	
	// fill the buffer
	while (true) {
		numNodes = bufferSize;
		status_t error = roster->GetDormantNodes(infoBuffer, &numNodes);
		if (error) {
			return;
		}
		if (numNodes < bufferSize) {
			break;
		}
			
		// reallocate buffer & try again
		delete [] infoBuffer;
		bufferSize += bufferInc;
		infoBuffer = new dormant_node_info[bufferSize];
	}
	
	// populate the list
	for (int32 i = 0; i < numNodes; i++) {
		DormantNodeListItem *item = new DormantNodeListItem(infoBuffer[i]);
		AddItem(item);
	}
	SortItems(compareName);
}
开发者ID:mariuz,项目名称:haiku,代码行数:34,代码来源:DormantNodeView.cpp

示例2: _updateList

void DormantNodeView::_updateList(
	int32 addOnID) {
	D_INTERNAL(("DormantNodeView::_updateList(%ld)\n", addOnID));

	// init the resizable node-info buffer
	BMediaRoster *roster = BMediaRoster::CurrentRoster();
	const int32 bufferInc = 64;
	int32 bufferSize = bufferInc;
	dormant_node_info *infoBuffer = new dormant_node_info[bufferSize];
	int32 numNodes;
	
	// fill the buffer
	while (true) {
		numNodes = bufferSize;
		status_t error = roster->GetDormantNodes(infoBuffer, &numNodes);
		if (error) {
			return;
		}
		if (numNodes < bufferSize) {
			break;
		}
			
		// reallocate buffer & try again
		delete [] infoBuffer;
		bufferSize += bufferInc;
		infoBuffer = new dormant_node_info[bufferSize];
	}

	// sort the list by add-on id to avoid multiple searches through
	// the list
	SortItems(compareAddOnID);

	// Remove all nodes managed by this add-on
	int32 start;
	for (start = 0; start < CountItems(); start++) {
		DormantNodeListItem *item = dynamic_cast<DormantNodeListItem *>(ItemAt(start));
		if (item && (item->info().addon == addOnID)) {
			break;
		}
	}
	int32 count = 0;
	for (int32 i = start; start < CountItems(); i++) {
		DormantNodeListItem *item = dynamic_cast<DormantNodeListItem *>(ItemAt(i));
		if (!item || (item->info().addon != addOnID)) {
			break;
		}
		count++;
	}
	RemoveItems(start, count);

	// add the items
	for (int32 i = 0; i < numNodes; i++) {
		if (infoBuffer[i].addon != addOnID) {
			continue;
		}
		AddItem(new DormantNodeListItem(infoBuffer[i]));
	}

	SortItems(compareName);
}
开发者ID:mariuz,项目名称:haiku,代码行数:60,代码来源:DormantNodeView.cpp

示例3: if

void
MediaWindow::_FindNodes(media_type type, uint64 kind, NodeList& into)
{
	dormant_node_info nodeInfo[64];
	int32 nodeInfoCount = 64;

	media_format format;
	media_format* nodeInputFormat = NULL;
	media_format* nodeOutputFormat = NULL;
	format.type = type;

	// output nodes must be BBufferConsumers => they have an input format
	// input nodes must be BBufferProducers => they have an output format
	if ((kind & B_PHYSICAL_OUTPUT) != 0)
		nodeInputFormat = &format;
	else if ((kind & B_PHYSICAL_INPUT) != 0)
		nodeOutputFormat = &format;
	else
		return;

	BMediaRoster* roster = BMediaRoster::Roster();

	if (roster->GetDormantNodes(nodeInfo, &nodeInfoCount, nodeInputFormat,
			nodeOutputFormat, NULL, kind) != B_OK) {
		// TODO: better error reporting!
		fprintf(stderr, "error\n");
		return;
	}

	for (int32 i = 0; i < nodeInfoCount; i++) {
		PRINT(("node : %s, media_addon %i, flavor_id %i\n",
			nodeInfo[i].name, (int)nodeInfo[i].addon,
			(int)nodeInfo[i].flavor_id));

		dormant_node_info* info = new dormant_node_info();
		strncpy(info->name, nodeInfo[i].name, B_MEDIA_NAME_LENGTH);
		info->flavor_id = nodeInfo[i].flavor_id;
		info->addon = nodeInfo[i].addon;
		into.AddItem(info);
	}
}
开发者ID:bhanug,项目名称:haiku,代码行数:41,代码来源:MediaWindow.cpp


注:本文中的BMediaRoster::GetDormantNodes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。