mirror of
https://github.com/vdr-projects/vdr.git
synced 2025-12-27 07:11:05 +01:00
Made the static cControl functions thread safe
This commit is contained in:
7
player.c
7
player.c
@@ -4,7 +4,7 @@
|
||||
* See the main source file 'vdr.c' for copyright information and
|
||||
* 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"
|
||||
@@ -40,6 +40,7 @@ void cPlayer::Detach(void)
|
||||
// --- cControl --------------------------------------------------------------
|
||||
|
||||
cControl *cControl::control = NULL;
|
||||
cMutex cControl::mutex;
|
||||
|
||||
cControl::cControl(cPlayer *Player, bool Hidden)
|
||||
{
|
||||
@@ -56,17 +57,20 @@ cControl::~cControl()
|
||||
|
||||
cControl *cControl::Control(void)
|
||||
{
|
||||
cMutexLock MutexLock(&mutex);
|
||||
return (control && !control->hidden) ? control : NULL;
|
||||
}
|
||||
|
||||
void cControl::Launch(cControl *Control)
|
||||
{
|
||||
cMutexLock MutexLock(&mutex);
|
||||
delete control;
|
||||
control = Control;
|
||||
}
|
||||
|
||||
void cControl::Attach(void)
|
||||
{
|
||||
cMutexLock MutexLock(&mutex);
|
||||
if (control && !control->attached && control->player && !control->player->IsAttached()) {
|
||||
if (cDevice::PrimaryDevice()->AttachPlayer(control->player))
|
||||
control->attached = true;
|
||||
@@ -79,6 +83,7 @@ void cControl::Attach(void)
|
||||
|
||||
void cControl::Shutdown(void)
|
||||
{
|
||||
cMutexLock MutexLock(&mutex);
|
||||
cControl *c = control; // avoids recursions
|
||||
control = NULL;
|
||||
delete c;
|
||||
|
||||
Reference in New Issue
Block a user