From patchwork Sun Nov 13 22:25:11 2005 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Reinhard Nissl X-Patchwork-Id: 12089 Received: from mail.gmx.de ([213.165.64.20] helo=mail.gmx.net) by www.linuxtv.org with smtp (Exim 4.50) id 1EbQIC-00048W-4e for vdr@linuxtv.org; Sun, 13 Nov 2005 23:25:44 +0100 Received: (qmail invoked by alias); 13 Nov 2005 22:25:13 -0000 Received: from ambg-c3471394.pool.mediaWays.net (EHLO [192.168.101.15]) [195.71.19.148] by mail.gmx.net (mp008) with SMTP; 13 Nov 2005 23:25:13 +0100 X-Authenticated: #527675 Message-ID: <4377BD47.8060308@gmx.de> Date: Sun, 13 Nov 2005 23:25:11 +0100 From: Reinhard Nissl User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050716) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Klaus Schmidinger's VDR Subject: Re: [vdr] Problem with transfer mode, xine plugin and ActualDevice References: <43679260.9060403@ventoso.org> <4367A306.5050308@gmx.de> <4367ABAC.1060501@ventoso.org> <4367C045.9020303@gmx.de> <4367C6AA.8020003@ventoso.org> <4367D97E.707@ventoso.org> <4367E1F2.7090509@gmx.de> <4367EFA6.9080208@ventoso.org> <4367F07C.9070404@ventoso.org> <43680202.90708@gmx.de> <436805B3.20109@ventoso.org> <4368D8F3.7080707@gmx.de> <4368FE50.5000601@ventoso.org> In-Reply-To: <4368FE50.5000601@ventoso.org> 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: Sun, 13 Nov 2005 22:25:44 -0000 Status: O X-Status: X-Keywords: X-UID: 6078 Hi, Luca Olivetti wrote: > Btw, this is the patch I'm using now (against original 0.7.6), and it > seems to work, but I'm not sure it's due to simple luck or it is working > by design (e.g. if I switch the order of cControl::Shutdown() and > Skins.Message in the OnClientConnect handler it won't work). As you wrote in a previous email: it's a threading issue. Please try the attached patch against 0.7.6, which now uses VDR's main thread to switch the primary device. Bye. --- ../xine-0.7.6/xine.c 2005-08-24 00:01:55.000000000 +0200 +++ xine.c 2005-11-13 22:21:10.000000000 +0100 @@ -156,7 +156,7 @@ void cPluginXine::Housekeeping(void) cOsdObject *cPluginXine::MainMenuAction(void) { // Perform the action when selected from the main VDR menu. - m_settings.TogglePrebufferMode(); + PluginXine::cXineDevice::MainMenuTrampoline(); return NULL; } --- ../xine-0.7.6/xineDevice.c 2005-09-11 21:17:06.000000000 +0200 +++ xineDevice.c 2005-11-13 22:56:06.000000000 +0100 @@ -2580,8 +2588,14 @@ store_frame(jumboPESdata, todo, __LINE__ void cXineDevice::MakePrimaryDevice(bool On) { + xfprintf(stderr, "-------------------------\n"); + xfprintf(stderr, "MakePrimaryDevice: %d\n", On); + xfprintf(stderr, "=========================\n"); + if (On) new cXineOsdProvider(*this); + else + cOsdProvider::Shutdown(); originalPrimaryDevice = 0; } @@ -2619,6 +2633,51 @@ store_frame(jumboPESdata, todo, __LINE__ m_currentOsd->ReshowCurrentOsd(dontOptimize, frameWidth, frameHeight); } + void cXineDevice::mainMenuTrampoline() + { + cMutexLock switchPrimaryDeviceLock(&m_switchPrimaryDeviceMutex); + if (m_switchPrimaryDeviceDeviceNo < 0) + return; + + cControl::Shutdown(); + + if (m_switchPrimaryDeviceDeviceNo == (1 + DeviceNumber())) + { + char *msg = 0; + ::asprintf(&msg, tr("Switching primary DVB to %s..."), m_plugin->Name()); + + Skins.Message(mtInfo, msg); + ::free(msg); + } + + SetPrimaryDevice(m_switchPrimaryDeviceDeviceNo); + + if (m_switchPrimaryDeviceDeviceNo != (1 + DeviceNumber())) + { + char *msg = 0; + ::asprintf(&msg, tr("Switched primary DVB back from %s"), m_plugin->Name()); + + Skins.Message(mtInfo, msg); + ::free(msg); + } + + m_switchPrimaryDeviceCond.Broadcast(); + } + + void cXineDevice::switchPrimaryDevice(const int deviceNo, const bool waitForExecution) + { + while (cRemote::HasKeys()) + cCondWait::SleepMs(10); + + cMutexLock switchPrimaryDeviceLock(&m_switchPrimaryDeviceMutex); + m_switchPrimaryDeviceDeviceNo = deviceNo; + + cRemote::CallPlugin(m_plugin->Name()); + + if (waitForExecution) + m_switchPrimaryDeviceCond.Wait(m_switchPrimaryDeviceMutex); + } + void cXineDevice::OnClientConnect() { reshowCurrentOsd(); @@ -2630,7 +2689,8 @@ store_frame(jumboPESdata, todo, __LINE__ { cDevice *primaryDevice = cDevice::PrimaryDevice(); if (this != primaryDevice) - SetPrimaryDevice(1 + DeviceNumber()); + switchPrimaryDevice(1 + DeviceNumber(), true); + originalPrimaryDevice = primaryDevice; } @@ -2647,7 +2707,7 @@ store_frame(jumboPESdata, todo, __LINE__ && originalPrimaryDevice) { if (this != originalPrimaryDevice) - SetPrimaryDevice(1 + originalPrimaryDevice->DeviceNumber()); + switchPrimaryDevice(1 + originalPrimaryDevice->DeviceNumber(), false); } } @@ -2697,6 +2757,8 @@ store_frame(jumboPESdata, todo, __LINE__ , m_currentOsd(0) , m_spuDecoder(0) , m_audioChannel(0) + , m_plugin(plugin) + , m_switchPrimaryDeviceDeviceNo(-1) , m_xineLib(plugin, settings, m_osdMutex, remote) { m_xineLib.SetEventSink(this); --- ../xine-0.7.6/xineDevice.h 2005-09-11 18:08:56.000000000 +0200 +++ xineDevice.h 2005-11-13 22:56:23.000000000 +0100 @@ -97,6 +97,13 @@ namespace PluginXine virtual void OnClientDisconnect(); virtual void ReshowCurrentOSD(const int frameWidth, const int frameHeight); + cPlugin *const m_plugin; + int m_switchPrimaryDeviceDeviceNo; + cMutex m_switchPrimaryDeviceMutex; + cCondVar m_switchPrimaryDeviceCond; + void switchPrimaryDevice(const int deviceNo, const bool waitForExecution); + void mainMenuTrampoline(); + public: virtual int64_t GetSTC(void); @@ -126,6 +133,11 @@ namespace PluginXine static void Stop(); static cXineDevice *GetDevice(); + static void MainMenuTrampoline() + { + GetDevice()->mainMenuTrampoline(); + } + bool hasNoSignalStream() const { return m_xineLib.hasNoSignalStream();