1
0

Stopper.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include "Stopper.h"
  2. #include "main.h"
  3. #include "../Winamp/wa_ipc.h"
  4. int m_force_seek=-1;
  5. Stopper::Stopper() : isplaying(0), timems(0)
  6. {
  7. }
  8. void Stopper::ChangeTracking(bool mode)
  9. {
  10. SendMessage(mod.hMainWindow, WM_USER, mode, IPC_ALLOW_PLAYTRACKING); // enable / disable stats updating
  11. }
  12. void Stopper::Stop()
  13. {
  14. isplaying = SendMessage(mod.hMainWindow, WM_USER, 0, IPC_ISPLAYING);
  15. if (isplaying)
  16. {
  17. ChangeTracking(0); // disable stats updating
  18. timems = SendMessage(mod.hMainWindow, WM_USER, 0, IPC_GETOUTPUTTIME);
  19. SendMessage(mod.hMainWindow, WM_COMMAND, 40047, 0); // Stop
  20. }
  21. }
  22. void Stopper::Play()
  23. {
  24. if (isplaying) // this works _most_ of the time, not sure why a small portion of the time it doesnt hrmph :/
  25. // ideally we should replace it with a system that pauses the decode thread, closes its file,
  26. // does the shit, and reopens and reseeks to the new offset. for gaplessness
  27. {
  28. if (timems)
  29. {
  30. m_force_seek = timems; // SendMessage(mod.hMainWindow,WM_USER,timems,106);
  31. }
  32. else m_force_seek = -1;
  33. SendMessage(mod.hMainWindow, WM_COMMAND, 40045, 0); // Play
  34. m_force_seek = -1;
  35. if (isplaying & 2)
  36. {
  37. SendMessage(mod.hMainWindow, WM_COMMAND, 40046, 0); // Pause
  38. }
  39. ChangeTracking(1); // enable stats updating
  40. }
  41. isplaying = 0;
  42. }