Stopper.cpp 1.2 KB

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