diff options
author | Klaus Schmidinger <kls (at) cadsoft (dot) de> | 2005-11-27 18:00:00 +0100 |
---|---|---|
committer | Klaus Schmidinger <kls (at) cadsoft (dot) de> | 2005-11-27 18:00:00 +0100 |
commit | 8c63e0fd967a7ac037872ca5af378dc92f0410fa (patch) | |
tree | 7f9632af6990a149944b0bb113ee7fac102e99d9 /skins.c | |
parent | 812ab9018c7be7feb901eface4c6431b483ca9ec (diff) | |
download | vdr-patch-lnbsharing-8c63e0fd967a7ac037872ca5af378dc92f0410fa.tar.gz vdr-patch-lnbsharing-8c63e0fd967a7ac037872ca5af378dc92f0410fa.tar.bz2 |
Version 1.3.37vdr-1.3.37
- Added compiler options "-fPIC -g" to all plugins (thanks to Rolf Ahrenberg).
- Fixed initializing the day index when editing the weekday parameter of a
repeating timer (thanks to Marco Schlüßler).
- No longer removing superfluous hyphens in EPG data - would become too
language dependent to handle all kinds of exceptions.
- Modified switching to Dolby Digital audio in live mode, if the driver
and firmware can handle live DD without the need of a Transfer Mode (thanks
to Werner Fink). Live DD mode requires a full featured DVB card and a
LinuxDVB driver with firmware version 0x2622 or higher. Older versions will
use Transfer Mode just like before.
- Implemented handling of the "CA PMT Reply" for CAMs (thanks to Marco
Schlüßler for figuring out some obscure length bytes in the CA PMT Reply
data of AlphaCrypt CAMs).
- Some preparations for being able to record several encrypted channels from
the same transponder at the same time (or record and view different encrypted
channels), provided the CAM in use can handle this. This is work in progress
and isn't actively used, yet.
- Fixed SetProgress() in the 'skincurses' plugin in case Total is 0 (reported
by Stefan Huelswitt).
- Added a copy constructor to cString and fixed its assignment operator
(thanks to Holger Brunn).
- The new function Skins.QueueMessage() can be called from a background thread
to queue a message for display. See VDR/skins.h for details.
- The SVDRP command MESG uses the new message queueing facility, so MESG
commands may now be executed at any time, and the message will be displayed
(no more "pending message").
Diffstat (limited to 'skins.c')
-rw-r--r-- | skins.c | 129 |
1 files changed, 127 insertions, 2 deletions
@@ -4,13 +4,49 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: skins.c 1.5 2005/10/02 10:12:10 kls Exp $ + * $Id: skins.c 1.6 2005/11/27 15:52:25 kls Exp $ */ #include "skins.h" #include "interface.h" #include "status.h" -#include "tools.h" + +// --- cSkinQueuedMessage ---------------------------------------------------- + +class cSkinQueuedMessage : public cListObject { + friend class cSkins; +private: + eMessageType type; + char *message; + int seconds; + int timeout; + tThreadId threadId; + eKeys key; + int state; + cMutex mutex; + cCondVar condVar; +public: + cSkinQueuedMessage(eMessageType Type, const char *s, int Seconds, int Timeout); + virtual ~cSkinQueuedMessage(); + }; + +cSkinQueuedMessage::cSkinQueuedMessage(eMessageType Type, const char *s, int Seconds, int Timeout) +{ + type = Type; + message = s ? strdup(s) : NULL; + seconds = Seconds; + timeout = Timeout; + threadId = cThread::ThreadId(); + key = kNone; + state = 0; // waiting +} + +cSkinQueuedMessage::~cSkinQueuedMessage() +{ + free(message); +} + +cList<cSkinQueuedMessage> SkinQueuedMessages; // --- cSkinDisplay ---------------------------------------------------------- @@ -202,6 +238,95 @@ eKeys cSkins::Message(eMessageType Type, const char *s, int Seconds) return k; } +int cSkins::QueueMessage(eMessageType Type, const char *s, int Seconds, int Timeout) +{ + if (Type == mtStatus) { + dsyslog("cSkins::QueueMessage() called with mtStatus - ignored!"); + return kNone; + } + if (isempty(s)) { + dsyslog("cSkins::QueueMessage() called with empty message - ignored!"); + return kNone; + } + int k = kNone; + if (Timeout > 0) { + if (cThread::IsMainThread()) { + dsyslog("cSkins::QueueMessage() called from main thread with Timeout = %d - ignored!", Timeout); + return k; + } + cSkinQueuedMessage *m = new cSkinQueuedMessage(Type, s, Seconds, Timeout); + queueMessageMutex.Lock(); + SkinQueuedMessages.Add(m); + m->mutex.Lock(); + queueMessageMutex.Unlock(); + if (m->condVar.TimedWait(m->mutex, Timeout * 1000)) + k = m->key; + else + k = -1; // timeout, nothing has been displayed + m->state = 2; // done + m->mutex.Unlock(); + } + else { + queueMessageMutex.Lock(); + // Check if there is a waiting message w/o timeout for this thread: + if (Timeout == -1) { + for (cSkinQueuedMessage *m = SkinQueuedMessages.Last(); m; m = SkinQueuedMessages.Prev(m)) { + if (m->threadId == cThread::ThreadId()) { + if (m->state == 0 && m->timeout == -1) + m->state = 2; // done + break; + } + } + } + // Add the new message: + SkinQueuedMessages.Add(new cSkinQueuedMessage(Type, s, Seconds, Timeout)); + queueMessageMutex.Unlock(); + } + return k; +} + +void cSkins::ProcessQueuedMessages(void) +{ + if (!cThread::IsMainThread()) { + dsyslog("cSkins::ProcessQueuedMessages() called from background thread - ignored!"); + return; + } + cSkinQueuedMessage *msg = NULL; + // Get the first waiting message: + queueMessageMutex.Lock(); + for (cSkinQueuedMessage *m = SkinQueuedMessages.First(); m; m = SkinQueuedMessages.Next(m)) { + if (m->state == 0) { // waiting + m->state = 1; // active + msg = m; + break; + } + } + queueMessageMutex.Unlock(); + // Display the message: + if (msg) { + msg->mutex.Lock(); + if (msg->state == 1) { // might have changed since we got it + msg->key = Skins.Message(msg->type, msg->message, msg->seconds); + if (msg->timeout == 0) + msg->state = 2; // done + else + msg->condVar.Broadcast(); + } + msg->mutex.Unlock(); + } + // Remove done messages from the queue: + queueMessageMutex.Lock(); + for (;;) { + cSkinQueuedMessage *m = SkinQueuedMessages.First(); + if (m && m->state == 2) { // done + SkinQueuedMessages.Del(m); + } + else + break; + } + queueMessageMutex.Unlock(); +} + void cSkins::Flush(void) { if (cSkinDisplay::Current()) |