vdr 2.8.4
status.c
Go to the documentation of this file.
1/*
2 * status.c: Status monitoring
3 *
4 * See the main source file 'vdr.c' for copyright information and
5 * how to reach the author.
6 *
7 * $Id: status.c 5.6 2026/10/25 14:49:46 kls Exp $
8 */
9
10#include "status.h"
11#include "thread.h"
12
13// --- cStatus ---------------------------------------------------------------
14
16
18static cVector<cStatus *> InUse; // status monitors a thread is currently calling, so that ~cStatus() can wait for them
19
20// The mutex is not held during the callbacks: they may take any lock (an output
21// plugin attaches the player in ChannelSwitch()), and the main thread sends
22// messages while it holds the cControl mutex.
23static cStatus *NextMonitor(cList<cStatus> &Monitors, cStatus *This)
24{
25 cMutexLock MutexLock(&Mutex);
26 if (This)
27 InUse.Remove(InUse.IndexOf(This));
28 cStatus *sm = This ? Monitors.Next(This) : Monitors.First();
29 if (sm)
30 InUse.Append(sm);
31 return sm;
32}
33
35{
36 Mutex.Lock();
37 statusMonitors.Add(this);
38 Mutex.Unlock();
39}
40
42{
43 Mutex.Lock();
44 while (InUse.IndexOf(this) >= 0) { // another thread is inside one of this monitor's callbacks
45 Mutex.Unlock();
47 Mutex.Lock();
48 }
49 statusMonitors.Del(this, false);
50 Mutex.Unlock();
51}
52
54{
55 for (cStatus *sm = NextMonitor(statusMonitors, NULL); sm; sm = NextMonitor(statusMonitors, sm))
56 sm->ChannelChange(Channel);
57}
58
60{
61 for (cStatus *sm = NextMonitor(statusMonitors, NULL); sm; sm = NextMonitor(statusMonitors, sm))
62 sm->TimerChange(Timer, Change);
63}
64
65void cStatus::MsgChannelSwitch(const cDevice *Device, int ChannelNumber, bool LiveView)
66{
67 for (cStatus *sm = NextMonitor(statusMonitors, NULL); sm; sm = NextMonitor(statusMonitors, sm))
68 sm->ChannelSwitch(Device, ChannelNumber, LiveView);
69}
70
71void cStatus::MsgRecording(const cDevice *Device, const char *Name, const char *FileName, bool On)
72{
73 for (cStatus *sm = NextMonitor(statusMonitors, NULL); sm; sm = NextMonitor(statusMonitors, sm))
74 sm->Recording(Device, Name, FileName, On);
75}
76
77void cStatus::MsgReplaying(const cControl *Control, const char *Name, const char *FileName, bool On)
78{
79 for (cStatus *sm = NextMonitor(statusMonitors, NULL); sm; sm = NextMonitor(statusMonitors, sm))
80 sm->Replaying(Control, Name, FileName, On);
81}
82
84{
85 for (cStatus *sm = NextMonitor(statusMonitors, NULL); sm; sm = NextMonitor(statusMonitors, sm))
86 sm->MarksModified(Marks);
87}
88
89void cStatus::MsgSetVolume(int Volume, bool Absolute)
90{
91 for (cStatus *sm = NextMonitor(statusMonitors, NULL); sm; sm = NextMonitor(statusMonitors, sm))
92 sm->SetVolume(Volume, Absolute);
93}
94
95void cStatus::MsgSetAudioTrack(int Index, const char * const *Tracks)
96{
97 for (cStatus *sm = NextMonitor(statusMonitors, NULL); sm; sm = NextMonitor(statusMonitors, sm))
98 sm->SetAudioTrack(Index, Tracks);
99}
100
101void cStatus::MsgSetAudioChannel(int AudioChannel)
102{
103 for (cStatus *sm = NextMonitor(statusMonitors, NULL); sm; sm = NextMonitor(statusMonitors, sm))
104 sm->SetAudioChannel(AudioChannel);
105}
106
107void cStatus::MsgSetSubtitleTrack(int Index, const char * const *Tracks)
108{
109 for (cStatus *sm = NextMonitor(statusMonitors, NULL); sm; sm = NextMonitor(statusMonitors, sm))
110 sm->SetSubtitleTrack(Index, Tracks);
111}
112
114{
115 for (cStatus *sm = NextMonitor(statusMonitors, NULL); sm; sm = NextMonitor(statusMonitors, sm))
116 sm->OsdClear();
117}
118
119void cStatus::MsgOsdTitle(const char *Title)
120{
121 for (cStatus *sm = NextMonitor(statusMonitors, NULL); sm; sm = NextMonitor(statusMonitors, sm))
122 sm->OsdTitle(Title);
123}
124
125void cStatus::MsgOsdStatusMessage(eMessageType Type, const char *Message)
126{
127 for (cStatus *sm = NextMonitor(statusMonitors, NULL); sm; sm = NextMonitor(statusMonitors, sm))
128 sm->OsdStatusMessage(Type, Message);
129}
130
131void cStatus::MsgOsdHelpKeys(const char *Red, const char *Green, const char *Yellow, const char *Blue)
132{
133 for (cStatus *sm = NextMonitor(statusMonitors, NULL); sm; sm = NextMonitor(statusMonitors, sm))
134 sm->OsdHelpKeys(Red, Green, Yellow, Blue);
135}
136
137void cStatus::MsgOsdItem(const char *Text, int Index, bool Selectable)
138{
139 for (cStatus *sm = NextMonitor(statusMonitors, NULL); sm; sm = NextMonitor(statusMonitors, sm))
140 sm->OsdItem(Text, Index, Selectable);
141}
142
143void cStatus::MsgOsdCurrentItem(const char *Text, int Index)
144{
145 for (cStatus *sm = NextMonitor(statusMonitors, NULL); sm; sm = NextMonitor(statusMonitors, sm))
146 sm->OsdCurrentItem(Text, Index);
147}
148
149void cStatus::MsgOsdTextItem(const char *Text, bool Scroll)
150{
151 for (cStatus *sm = NextMonitor(statusMonitors, NULL); sm; sm = NextMonitor(statusMonitors, sm))
152 sm->OsdTextItem(Text, Scroll);
153}
154
155void cStatus::MsgOsdChannel(const char *Text)
156{
157 for (cStatus *sm = NextMonitor(statusMonitors, NULL); sm; sm = NextMonitor(statusMonitors, sm))
158 sm->OsdChannel(Text);
159}
160
161void cStatus::MsgOsdProgramme(time_t PresentTime, const char *PresentTitle, const char *PresentSubtitle, time_t FollowingTime, const char *FollowingTitle, const char *FollowingSubtitle)
162{
163 for (cStatus *sm = NextMonitor(statusMonitors, NULL); sm; sm = NextMonitor(statusMonitors, sm))
164 sm->OsdProgramme(PresentTime, PresentTitle, PresentSubtitle, FollowingTime, FollowingTitle, FollowingSubtitle);
165}
static void SleepMs(int TimeoutMs)
Creates a cCondWait object and uses it to sleep for TimeoutMs milliseconds, immediately giving up the...
Definition thread.c:73
void Del(cListObject *Object, bool DeleteObject=true)
Definition tools.c:2260
void Add(cListObject *Object, cListObject *After=NULL)
Definition tools.c:2228
int Index(void) const
Definition tools.c:2148
Definition tools.h:650
const T * First(void) const
Returns the first element in this list, or NULL if the list is empty.
Definition tools.h:662
const T * Next(const T *Object) const
< Returns the element immediately before Object in this list, or NULL if Object is the first element ...
Definition tools.h:669
bool Lock(int TimeoutMs=0, bool *TimedOut=NULL)
Returns true if the mutex was successfully locked.
Definition thread.c:228
void Unlock(void)
Definition thread.c:252
static void MsgMarksModified(const cMarks *Marks)
Definition status.c:83
static void MsgOsdTitle(const char *Title)
Definition status.c:119
static void MsgOsdChannel(const char *Text)
Definition status.c:155
cStatus(void)
Definition status.c:34
static void MsgOsdItem(const char *Text, int Index, bool Selectable=true)
Definition status.c:137
static void MsgOsdHelpKeys(const char *Red, const char *Green, const char *Yellow, const char *Blue)
Definition status.c:131
static void MsgOsdStatusMessage(const char *Message)
Definition status.h:125
static void MsgSetAudioChannel(int AudioChannel)
Definition status.c:101
static void MsgOsdProgramme(time_t PresentTime, const char *PresentTitle, const char *PresentSubtitle, time_t FollowingTime, const char *FollowingTitle, const char *FollowingSubtitle)
Definition status.c:161
static void MsgReplaying(const cControl *Control, const char *Name, const char *FileName, bool On)
Definition status.c:77
static void MsgSetVolume(int Volume, bool Absolute)
Definition status.c:89
static void MsgRecording(const cDevice *Device, const char *Name, const char *FileName, bool On)
Definition status.c:71
static cList< cStatus > statusMonitors
Definition status.h:38
static void MsgOsdClear(void)
Definition status.c:113
static void MsgChannelChange(const cChannel *Channel)
Definition status.c:53
static void MsgSetAudioTrack(int Index, const char *const *Tracks)
Definition status.c:95
static void MsgOsdCurrentItem(const char *Text, int Index=-1)
Definition status.c:143
static void MsgTimerChange(const cTimer *Timer, eTimerChange Change)
Definition status.c:59
static void MsgOsdTextItem(const char *Text, bool Scroll=false)
Definition status.c:149
static void MsgSetSubtitleTrack(int Index, const char *const *Tracks)
Definition status.c:107
static void MsgChannelSwitch(const cDevice *Device, int ChannelNumber, bool LiveView)
Definition status.c:65
virtual ~cStatus() override
Definition status.c:41
static cMutex Mutex
Definition epg.c:1439
eMessageType
Definition skins.h:37
static cVector< cStatus * > InUse
Definition status.c:18
static cMutex Mutex
Definition status.c:17
static cStatus * NextMonitor(cList< cStatus > &Monitors, cStatus *This)
Definition status.c:23
eTimerChange
Definition status.h:32