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.

307 lines
8.4 KiB

  1. /*
  2. @{[hǗNX
  3. @iNP2)@Sachiko Yasukawa
  4. */
  5. // Date | Author | Description
  6. // -----------+--------------+--------------------------------------------
  7. // 1998.03.27 | Hideki Yagi | Change the specification about GetSTC().
  8. //
  9. #include "stdafx.h"
  10. #include "includes.h"
  11. #include "classlib.h"
  12. //������
  13. BOOL CMPEGBoard::Init()
  14. {
  15. m_pBaseStreamObject=NULL;
  16. m_pIHAL=NULL;
  17. return TRUE;
  18. }
  19. //�Ǘ����ׂ��V�����X�g���[���̒lj�
  20. //�p�����[�^
  21. //IBaseStream�@���b�p�[�������X�g���[���N���X�̊��{�N���X�ւ̃|�C���^
  22. BOOL CMPEGBoard::AddStreamObjectInterface(IBaseStream *INewStreamObject)
  23. {
  24. CBaseStream *pBSt1, *pBSt2;
  25. ASSERT(INewStreamObject);
  26. //HAL���ݒ肵�Ă��Ȃ��̂ŃG���[
  27. //if(m_pIHAL == NULL){
  28. // _RPTF0(_CRT_ERROR, "m_pIHAL = NULL\n");
  29. // return FALSE;
  30. //}
  31. //�܂����‚��X�g���[�����lj������Ă��Ȃ��B
  32. //m_pBaseStreamObject ... �Ǘ����ׂ��X�g���[���̐擪������
  33. if(m_pBaseStreamObject == NULL){
  34. m_pBaseStreamObject = (CBaseStream *) INewStreamObject;
  35. pBSt1 = m_pBaseStreamObject;
  36. }
  37. //�Ǘ����ׂ��V�����X�g���[�����lj�
  38. else{
  39. pBSt1 = (CBaseStream *)INewStreamObject;
  40. //MIX�^�C�v�̃X�g���[���ɒlj��ł��Ȃ�
  41. if(ISMIXSTREAM(pBSt1->m_StreamType) == TRUE || ISMIXSTREAM(m_pBaseStreamObject->m_StreamType) == TRUE){
  42. _RPTF0(_CRT_ERROR, "INVALID STREAM\n");
  43. DBG_PRINTF(("CLASSLIB:CMPEGBOARD::AddStreamObjectInterface:SET INVALID TYPE STREAM\n"));
  44. DBG_BREAK();
  45. return FALSE;
  46. }
  47. //�Ǘ����ׂ��X�g���[���̃��X�g���T��
  48. for(pBSt2 = m_pBaseStreamObject; pBSt2->m_pNextStreamObject != NULL; pBSt2 = pBSt2->m_pNextStreamObject);
  49. pBSt2->m_pNextStreamObject= pBSt1;//���܂܂Ń��X�g���������̂�Next�Ƀp�����[�^�Ŏw�肳�ꂽ�X�g���[����
  50. pBSt1->m_pPrevStreamObject = pBSt2;//�p�����[�^�Ŏw�肳�ꂽ�X�g���[����Prev�ɍ��܂Ń��X�g���������̂�
  51. }
  52. //�lj����悤�Ƃ��Ă����X�g���[���ɂg�`�k�C���^�t�F�[�X�ւ̃|�C���^���������B
  53. pBSt1->m_pIHAL=m_pIHAL;
  54. //�lj����悤�Ƃ��Ă����X�g���[����StreamControlHAL�C���^�t�F�[�X�ւ̃|�C���^���擾�������B
  55. if(SetHALStream(pBSt1, m_pIHAL) == FALSE){
  56. _RPTF0(_CRT_ERROR, "CAN'T GET STREAMCONTROLHAL\n");
  57. DBG_PRINTF(("CLASSLIB:CMPEGBOARD::AddStreamObjectInterface:CAN'T GET STREAMCONTROLHAL\n"));
  58. DBG_BREAK();
  59. return FALSE;
  60. }
  61. return TRUE;
  62. }
  63. //�Ǘ����ׂ��X�g���[�������̉���
  64. //�p�����[�^
  65. //IBaseStream�@���b�p�[�������X�g���[���N���X�̊��{�N���X�ւ̃|�C���^
  66. BOOL CMPEGBoard::ReleaseStreamObjectInterface(IBaseStream *IReleaseStreamObject)
  67. {
  68. CBaseStream *pBSt1;
  69. ASSERT(IReleaseStreamObject);
  70. //�������ׂ��X�g���[�����Ȃ��̂ŃG���[
  71. if(m_pBaseStreamObject == NULL){
  72. _RPTF0(_CRT_WARN, "NO ADDED STREAM\n");
  73. DBG_PRINTF(("CLASSLIB:CMPEGBOARD::ReleaseStreamObjectInterface:NO ADDED STREAM\n"));
  74. DBG_BREAK();
  75. return FALSE;
  76. }
  77. else{
  78. pBSt1 = (CBaseStream *)IReleaseStreamObject;
  79. //�����[�X���Ă͂����Ȃ��΂����������͂��H
  80. //�Ǘ����ׂ��X�g���[���̃`�F�[����������
  81. pBSt1->m_pPrevStreamObject->m_pNextStreamObject = pBSt1->m_pNextStreamObject;
  82. pBSt1->m_pNextStreamObject->m_pPrevStreamObject = pBSt1->m_pPrevStreamObject;
  83. //Transfer�I�u�W�F�N�g�ł��Ǘ����Ă����͂��Ȃ̂Ń����[�X
  84. ASSERT(((CBaseStream *)IReleaseStreamObject)->m_pTransfer);
  85. if(((CTransfer *)((CBaseStream *)IReleaseStreamObject)->m_pTransfer)->ReleaseStreamObject(IReleaseStreamObject) == FALSE){
  86. _RPTF0(_CRT_WARN, "NO RELEASE STREAM FROM TRANSFER OBJECT\n");
  87. DBG_PRINTF(("CLASSLIB:CMPEGBOARD::ReleaseStreamObjectInterface:CAN'T RELEASE STREAM FROM TRANSFER OBJECT\n"));
  88. DBG_BREAK();
  89. return FALSE;
  90. }
  91. }
  92. return TRUE;
  93. }
  94. //�d�����I���ɂ���
  95. BOOL CMPEGBoard::PowerOn()
  96. {
  97. return ChangePower(POWERSTATE_ON);
  98. }
  99. //�d�����I�t�ɂ���
  100. BOOL CMPEGBoard::PowerOff()
  101. {
  102. return ChangePower(POWERSTATE_OFF);
  103. }
  104. //STC�̒l���Z�b�g����
  105. BOOL CMPEGBoard::SetSTC(DWORD time)
  106. {
  107. //�܂����������I�����ĂȂ��B
  108. if(m_pIHAL == NULL || m_pBaseStreamObject == NULL){
  109. _RPTF0(_CRT_WARN, "NOT INITILIZE CMPEGBoard \n");
  110. DBG_PRINTF(("CLASSLIB:CMPEGBOARD::SetSTC:NOT BE INITILIZE CMPEGBoard CORRECTLY\n"));
  111. DBG_BREAK();
  112. return FALSE;
  113. }
  114. if(m_pIHAL->SetSTC(time) != HAL_SUCCESS){
  115. _RPTF0(_CRT_WARN, "CAN'T SETSTC \n");
  116. DBG_PRINTF(("CLASSLIB:CMPEGBOARD::SetSTC:CAN'T SETSTC \n"));
  117. DBG_BREAK();
  118. return FALSE;
  119. }
  120. return TRUE;
  121. }
  122. //STC�̒l���Q�b�g����
  123. //���^�[���l���l�������B
  124. BOOL CMPEGBoard::GetSTC(DWORD *foo) // 98.03.27 H.Yagi
  125. {
  126. DWORD Time;
  127. //�܂����������I�����ĂȂ��B
  128. if(m_pIHAL == NULL || m_pBaseStreamObject == NULL){
  129. _RPTF0(_CRT_ERROR, "NOT INITILIZE CMPEGBoard \n");
  130. *foo = 0xffffffff;
  131. return FALSE;
  132. }
  133. //STC�̎擾
  134. if(m_pIHAL->GetSTC(&Time) != HAL_SUCCESS){
  135. _RPTF0(_CRT_WARN, "CAN'T GETSTC \n");
  136. *foo = 0xffffffff;
  137. return FALSE; // 98.04.21 H.Yagi
  138. }
  139. *foo = Time;
  140. return TRUE;
  141. }
  142. //HAL�I�u�W�F�N�g�ւ̃C���^�t�F�[�X�̐ݒ�
  143. BOOL CMPEGBoard::SetHALObjectInterface(IClassLibHAL *pILibHAL)
  144. {
  145. CBaseStream *pStream;
  146. ASSERT(pILibHAL);
  147. m_pIHAL = pILibHAL;
  148. //10/14����
  149. for(pStream = m_pBaseStreamObject; pStream; pStream = (CBaseStream *)pStream->GetNextStream()){
  150. if(SetHALStream(pStream, m_pIHAL) == FALSE){
  151. _RPTF0(_CRT_ERROR, "CAN'T GET STREAMCONTROLHAL\n");
  152. DBG_PRINTF(("CLASSLIB:CMPEGBOARD::SetHALInterface:CAN'T GET STREAMCONTROLHAL\n"));
  153. DBG_BREAK();
  154. return FALSE;
  155. }
  156. }
  157. return TRUE;
  158. }
  159. //�d���̃I���I�t
  160. BOOL CMPEGBoard::ChangePower(POWERSTATE fOnOff)
  161. {
  162. CBaseStream *pBSt;
  163. IMPEGBoardBaseState *pState;
  164. //�܂����������I�����ĂȂ��B
  165. if(m_pIHAL == NULL || m_pBaseStreamObject == NULL ){
  166. _RPTF0(_CRT_WARN, "NOT INITILIZE CMPEGBoard \n");
  167. DBG_PRINTF(("CLASSLIB:CMPEGBOARD::ChangePower:NOT INITILIZE CMPEGBoard CRRECTLY\n"));
  168. DBG_BREAK();
  169. return FALSE;
  170. }
  171. else{
  172. for(pBSt = m_pBaseStreamObject; pBSt; pBSt = pBSt->m_pNextStreamObject){
  173. ASSERT(pBSt->m_pMPEGBoardStateObject);
  174. //BaseState(CPowerOffState, CStopState etc.�̊��{�N���X�j�ւ̃|�C���^���Ƃ��Ă���
  175. pState = pBSt->GetIMPEGBoardState();
  176. //���������������I�����ĂȂ��B
  177. if(pState == NULL){
  178. _RPTF0(_CRT_WARN, "NOT INITILIZE CMPEGBoard \n");
  179. DBG_PRINTF(("CLASSLIB:CMPEGBOARD::ChangePower:NOT INITILIZE CMPEGBoard \n"));
  180. DBG_BREAK();
  181. return FALSE;
  182. }
  183. //�d���̃X�e�[�^�X�ύX
  184. //�I�t�Ȃ�
  185. if(fOnOff == POWERSTATE_ON){
  186. if(!ISPOWEROFF()){
  187. //_RPTF0(_CRT_WARN, "STATE CHANGE ERROR From PowerON To PowerON\n");
  188. return TRUE;//FALSE�H�H�H
  189. }
  190. if(pState->ChangeStop(m_pIHAL, pBSt->GetHALStreamControl(), NULL) == FALSE){
  191. _RPTF0(_CRT_WARN, "CANT CHANGE POWERSTATE\n");
  192. DBG_PRINTF(("CLASSLIB:CMPEGBOARD::ChangePower:CANT CHANGE POWERSTATE\n"));
  193. DBG_BREAK();
  194. return FALSE;
  195. }
  196. }
  197. else{
  198. //// if(ISPOWEROFF()){
  199. //// //_RPTF0(_CRT_WARN, "STATE CHANGE ERROR From PowerOff To PowerOff\n");
  200. //// return TRUE;//FALSE???
  201. //// }
  202. if(pState->ChangePowerOff(m_pIHAL, pBSt->GetHALStreamControl()) == FALSE){
  203. _RPTF0(_CRT_WARN, "CANT CHANGE POWERSTATE");
  204. DBG_PRINTF(("CLASSLIB:CMPEGBOARD::ChangePower:CANT CHANGE POWERSTATE\n"));
  205. DBG_BREAK();
  206. return FALSE;
  207. }
  208. }
  209. }
  210. }
  211. return TRUE;
  212. }
  213. BOOL CMPEGBoard::ISPOWEROFF()
  214. {
  215. POWERSTATE PowerState;
  216. ASSERT(m_pIHAL);
  217. m_pIHAL->GetPowerState(&PowerState);
  218. if(PowerState == POWERSTATE_ON)
  219. return POWERSTATE_ON;
  220. else
  221. return POWERSTATE_OFF;
  222. }
  223. BOOL CMPEGBoard::SetHALStream(CBaseStream *pStream, IClassLibHAL *pIHAL)
  224. {
  225. HALRESULT st;
  226. ASSERT(pStream);
  227. //MIX�X�g���[���p
  228. if(ISMIXSTREAM(pStream->m_StreamType) == TRUE){
  229. if((st = pIHAL->GetMixHALStream(&pStream->m_pIStreamHAL)) != HAL_SUCCESS){
  230. if(st != HAL_NOT_IMPLEMENT){
  231. _RPTF0(_CRT_WARN, "NOT IMPLEMENT");
  232. }
  233. //���ۂɃC���v�������g�����Ȃ��̂͋��������H�H�H
  234. _RPTF0(_CRT_WARN, "CAN'T GET MIXHALSTREAM INTERFACE\n");
  235. DBG_PRINTF(("CLASSLIB:CMPEGBOARD::ChangePower:CAN'T GET MIXHALSTREAM INTERFACE\n"));
  236. DBG_BREAK();
  237. return FALSE;
  238. }
  239. }
  240. //�P�ƃX�g���[���p
  241. else{
  242. switch(pStream->m_StreamType){
  243. case Video:
  244. st = pIHAL->GetVideoHALStream(&pStream->m_pIStreamHAL);
  245. break;
  246. case Audio:
  247. st = pIHAL->GetAudioHALStream(&pStream->m_pIStreamHAL);
  248. break;
  249. case Subpicture:
  250. st = pIHAL->GetSubpicHALStream(&pStream->m_pIStreamHAL);
  251. break;
  252. default:
  253. _RPTF0(_CRT_WARN, "INVALID STREAMTYPE\n");
  254. DBG_PRINTF(("CLASSLIB:CMPEGBOARD::SetHALStream:INVALID STREAMTYPE\n"));
  255. DBG_BREAK();
  256. return FALSE;
  257. }
  258. if(st != HAL_SUCCESS){
  259. _RPTF0(_CRT_WARN, "INVALID STREAMTYPE\n");
  260. DBG_PRINTF(("CLASSLIB:CMPEGBOARD::SetHALStream:INVALID STREAMTYPE\n"));
  261. DBG_BREAK();
  262. return FALSE;
  263. }
  264. }
  265. return TRUE;
  266. }