[vdr] Memory access error while attach player?
Patrick Fischer
patrick_fischer at gmx.de
Mon Dec 19 11:25:48 CET 2005
After hours of tests I found a solution for my thread problems.
I use the workaround specified below and I need to patch the player.c
and player.h to make it thread save. The patch is attached.
There were two problems:
-if the mainloop will work with my ReplayControl before it is attached
it will crash(fixed by workaround)
-cControl were not thread safe (fixed by patch)
I hope it will help somebody and maybe Klaus will include my
cControlThreadSavePatch.
Greeting
Patrick
> now I have written a workaround and it works.
>
> I have written cMyReplayControl inherit from cReplayControl.
>
>
> //---------------cIvvonReplayControl.h-------------------
> class cIvvonReplayControl: public cReplayControl{
> public:
> cIvvonReplayControl();
> virtual ~cIvvonReplayControl();
> eOSState ProcessKey(eKeys Key); };
> //---------------cIvvonReplayControl.c-------------------
> cMyReplayControl::cMyReplayControl():cReplayControl(){}
>
> cMyReplayControl::~cMyReplayControl(){}
>
> eOSState cMyReplayControl::ProcessKey(eKeys Key){
> if(!cReplayControl::Active()){
> dsyslog("ReplayControl is not Active. Use workaround1");
> cControl::Attach(); }
> eOSState tmp = cReplayControl::ProcessKey(Key);
> if(tmp==osEnd){
> dsyslog("ReplayControl is not Active. Use workaround2");
> cControl::Attach();
> tmp = cReplayControl::ProcessKey(Key);
> }
> if(tmp==osEnd){
> //only for debug
> dsyslog("cMyPlayerControl is still not attached and Active!!!!!");
> exit(0); }
> return tmp;
> }
>
-------------- next part --------------
--- ./vdr-1.3.35/player.c 2005-11-02 08:40:23.000000000 +0100
+++ ./vdr-1.3.37/player.c 2005-12-19 10:41:38.000000000 +0100
@@ -40,6 +40,7 @@
// --- cControl --------------------------------------------------------------
cControl *cControl::control = NULL;
+cMutex cControl::mutex;
cControl::cControl(cPlayer *Player, bool Hidden)
{
@@ -61,12 +62,14 @@
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 +82,7 @@
void cControl::Shutdown(void)
{
+ cMutexLock MutexLock(&mutex);
cControl *c = control; // avoids recursions
control = NULL;
delete c;
-------------- next part --------------
--- ./vdr-1.3.35/player.h 2005-11-02 08:40:23.000000000 +0100
+++ ./vdr-1.3.37/player.h 2005-12-19 10:41:58.000000000 +0100
@@ -62,6 +62,7 @@
class cControl : public cOsdObject {
private:
static cControl *control;
+ static cMutex mutex;
bool attached;
bool hidden;
protected:
More information about the vdr
mailing list