Source code of Windows XP (NT5)
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.

293 lines
6.7 KiB

  1. //---------------------------------------------------------------------------
  2. //
  3. // Module: si.cpp
  4. //
  5. // Description:
  6. //
  7. // Start Info 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. CStartInfo::Create(
  32. PSTART_NODE pStartNode,
  33. PCONNECT_INFO pConnectInfo,
  34. PGRAPH_PIN_INFO pGraphPinInfo,
  35. PGRAPH_NODE pGraphNode
  36. )
  37. {
  38. NTSTATUS Status = STATUS_SUCCESS;
  39. PSTART_INFO pStartInfo;
  40. Assert(pGraphNode);
  41. Assert(pStartNode);
  42. FOR_EACH_LIST_ITEM(&pGraphNode->lstStartInfo, pStartInfo) {
  43. if(pStartInfo->GetPinInfo() == pStartNode->pPinNode->pPinInfo &&
  44. pStartInfo->pConnectInfoHead == pConnectInfo) {
  45. ASSERT(pStartInfo->pConnectInfoHead->IsSameGraph(pConnectInfo));
  46. pStartInfo->AddRef();
  47. goto exit;
  48. }
  49. } END_EACH_LIST_ITEM
  50. pStartInfo = new START_INFO(
  51. pStartNode->pPinNode->pPinInfo,
  52. pConnectInfo,
  53. pGraphPinInfo,
  54. pGraphNode);
  55. if(pStartInfo == NULL) {
  56. Status = STATUS_INSUFFICIENT_RESOURCES;
  57. goto exit;
  58. }
  59. DPF2(80, "CStartInfo::Create %08x GN %08x", pStartInfo, pGraphNode);
  60. exit:
  61. pStartNode->pStartInfo = pStartInfo;
  62. return(Status);
  63. }
  64. CStartInfo::CStartInfo(
  65. PPIN_INFO pPinInfo,
  66. PCONNECT_INFO pConnectInfo,
  67. PGRAPH_PIN_INFO pGraphPinInfo,
  68. PGRAPH_NODE pGraphNode
  69. )
  70. {
  71. Assert(pGraphPinInfo);
  72. Assert(pGraphNode);
  73. this->pPinInfo = pPinInfo;
  74. this->ulTopologyConnectionTableIndex = MAXULONG;
  75. this->ulVolumeNodeNumberPre = MAXULONG;
  76. this->ulVolumeNodeNumberSuperMix = MAXULONG;
  77. this->ulVolumeNodeNumberPost = MAXULONG;
  78. this->pGraphPinInfo = pGraphPinInfo;
  79. pGraphPinInfo->AddRef();
  80. this->pConnectInfoHead = pConnectInfo;
  81. pConnectInfo->AddRef();
  82. AddList(&pGraphNode->lstStartInfo);
  83. AddRef();
  84. DPF2(80, "CStartInfo: %08x GN %08x", this, pGraphNode);
  85. }
  86. CStartInfo::~CStartInfo(
  87. )
  88. {
  89. DPF1(80, "~CStartInfo: %08x", this);
  90. Assert(this);
  91. RemoveList();
  92. pGraphPinInfo->Destroy();
  93. pConnectInfoHead->Destroy();
  94. }
  95. ENUMFUNC
  96. CStartInfo::CreatePinInfoConnection(
  97. PVOID pReference
  98. )
  99. {
  100. PGRAPH_NODE pGraphNode = PGRAPH_NODE(pReference);
  101. PTOPOLOGY_CONNECTION pTopologyConnection = NULL;
  102. PCONNECT_INFO pConnectInfo;
  103. NTSTATUS Status;
  104. Assert(this);
  105. Assert(pGraphNode);
  106. for(pConnectInfo = GetFirstConnectInfo();
  107. pConnectInfo != NULL;
  108. pConnectInfo = pConnectInfo->GetNextConnectInfo()) {
  109. Assert(pConnectInfo);
  110. Status = ::CreatePinInfoConnection(
  111. &pTopologyConnection,
  112. NULL,
  113. pGraphNode,
  114. pConnectInfo->pPinInfoSource,
  115. pConnectInfo->pPinInfoSink);
  116. if(!NT_SUCCESS(Status)) {
  117. Trap();
  118. goto exit;
  119. }
  120. }
  121. Status = STATUS_CONTINUE;
  122. exit:
  123. return(Status);
  124. }
  125. ENUMFUNC
  126. FindVolumeNode(
  127. IN PTOPOLOGY_CONNECTION pTopologyConnection,
  128. IN BOOL fToDirection,
  129. IN PSTART_INFO pStartInfo
  130. )
  131. {
  132. PTOPOLOGY_PIN pTopologyPin;
  133. Assert(pTopologyConnection);
  134. // Need this check when called from EnumerateGraphTopology
  135. if(IS_CONNECTION_TYPE(pTopologyConnection, GRAPH)) {
  136. return(STATUS_DEAD_END);
  137. }
  138. if(fToDirection) {
  139. pTopologyPin = pTopologyConnection->pTopologyPinTo;
  140. }
  141. else {
  142. pTopologyPin = pTopologyConnection->pTopologyPinFrom;
  143. }
  144. if(pTopologyPin == NULL) {
  145. return(STATUS_CONTINUE);
  146. }
  147. if(IsEqualGUID(pTopologyPin->pTopologyNode->pguidType, &KSNODETYPE_SUM)) {
  148. return(STATUS_DEAD_END);
  149. }
  150. if(IsEqualGUID(pTopologyPin->pTopologyNode->pguidType, &KSNODETYPE_MUX)) {
  151. return(STATUS_DEAD_END);
  152. }
  153. if(IsEqualGUID(
  154. pTopologyPin->pTopologyNode->pguidType,
  155. &KSNODETYPE_SUPERMIX)) {
  156. Assert(pStartInfo);
  157. pStartInfo->ulVolumeNodeNumberSuperMix =
  158. pTopologyPin->pTopologyNode->ulSysaudioNodeNumber;
  159. DPF1(100, "FindVolumeNode: found supermix node: %02x",
  160. pStartInfo->ulVolumeNodeNumberSuperMix);
  161. return(STATUS_CONTINUE);
  162. }
  163. if(IsEqualGUID(
  164. pTopologyPin->pTopologyNode->pguidType,
  165. &KSNODETYPE_VOLUME)) {
  166. Assert(pStartInfo);
  167. if(pStartInfo->ulVolumeNodeNumberSuperMix != MAXULONG) {
  168. // Found a volume node after a super mix
  169. pStartInfo->ulVolumeNodeNumberPost =
  170. pTopologyPin->pTopologyNode->ulSysaudioNodeNumber;
  171. DPF1(100, "FindVolumeNode: found post node: %02x",
  172. pStartInfo->ulVolumeNodeNumberPost);
  173. return(STATUS_SUCCESS);
  174. }
  175. if(pStartInfo->ulVolumeNodeNumberPre == MAXULONG) {
  176. // Found first volume node
  177. pStartInfo->ulVolumeNodeNumberPre =
  178. pTopologyPin->pTopologyNode->ulSysaudioNodeNumber;
  179. DPF1(100, "FindVolumeNode: found pre node: %02x",
  180. pStartInfo->ulVolumeNodeNumberPre);
  181. }
  182. }
  183. return(STATUS_CONTINUE);
  184. }
  185. ENUMFUNC
  186. CStartInfo::EnumStartInfo(
  187. )
  188. {
  189. Assert(this);
  190. DPF3(100, "EnumStartInfo: %08x %d %s",
  191. this,
  192. GetPinInfo()->PinId,
  193. GetPinInfo()->pFilterNode->DumpName());
  194. EnumerateGraphTopology(
  195. this,
  196. (TOP_PFN)FindVolumeNode,
  197. this);
  198. return(STATUS_CONTINUE);
  199. }
  200. //---------------------------------------------------------------------------
  201. #ifdef DEBUG
  202. ENUMFUNC
  203. CStartInfo::Dump(
  204. )
  205. {
  206. PCONNECT_INFO pConnectInfo;
  207. Assert(this);
  208. // .sgv or .so
  209. if(ulDebugFlags & (DEBUG_FLAGS_VERBOSE | DEBUG_FLAGS_OBJECT)) {
  210. dprintf("SI: %08x cRef %08x PI %08x #%d %s\n",
  211. this,
  212. cReference,
  213. GetPinInfo(),
  214. GetPinInfo()->PinId,
  215. GetPinInfo()->pFilterNode->DumpName());
  216. dprintf(" ulTopConnecTableIndex: %08x ulVolumeNodeNumberPre %08x\n",
  217. ulTopologyConnectionTableIndex,
  218. ulVolumeNodeNumberPre);
  219. dprintf(" ulVolumeNodeNumberSup: %08x ulVolumeNodeNumberPost %08x\n",
  220. ulVolumeNodeNumberSuperMix,
  221. ulVolumeNodeNumberPost);
  222. pGraphPinInfo->Dump();
  223. }
  224. // .sg
  225. else {
  226. dprintf("SI: %08x PI %08x P%-2d C%-1d #%d %s\n",
  227. this,
  228. GetPinInfo(),
  229. GetPinInstances()->PossibleCount,
  230. GetPinInstances()->CurrentCount,
  231. GetPinInfo()->PinId,
  232. GetPinInfo()->pFilterNode->DumpName());
  233. }
  234. if(ulDebugFlags & DEBUG_FLAGS_GRAPH) {
  235. for(pConnectInfo = GetFirstConnectInfo();
  236. pConnectInfo != NULL;
  237. pConnectInfo = pConnectInfo->GetNextConnectInfo()) {
  238. pConnectInfo->Dump();
  239. }
  240. }
  241. return(STATUS_CONTINUE);
  242. }
  243. #endif