]> git.vomp.tv Git - vompclient.git/blob - sleeptimer.h
Switch from deprecated libavresample to libswresample. Some AudioOMX CWFs
[vompclient.git] / sleeptimer.h
1 /*
2     Copyright 2008 Thomas Steger
3     Copyright 2020 Chris Tallon
4
5     This file is part of VOMP.
6
7     VOMP is free software; you can redistribute it and/or modify
8     it under the terms of the GNU General Public License as published by
9     the Free Software Foundation; either version 2 of the License, or
10     (at your option) any later version.
11
12     VOMP is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15     GNU General Public License for more details.
16
17     You should have received a copy of the GNU General Public License
18     along with VOMP.  If not, see <https://www.gnu.org/licenses/>.
19 */
20
21 #ifndef SLEEPTIMER_H
22 #define SLEEPTIMER_H
23
24 #include <chrono>
25 #include "defines.h"
26 #include "boxx.h"
27 #include "wsymbol.h"
28 #include "timers.h"
29
30 class Log;
31 class BoxStack;
32 class VSleepTimer;
33 class VCountdown;
34
35 class SleepTimer : public TimerReceiver
36 {
37  public:
38    SleepTimer();
39    void go();
40    void timercall(int clientReference);
41    void shutdown();
42
43  private:
44    Log* logger{};
45    BoxStack* boxstack{};
46    Timers* timers{};
47
48    void calcNewTime();
49    void calcCurrentSec();
50
51    int sec{-1};
52    const char* timerText;
53    char liveText[10];
54    std::chrono::system_clock::time_point endTime;
55
56    std::mutex stateLock;
57    UINT state{0};
58    /* 0 = inactive
59     * 1 = counting - no displays
60     * 2 = counting - modify display showing
61     * 3 = counting - countdown display showing
62     * 4 - not counting - OFF dialogue showing
63     */
64
65    VSleepTimer* vsleeptimer{};
66    VCountdown* vcountdown{};
67 };
68
69 class VSleepTimer : public Boxx
70 {
71   public:
72     VSleepTimer();
73     void setTime(const char* text);
74     void draw();
75
76   private:
77     WSymbol wsClock;
78     const char* displaySleeptimer;
79 };
80
81 class VCountdown : public Boxx
82 {
83   public:
84     VCountdown();
85     void setTime(int sec);
86     void draw();
87
88   private:
89     WSymbol wsClock;
90     int sec;
91 };
92
93 #endif