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.

263 lines
8.1 KiB

  1. //---------------------------------------------------------------------------
  2. //
  3. // Module: pn.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. CPinNode::CPinNode(
  30. PPIN_INFO pPinInfo
  31. )
  32. {
  33. Assert(pPinInfo);
  34. this->pPinInfo = pPinInfo;
  35. AddList(&pPinInfo->lstPinNode);
  36. }
  37. CPinNode::CPinNode(
  38. PGRAPH_NODE pGraphNode,
  39. PPIN_NODE pPinNode
  40. )
  41. {
  42. this->pPinInfo = pPinNode->pPinInfo;
  43. this->ulOverhead = pPinNode->GetOverhead();
  44. this->pDataRange = pPinNode->pDataRange;
  45. this->pInterface = pPinNode->pInterface;
  46. this->pMedium = pPinNode->pMedium;
  47. this->pLogicalFilterNode = pPinNode->pLogicalFilterNode;
  48. AddList(&pGraphNode->lstPinNode);
  49. }
  50. NTSTATUS
  51. CPinNode::CreateAll(
  52. PPIN_INFO pPinInfo,
  53. PDATARANGES pDataRanges,
  54. PIDENTIFIERS pInterfaces,
  55. PIDENTIFIERS pMediums
  56. )
  57. {
  58. NTSTATUS Status = STATUS_SUCCESS;
  59. PKSDATARANGE pDataRange;
  60. PPIN_NODE pPinNode;
  61. ULONG d, i, m;
  62. Assert(pPinInfo);
  63. // Data Ranges loop
  64. pDataRange = &pDataRanges->aDataRanges[0];
  65. for(d = 0; d < pDataRanges->MultipleItem.Count; d++) {
  66. if(IsEqualGUID(
  67. &KSDATAFORMAT_SPECIFIER_WAVEFORMATEX,
  68. &pDataRange->Specifier) ||
  69. IsEqualGUID(
  70. &KSDATAFORMAT_SPECIFIER_DSOUND,
  71. &pDataRange->Specifier)) {
  72. //
  73. // Reject KSDATARANGE_AUDIO's that have the wrong size
  74. //
  75. if(pDataRange->FormatSize < sizeof(KSDATARANGE_AUDIO)) {
  76. DPF(5, "CPinNode::Create: KSDATARANGE_AUDIO wrong size");
  77. continue;
  78. }
  79. }
  80. // Interfaces loop
  81. for(i = 0; i < pInterfaces->MultipleItem.Count; i++) {
  82. // Mediums loop
  83. for(m = 0; m < pMediums->MultipleItem.Count; m++) {
  84. pPinNode = new PIN_NODE(pPinInfo);
  85. if(pPinNode == NULL) {
  86. Status = STATUS_INSUFFICIENT_RESOURCES;
  87. Trap();
  88. goto exit;
  89. }
  90. if(pDataRanges != &DataRangesNull) {
  91. pPinNode->pDataRange = pDataRange;
  92. AssertAligned(pPinNode->pDataRange);
  93. } else Trap();
  94. if(pInterfaces != &IdentifiersNull) {
  95. pPinNode->pInterface = &pInterfaces->aIdentifiers[i];
  96. AssertAligned(pPinNode->pInterface);
  97. }
  98. if(pMediums != &IdentifiersNull) {
  99. pPinNode->pMedium = &pMediums->aIdentifiers[m];
  100. AssertAligned(pPinNode->pMedium);
  101. } else Trap();
  102. if(IsEqualGUID(
  103. &KSDATAFORMAT_SPECIFIER_WAVEFORMATEX,
  104. &pDataRange->Specifier) ||
  105. IsEqualGUID(
  106. &KSDATAFORMAT_SPECIFIER_DSOUND,
  107. &pDataRange->Specifier)) {
  108. //
  109. // Puts in order based on SR, BPS and CHs,
  110. // scaled down to 0 - 256
  111. //
  112. pPinNode->ulOverhead = 256 -
  113. (( (((PKSDATARANGE_AUDIO)pDataRange)->
  114. MaximumChannels > 6 ? 6 :
  115. ((PKSDATARANGE_AUDIO)pDataRange)->
  116. MaximumChannels) *
  117. ((PKSDATARANGE_AUDIO)pDataRange)->
  118. MaximumSampleFrequency *
  119. ((PKSDATARANGE_AUDIO)pDataRange)->
  120. MaximumBitsPerSample) / ((96000 * 32 * 6)/256));
  121. //
  122. // Try the WaveFormatEx format first, then DSOUND
  123. //
  124. if(IsEqualGUID(
  125. &KSDATAFORMAT_SPECIFIER_DSOUND,
  126. &pDataRange->Specifier)) {
  127. pPinNode->ulOverhead += 1;
  128. }
  129. }
  130. else {
  131. // Put in order that the filter had the data ranges
  132. pPinNode->ulOverhead = d;
  133. }
  134. // Put in order that the filter had the interface/mediums
  135. pPinNode->ulOverhead += (m << 16) + (i << 8);
  136. }
  137. }
  138. // Get the pointer to the next data range
  139. *((PUCHAR*)&pDataRange) += ((pDataRange->FormatSize +
  140. FILE_QUAD_ALIGNMENT) & ~FILE_QUAD_ALIGNMENT);
  141. }
  142. exit:
  143. return(Status);
  144. }
  145. BOOL
  146. CPinNode::ComparePins(
  147. PPIN_NODE pPinNode2
  148. )
  149. {
  150. PPIN_NODE pPinNode1 = this;
  151. // Check if dataflow is compatible
  152. switch(pPinNode1->pPinInfo->DataFlow) {
  153. case KSPIN_DATAFLOW_IN:
  154. switch(pPinNode2->pPinInfo->DataFlow) {
  155. case KSPIN_DATAFLOW_OUT:
  156. break;
  157. default:
  158. DPF(100, "ComparePins: dataflow mismatch");
  159. return(FALSE);
  160. }
  161. break;
  162. case KSPIN_DATAFLOW_OUT:
  163. switch(pPinNode2->pPinInfo->DataFlow) {
  164. case KSPIN_DATAFLOW_IN:
  165. break;
  166. default:
  167. DPF(100, "ComparePins: dataflow mismatch");
  168. return(FALSE);
  169. }
  170. break;
  171. default:
  172. Trap();
  173. DPF(100, "ComparePins: dataflow mismatch");
  174. return(FALSE);
  175. }
  176. // Check if communication type is compatible
  177. switch(pPinNode1->pPinInfo->Communication) {
  178. case KSPIN_COMMUNICATION_BOTH:
  179. switch(pPinNode2->pPinInfo->Communication) {
  180. case KSPIN_COMMUNICATION_BOTH:
  181. case KSPIN_COMMUNICATION_SINK:
  182. case KSPIN_COMMUNICATION_SOURCE:
  183. break;
  184. default:
  185. DPF(100, "ComparePins: comm mismatch");
  186. return(FALSE);
  187. }
  188. break;
  189. case KSPIN_COMMUNICATION_SOURCE:
  190. switch(pPinNode2->pPinInfo->Communication) {
  191. case KSPIN_COMMUNICATION_BOTH:
  192. case KSPIN_COMMUNICATION_SINK:
  193. break;
  194. default:
  195. DPF(100, "ComparePins: comm mismatch");
  196. return(FALSE);
  197. }
  198. break;
  199. case KSPIN_COMMUNICATION_SINK:
  200. switch(pPinNode2->pPinInfo->Communication) {
  201. case KSPIN_COMMUNICATION_BOTH:
  202. case KSPIN_COMMUNICATION_SOURCE:
  203. break;
  204. default:
  205. DPF(100, "ComparePins: comm mismatch");
  206. return(FALSE);
  207. }
  208. break;
  209. default:
  210. DPF(100, "ComparePins: comm mismatch");
  211. return(FALSE);
  212. }
  213. // Check if interface is the same
  214. if(!CompareIdentifier(pPinNode1->pInterface, pPinNode2->pInterface)) {
  215. DPF(100, "ComparePins: interface mismatch");
  216. return(FALSE);
  217. }
  218. // Check if medium is the same
  219. if(!CompareIdentifier(pPinNode1->pMedium, pPinNode2->pMedium)) {
  220. Trap();
  221. DPF(100, "ComparePins: medium mismatch");
  222. return(FALSE);
  223. }
  224. // Check if data range is the same
  225. if(!CompareDataRange(pPinNode1->pDataRange, pPinNode2->pDataRange)) {
  226. DPF(100, "ComparePins: datarange mismatch");
  227. return(FALSE);
  228. }
  229. return(TRUE);
  230. }
  231. //---------------------------------------------------------------------------