Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

261 lines
7.7 KiB

  1. //---------------------------------------------------------------------------
  2. //
  3. // Module: tn.cpp
  4. //
  5. // Description:
  6. //
  7. // Topology Node Class
  8. //
  9. //@@BEGIN_MSINTERNAL
  10. // Development Team:
  11. // Mike McLaughlin
  12. //
  13. // History: Date Author Comment
  14. //
  15. // To Do: Date Author Comment
  16. //
  17. //@@END_MSINTERNAL
  18. //
  19. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  20. // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  21. // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  22. // PURPOSE.
  23. //
  24. // Copyright (c) 1996-1999 Microsoft Corporation. All Rights Reserved.
  25. //
  26. //---------------------------------------------------------------------------
  27. #include "common.h"
  28. //---------------------------------------------------------------------------
  29. //---------------------------------------------------------------------------
  30. NTSTATUS
  31. CTopologyNode::Create(
  32. PTOPOLOGY_NODE *ppTopologyNode,
  33. PFILTER_NODE pFilterNode,
  34. ULONG ulNodeNumber,
  35. GUID *pguidType
  36. )
  37. {
  38. NTSTATUS Status = STATUS_SUCCESS;
  39. PTOPOLOGY_NODE pTopologyNode;
  40. pTopologyNode = new TOPOLOGY_NODE(pFilterNode, ulNodeNumber, pguidType);
  41. if(pTopologyNode == NULL) {
  42. Status = STATUS_INSUFFICIENT_RESOURCES;
  43. Trap();
  44. goto exit;
  45. }
  46. DPF2(70, "CTopologyNode::Create: %08x, FN: %08x",
  47. pTopologyNode,
  48. pFilterNode);
  49. exit:
  50. *ppTopologyNode = pTopologyNode;
  51. return(Status);
  52. }
  53. CTopologyNode::CTopologyNode(
  54. PFILTER_NODE pFilterNode,
  55. ULONG ulNodeNumber,
  56. GUID *pguidType
  57. )
  58. {
  59. Assert(pFilterNode);
  60. this->pFilterNode = pFilterNode;
  61. this->ulRealNodeNumber = ulNodeNumber;
  62. this->ulSysaudioNodeNumber = MAXULONG;
  63. this->iVirtualSource = MAXULONG;
  64. this->pguidType = pguidType;
  65. AddList(&pFilterNode->lstTopologyNode);
  66. DPF2(70, "CTopologyNode: %08x, FN: %08x", this, pFilterNode);
  67. }
  68. CTopologyNode::~CTopologyNode(
  69. )
  70. {
  71. DPF1(70, "~CTopologyNode: %08x", this);
  72. Assert(this);
  73. }
  74. NTSTATUS
  75. CreateTopology(
  76. PFILTER_NODE pFilterNode,
  77. PKSTOPOLOGY pTopology
  78. )
  79. {
  80. NTSTATUS Status = STATUS_SUCCESS;
  81. PTOPOLOGY_CONNECTION pTopologyConnection;
  82. PTOPOLOGY_NODE *papTopologyNode = NULL;
  83. PTOPOLOGY_NODE pTopologyNodeFrom;
  84. PTOPOLOGY_NODE pTopologyNodeTo;
  85. PTOPOLOGY_PIN pTopologyPinFrom;
  86. PTOPOLOGY_PIN pTopologyPinTo;
  87. PPIN_INFO pPinInfoFrom;
  88. PPIN_INFO pPinInfoTo;
  89. PPIN_INFO pPinInfo;
  90. ULONG ulTopologyPinNumberFrom;
  91. ULONG ulTopologyPinNumberTo;
  92. ULONG n, c;
  93. // If no topology, return error
  94. if(pTopology->TopologyNodesCount == 0) {
  95. if(pTopology->TopologyConnectionsCount == 0) {
  96. DPF2(5,
  97. "CreateTopology: FAILED, %s has no topology FN: %08x",
  98. pFilterNode->DumpName(),
  99. pFilterNode);
  100. Status = STATUS_INVALID_PARAMETER;
  101. goto exit;
  102. }
  103. }
  104. else {
  105. papTopologyNode = new PTOPOLOGY_NODE[pTopology->TopologyNodesCount];
  106. if(papTopologyNode == NULL) {
  107. Status = STATUS_INSUFFICIENT_RESOURCES;
  108. goto exit;
  109. }
  110. for(n = 0; n < pTopology->TopologyNodesCount; n++) {
  111. Status = CTopologyNode::Create(
  112. &papTopologyNode[n],
  113. pFilterNode,
  114. n,
  115. (GUID *)&pTopology->TopologyNodes[n]);
  116. if(!NT_SUCCESS(Status)) {
  117. Trap();
  118. goto exit;
  119. }
  120. }
  121. }
  122. for(c = 0; c < pTopology->TopologyConnectionsCount; c++) {
  123. pTopologyNodeFrom = pTopologyNodeTo = NULL;
  124. pTopologyPinFrom = pTopologyPinTo = NULL;
  125. pPinInfoFrom = pPinInfoTo = NULL;
  126. if(pTopology->TopologyConnections[c].FromNode != KSFILTER_NODE) {
  127. if(pTopology->TopologyConnections[c].FromNode >=
  128. pTopology->TopologyNodesCount) {
  129. DPF2(5,
  130. "CreateTopology: FAILED, %s invalid 'from' node # %08x",
  131. pFilterNode->DumpName(),
  132. pTopology->TopologyConnections[c].FromNode);
  133. Trap();
  134. Status = STATUS_INVALID_PARAMETER;
  135. goto exit;
  136. }
  137. pTopologyNodeFrom =
  138. papTopologyNode[pTopology->TopologyConnections[c].FromNode];
  139. ulTopologyPinNumberFrom =
  140. pTopology->TopologyConnections[c].FromNodePin;
  141. }
  142. if(pTopology->TopologyConnections[c].ToNode != KSFILTER_NODE) {
  143. if(pTopology->TopologyConnections[c].ToNode >=
  144. pTopology->TopologyNodesCount) {
  145. DPF2(5,
  146. "CreateTopology: FAILED, %s invalid 'to' node # %08x",
  147. pFilterNode->DumpName(),
  148. pTopology->TopologyConnections[c].ToNode);
  149. Trap();
  150. Status = STATUS_INVALID_PARAMETER;
  151. goto exit;
  152. }
  153. pTopologyNodeTo =
  154. papTopologyNode[pTopology->TopologyConnections[c].ToNode];
  155. ulTopologyPinNumberTo =
  156. pTopology->TopologyConnections[c].ToNodePin;
  157. }
  158. if(pTopologyNodeFrom == NULL) {
  159. FOR_EACH_LIST_ITEM(&pFilterNode->lstPinInfo, pPinInfo) {
  160. if(pPinInfo->PinId ==
  161. pTopology->TopologyConnections[c].FromNodePin) {
  162. pPinInfoFrom = pPinInfo;
  163. break;
  164. }
  165. } END_EACH_LIST_ITEM
  166. if(pPinInfoFrom == NULL) {
  167. DPF2(5,
  168. "CreateTopology: FAILED, %s invalid 'from' node pin # %08x",
  169. pFilterNode->DumpName(),
  170. pTopology->TopologyConnections[c].FromNodePin);
  171. Trap();
  172. Status = STATUS_INVALID_PARAMETER;
  173. goto exit;
  174. }
  175. }
  176. else {
  177. Status = CTopologyPin::Create(
  178. &pTopologyPinFrom,
  179. ulTopologyPinNumberFrom,
  180. pTopologyNodeFrom);
  181. if(!NT_SUCCESS(Status)) {
  182. Trap();
  183. goto exit;
  184. }
  185. }
  186. if(pTopologyNodeTo == NULL) {
  187. FOR_EACH_LIST_ITEM(&pFilterNode->lstPinInfo, pPinInfo) {
  188. if(pPinInfo->PinId ==
  189. pTopology->TopologyConnections[c].ToNodePin) {
  190. pPinInfoTo = pPinInfo;
  191. break;
  192. }
  193. } END_EACH_LIST_ITEM
  194. if(pPinInfoTo == NULL) {
  195. DPF2(5,
  196. "CreateTopology: FAILED, %s invalid 'to' node pin # %08x",
  197. pFilterNode->DumpName(),
  198. pTopology->TopologyConnections[c].ToNodePin);
  199. Trap();
  200. Status = STATUS_INVALID_PARAMETER;
  201. goto exit;
  202. }
  203. }
  204. else {
  205. Status = CTopologyPin::Create(
  206. &pTopologyPinTo,
  207. ulTopologyPinNumberTo,
  208. pTopologyNodeTo);
  209. if(!NT_SUCCESS(Status)) {
  210. Trap();
  211. goto exit;
  212. }
  213. }
  214. Status = CTopologyConnection::Create(
  215. &pTopologyConnection,
  216. pFilterNode,
  217. NULL,
  218. pTopologyPinFrom,
  219. pTopologyPinTo,
  220. pPinInfoFrom,
  221. pPinInfoTo);
  222. if(!NT_SUCCESS(Status)) {
  223. Trap();
  224. goto exit;
  225. }
  226. ASSERT(IS_CONNECTION_TYPE(pTopologyConnection, FILTER));
  227. }
  228. exit:
  229. delete [] papTopologyNode;
  230. return(Status);
  231. }
  232. //---------------------------------------------------------------------------