1
0

WaitLayer.cpp 775 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #include "main.h"
  2. #include "WaitLayer.h"
  3. #include "util.h"
  4. WaitLayer::WaitLayer(IWMReader *_reader)
  5. : reader(_reader), stopEvent(0)
  6. {
  7. reader->AddRef();
  8. openEvent = CreateEvent(0, TRUE, FALSE, 0);
  9. }
  10. WaitLayer::~WaitLayer()
  11. {
  12. reader->Release();
  13. reader=0;
  14. }
  15. void WaitLayer::Opened()
  16. {
  17. SetEvent(openEvent);
  18. WMHandler::Opened();
  19. }
  20. bool WaitLayer::IsOpen()
  21. {
  22. return WaitForSingleObject(openEvent, 0) == WAIT_OBJECT_0;
  23. }
  24. void WaitLayer::OpenCalled()
  25. {
  26. SetEvent(openEvent);
  27. WMHandler::OpenCalled();
  28. }
  29. void WaitLayer::OpenFailed()
  30. {
  31. SetEvent(openEvent);
  32. WMHandler::OpenFailed();
  33. }
  34. bool WaitLayer::WaitForOpen(int time_ms)
  35. {
  36. return WaitForSingleObject(openEvent, time_ms) == WAIT_OBJECT_0;
  37. }
  38. void WaitLayer::ResetForOpen()
  39. {
  40. ResetEvent(openEvent);
  41. }