From patchwork Mon Dec 19 10:25:48 2005 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Fischer X-Patchwork-Id: 12124 Received: from mail.gmx.de ([213.165.64.21] helo=mail.gmx.net) by www.linuxtv.org with smtp (Exim 4.50) id 1EoIC0-0005eR-Us for vdr@linuxtv.org; Mon, 19 Dec 2005 11:24:32 +0100 Received: (qmail invoked by alias); 19 Dec 2005 10:23:57 -0000 Received: from p54990AA2.dip0.t-ipconnect.de (EHLO [192.168.2.10]) [84.153.10.162] by mail.gmx.net (mp036) with SMTP; 19 Dec 2005 11:23:57 +0100 X-Authenticated: #1735141 Message-ID: <43A68AAC.7090002@gmx.de> Date: Mon, 19 Dec 2005 11:25:48 +0100 From: Patrick Fischer User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.6) Gecko/20051002 Thunderbird/1.0.2 Mnenhy/0.7.2.0 X-Accept-Language: de-DE, de, en-us, en MIME-Version: 1.0 To: VDR Mailing List Subject: Re: [vdr] Memory access error while attach player? References: <439D6FDE.50708@gmx.de> <43A03764.9010006@gmx.de> <43A037AA.2040100@cadsoft.de> <43A0448A.5000201@gmx.de> <43A04626.4080003@cadsoft.de> <43A053CD.50404@gmx.de> <43A05412.3050208@cadsoft.de> <43A19D02.5050509@gmx.de> <43A2A69D.4060604@gmx.de> In-Reply-To: <43A2A69D.4060604@gmx.de> X-Y-GMX-Trusted: 0 X-BeenThere: vdr@linuxtv.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: VDR Mailing List List-Id: VDR Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Dec 2005 10:24:33 -0000 Status: O X-Status: X-Keywords: X-UID: 6713 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; > } > --- ./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: --- ./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;