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.

117 lines
2.2 KiB

  1. //**************************************************************************
  2. //
  3. // Title : CCQue.cpp
  4. //
  5. // Date : 1998.05.06 1st making
  6. //
  7. // Author : Toshiba [PCS](PSY) Hideki Yagi
  8. //
  9. // Copyright 1997 Toshiba Corporation. All Rights Reserved.
  10. //
  11. // -------------------------------------------------------------------------
  12. //
  13. // Change log :
  14. //
  15. // Date Revision Description
  16. // ------------ ---------- -----------------------------------------------
  17. // 1998.05.06 000.0000 1st making.
  18. //
  19. //**************************************************************************
  20. #include "includes.h"
  21. #include "ccque.h"
  22. #include "wdmbuff.h"
  23. #include "dvdinit.h"
  24. CCQueue::CCQueue( void )
  25. {
  26. count = 0;
  27. top = bottom = NULL;
  28. }
  29. CCQueue::~CCQueue( void )
  30. {
  31. count = 0;
  32. top = bottom = NULL;
  33. }
  34. void CCQueue::Init( void )
  35. {
  36. count = 0;
  37. top = bottom = NULL;
  38. }
  39. void CCQueue::put( PHW_STREAM_REQUEST_BLOCK pSrb )
  40. {
  41. pSrb->NextSRB = NULL;
  42. if( top == NULL ){
  43. top = bottom = pSrb;
  44. count++;
  45. return;
  46. }
  47. bottom->NextSRB = pSrb;
  48. bottom = pSrb;
  49. count++;
  50. return;
  51. }
  52. PHW_STREAM_REQUEST_BLOCK CCQueue::get( void )
  53. {
  54. PHW_STREAM_REQUEST_BLOCK srb;
  55. if( top == NULL ){
  56. return( NULL );
  57. }
  58. srb = top;
  59. top = top->NextSRB;
  60. count--;
  61. if( count==0 ){
  62. top = bottom = NULL;
  63. }
  64. return( srb );
  65. }
  66. BOOL CCQueue::remove( PHW_STREAM_REQUEST_BLOCK pSrb )
  67. {
  68. if( top == NULL ){
  69. return( FALSE );
  70. }
  71. if( top == pSrb ){
  72. top = top->NextSRB;
  73. count--;
  74. if( count==0 )
  75. top = bottom = NULL;
  76. return( TRUE );
  77. }
  78. PHW_STREAM_REQUEST_BLOCK srbPrev;
  79. PHW_STREAM_REQUEST_BLOCK srb;
  80. srbPrev = top;
  81. srb = srbPrev->NextSRB;
  82. while( srb!=NULL ){
  83. if( srb==pSrb ){
  84. srbPrev->NextSRB = srb->NextSRB;
  85. if( srb == bottom ){
  86. bottom = srbPrev;
  87. }
  88. count--;
  89. return( TRUE );
  90. // break;
  91. }
  92. srbPrev = srb;
  93. srb = srbPrev->NextSRB;
  94. }
  95. return( FALSE );
  96. }