diff options
author | Jean-Francois Mauguit <jfmauguit@mac.com> | 2024-09-24 09:03:25 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-24 09:03:25 -0400 |
commit | bab614c421ed7ae329d26bf028c4a3b1d2450f5a (patch) | |
tree | 12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/nu/VideoClock.h | |
parent | 4bde6044fddf053f31795b9eaccdd2a5a527d21f (diff) | |
parent | 20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (diff) | |
download | winamp-bab614c421ed7ae329d26bf028c4a3b1d2450f5a.tar.gz |
Merge pull request #5 from WinampDesktop/community
Merge to main
Diffstat (limited to 'Src/nu/VideoClock.h')
-rw-r--r-- | Src/nu/VideoClock.h | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/Src/nu/VideoClock.h b/Src/nu/VideoClock.h new file mode 100644 index 00000000..0ff82cf0 --- /dev/null +++ b/Src/nu/VideoClock.h @@ -0,0 +1,63 @@ +#pragma once +#include <windows.h> + +namespace nu +{ +class VideoClock +{ +public: + VideoClock() + { + video_sync_start_time=0; + pause_start_time=0; + length_paused=0; + paused=0; + } + + void Reset() + { + length_paused = 0; + paused=0; + } + + void Pause() + { + paused=1; + pause_start_time = GetTickCount(); + } + + void Unpause() + { + paused=0; + length_paused += (GetTickCount() - pause_start_time); + } + + int GetOutputTime() + { + if (paused) + { + return pause_start_time - video_sync_start_time - length_paused; + } + else + { + return GetTickCount() - video_sync_start_time - length_paused; + } + } + + void Seek(int time_ms) + { + video_sync_start_time = GetTickCount() - time_ms; + length_paused = 0; + } + + void Start() + { + video_sync_start_time = GetTickCount(); + } +private: + DWORD video_sync_start_time; + DWORD pause_start_time; + DWORD length_paused; + int paused; +}; +}
\ No newline at end of file |