1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

Made the static cControl functions thread safe

This commit is contained in:
Klaus Schmidinger 2006-01-01 14:46:24 +01:00
parent fef0b70bb1
commit 7d84ddefb3
4 changed files with 10 additions and 2 deletions

View File

@ -1554,6 +1554,7 @@ Nicolas Huillard <nhuillard@e-dition.fr>
Patrick Fischer <patrick_fischer@gmx.de> Patrick Fischer <patrick_fischer@gmx.de>
for reporting an error in the cFilter example in PLUGINS.html for reporting an error in the cFilter example in PLUGINS.html
for making the static cControl functions thread safe
Ralf Müller <ralf@bj-ig.de> Ralf Müller <ralf@bj-ig.de>
for a patch that was used to implement cUnbufferedFile for a patch that was used to implement cUnbufferedFile

View File

@ -4057,3 +4057,4 @@ Video Disk Recorder Revision History
Jürgen Schneider). Jürgen Schneider).
- Removed unused variables in skinclassic.c and skinsttng.c (thanks to Marco - Removed unused variables in skinclassic.c and skinsttng.c (thanks to Marco
Schlüßler). Schlüßler).
- Made the static cControl functions thread safe (thanks to Patrick Fischer).

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: player.c 1.9 2004/12/12 11:21:07 kls Exp $ * $Id: player.c 1.10 2006/01/01 14:45:36 kls Exp $
*/ */
#include "player.h" #include "player.h"
@ -40,6 +40,7 @@ void cPlayer::Detach(void)
// --- cControl -------------------------------------------------------------- // --- cControl --------------------------------------------------------------
cControl *cControl::control = NULL; cControl *cControl::control = NULL;
cMutex cControl::mutex;
cControl::cControl(cPlayer *Player, bool Hidden) cControl::cControl(cPlayer *Player, bool Hidden)
{ {
@ -56,17 +57,20 @@ cControl::~cControl()
cControl *cControl::Control(void) cControl *cControl::Control(void)
{ {
cMutexLock MutexLock(&mutex);
return (control && !control->hidden) ? control : NULL; return (control && !control->hidden) ? control : NULL;
} }
void cControl::Launch(cControl *Control) void cControl::Launch(cControl *Control)
{ {
cMutexLock MutexLock(&mutex);
delete control; delete control;
control = Control; control = Control;
} }
void cControl::Attach(void) void cControl::Attach(void)
{ {
cMutexLock MutexLock(&mutex);
if (control && !control->attached && control->player && !control->player->IsAttached()) { if (control && !control->attached && control->player && !control->player->IsAttached()) {
if (cDevice::PrimaryDevice()->AttachPlayer(control->player)) if (cDevice::PrimaryDevice()->AttachPlayer(control->player))
control->attached = true; control->attached = true;
@ -79,6 +83,7 @@ void cControl::Attach(void)
void cControl::Shutdown(void) void cControl::Shutdown(void)
{ {
cMutexLock MutexLock(&mutex);
cControl *c = control; // avoids recursions cControl *c = control; // avoids recursions
control = NULL; control = NULL;
delete c; delete c;

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: player.h 1.17 2005/05/22 11:07:42 kls Exp $ * $Id: player.h 1.18 2006/01/01 14:43:10 kls Exp $
*/ */
#ifndef __PLAYER_H #ifndef __PLAYER_H
@ -62,6 +62,7 @@ public:
class cControl : public cOsdObject { class cControl : public cOsdObject {
private: private:
static cControl *control; static cControl *control;
static cMutex mutex;
bool attached; bool attached;
bool hidden; bool hidden;
protected: protected: