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.

187 lines
4.7 KiB

  1. //---------------------------------------------------------------------------
  2. //
  3. // Module: cn.cpp
  4. //
  5. // Description:
  6. //
  7. //
  8. //@@BEGIN_MSINTERNAL
  9. // Development Team:
  10. // Mike McLaughlin
  11. //
  12. // History: Date Author Comment
  13. //
  14. // To Do: Date Author Comment
  15. //
  16. //@@END_MSINTERNAL
  17. //
  18. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  19. // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  20. // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  21. // PURPOSE.
  22. //
  23. // Copyright (c) 1996-1999 Microsoft Corporation. All Rights Reserved.
  24. //
  25. //---------------------------------------------------------------------------
  26. #include "common.h"
  27. //---------------------------------------------------------------------------
  28. //---------------------------------------------------------------------------
  29. #ifdef DEBUG
  30. PLIST_CONNECT_NODE gplstConnectNode = NULL;
  31. #endif
  32. //---------------------------------------------------------------------------
  33. NTSTATUS
  34. CConnectNode::Create(
  35. PCONNECT_NODE *ppConnectNode,
  36. PLOGICAL_FILTER_NODE pLogicalFilterNode,
  37. PCONNECT_NODE pConnectNodeNext,
  38. PGRAPH_PIN_INFO pGraphPinInfo,
  39. PPIN_NODE pPinNode1,
  40. PPIN_NODE pPinNode2,
  41. ULONG ulFlagsCurrent,
  42. PGRAPH_NODE pGraphNode
  43. )
  44. {
  45. NTSTATUS Status = STATUS_SUCCESS;
  46. PCONNECT_NODE pConnectNode;
  47. Assert(pPinNode1);
  48. Assert(pPinNode2);
  49. pConnectNode = new CConnectNode(pConnectNodeNext);
  50. if(pConnectNode == NULL) {
  51. Status = STATUS_INSUFFICIENT_RESOURCES;
  52. goto exit;
  53. }
  54. #ifdef DEBUG
  55. Status = gplstConnectNode->AddList(pConnectNode);
  56. if(!NT_SUCCESS(Status)) {
  57. Trap();
  58. goto exit;
  59. }
  60. #endif
  61. switch(pPinNode1->pPinInfo->Communication) {
  62. case KSPIN_COMMUNICATION_BOTH:
  63. switch(pPinNode2->pPinInfo->Communication) {
  64. case KSPIN_COMMUNICATION_SINK:
  65. pConnectNode->pPinNodeSource = pPinNode1;
  66. pConnectNode->pPinNodeSink = pPinNode2;
  67. break;
  68. case KSPIN_COMMUNICATION_BOTH:
  69. case KSPIN_COMMUNICATION_SOURCE:
  70. pConnectNode->pPinNodeSource = pPinNode2;
  71. pConnectNode->pPinNodeSink = pPinNode1;
  72. break;
  73. default:
  74. ASSERT(FALSE);
  75. Status = STATUS_INVALID_PARAMETER;
  76. goto exit;
  77. }
  78. break;
  79. case KSPIN_COMMUNICATION_SINK:
  80. pConnectNode->pPinNodeSink = pPinNode1;
  81. pConnectNode->pPinNodeSource = pPinNode2;
  82. ASSERT(
  83. pPinNode2->pPinInfo->Communication == KSPIN_COMMUNICATION_BOTH ||
  84. pPinNode2->pPinInfo->Communication == KSPIN_COMMUNICATION_SOURCE);
  85. break;
  86. case KSPIN_COMMUNICATION_SOURCE:
  87. pConnectNode->pPinNodeSink = pPinNode2;
  88. pConnectNode->pPinNodeSource = pPinNode1;
  89. ASSERT(
  90. pPinNode2->pPinInfo->Communication == KSPIN_COMMUNICATION_SINK ||
  91. pPinNode2->pPinInfo->Communication == KSPIN_COMMUNICATION_BOTH);
  92. break;
  93. default:
  94. ASSERT(FALSE);
  95. Status = STATUS_INVALID_PARAMETER;
  96. goto exit;
  97. }
  98. Status = CConnectInfo::Create(
  99. pConnectNode,
  100. pLogicalFilterNode,
  101. pConnectNodeNext->GetConnectInfo(),
  102. pGraphPinInfo,
  103. ulFlagsCurrent,
  104. pGraphNode);
  105. if(!NT_SUCCESS(Status)) {
  106. Trap();
  107. goto exit;
  108. }
  109. if(pLogicalFilterNode->GetFlags() & LFN_FLAGS_NO_BYPASS) {
  110. Status = pGraphNode->lstLogicalFilterNodeNoBypass.AddList(
  111. pLogicalFilterNode,
  112. pConnectNode);
  113. if(!NT_SUCCESS(Status)) {
  114. Trap();
  115. goto exit;
  116. }
  117. }
  118. DPF3(80, "CConnectNode::Create %08x PN %08x %08x",
  119. pConnectNode,
  120. pConnectNode->pPinNodeSink,
  121. pConnectNode->pPinNodeSource);
  122. exit:
  123. if(!NT_SUCCESS(Status)) {
  124. if (pConnectNode) {
  125. pConnectNode->Destroy();
  126. }
  127. pConnectNode = NULL;
  128. }
  129. *ppConnectNode = pConnectNode;
  130. return(Status);
  131. }
  132. CConnectNode::CConnectNode(
  133. PCONNECT_NODE pConnectNodeNext
  134. )
  135. {
  136. this->pConnectNodeNext = pConnectNodeNext;
  137. pConnectNodeNext->AddRef();
  138. AddRef();
  139. DPF1(80, "CConnectNode:%08x PN:%08x %08x", this);
  140. }
  141. CConnectNode::~CConnectNode(
  142. )
  143. {
  144. Assert(this);
  145. DPF1(80, "~CConnectNode: %08x", this);
  146. pConnectInfo->Destroy();
  147. pConnectNodeNext->Destroy();
  148. }
  149. //---------------------------------------------------------------------------
  150. #ifdef DEBUG
  151. ENUMFUNC
  152. CConnectNode::Dump(
  153. )
  154. {
  155. Assert(this);
  156. dprintf("CN: %08x cRef %08x CI %08x N %08x\n",
  157. this,
  158. cReference,
  159. pConnectInfo,
  160. pConnectNodeNext);
  161. dprintf(" Source: %08x #%d %s\n",
  162. pPinNodeSource,
  163. pPinNodeSource->pPinInfo->PinId,
  164. pPinNodeSource->pPinInfo->pFilterNode->DumpName());
  165. dprintf(" Sink: %08x #%d %s\n",
  166. pPinNodeSink,
  167. pPinNodeSink->pPinInfo->PinId,
  168. pPinNodeSink->pPinInfo->pFilterNode->DumpName());
  169. return(STATUS_CONTINUE);
  170. }
  171. #endif