Problem with transfer mode, xine plugin and ActualDevice

Message ID 4367E1F2.7090509@gmx.de
State New
Headers

Commit Message

Reinhard Nissl Nov. 1, 2005, 9:45 p.m. UTC
  Hi,

Luca Olivetti wrote:

>>>Please test the attached patch.
>>
>>It doesn't work (i.e. it works like without the patch, only there's a
>>message telling that the primary device is changing).
> 
> Correction: it works when switching to xine, it doesn't when switching
> *from* xine (you forgot the cControl::Shutdown() in the other direction).
> BTW, shouldn't the "originalPrimaryDevice = primaryDevice" be inside the
> "if (this != primaryDevice)" ?

So the revised patch (see attachment) should work now as expected, isn't it?

Bye.
  

Comments

Luca Olivetti Nov. 1, 2005, 10:43 p.m. UTC | #1
En/na Reinhard Nissl ha escrit:

> 
> So the revised patch (see attachment) should work now as expected, isn't
> it?

I'm really puzzled (since now the plugin is doing exactly the same as
vdr) but it doesn't :-(

Bye
  
Luca Olivetti Nov. 1, 2005, 10:47 p.m. UTC | #2
En/na Luca Olivetti ha escrit:
> En/na Reinhard Nissl ha escrit:
> 
> 
>>So the revised patch (see attachment) should work now as expected, isn't
>>it?
> 
> 
> I'm really puzzled (since now the plugin is doing exactly the same as
> vdr) but it doesn't :-(

Could it be that OnClientConnect is asyncrhonous wrt the main vdr thread
and SetPrimaryDevice should be called only from the main thread (so that
if it works or not is basically random?).

Bye
  
Reinhard Nissl Nov. 2, 2005, 12:02 a.m. UTC | #3
Hi,

Luca Olivetti wrote:

>>>So the revised patch (see attachment) should work now as expected, isn't
>>>it?
>>
>>I'm really puzzled (since now the plugin is doing exactly the same as
>>vdr) but it doesn't :-(
> 
> Could it be that OnClientConnect is asyncrhonous wrt the main vdr thread
> and SetPrimaryDevice should be called only from the main thread (so that
> if it works or not is basically random?).

Well yes, this could be a problem. OnClientConnect() is driven by an own 
thread in xineLib.c.

Bye.
  
Luca Olivetti Nov. 2, 2005, 12:17 a.m. UTC | #4
En/na Reinhard Nissl ha escrit:
> Hi,
> 
> Luca Olivetti wrote:
> 
>>>> So the revised patch (see attachment) should work now as expected,
>>>> isn't
>>>> it?
>>>
>>>
>>> I'm really puzzled (since now the plugin is doing exactly the same as
>>> vdr) but it doesn't :-(
>>
>>
>> Could it be that OnClientConnect is asyncrhonous wrt the main vdr thread
>> and SetPrimaryDevice should be called only from the main thread (so that
>> if it works or not is basically random?).
> 
> 
> Well yes, this could be a problem. OnClientConnect() is driven by an own
> thread in xineLib.c.

Well, juggling around the instructions (i.e., calling the
cControl::Shutdown() after the Skins.Message or after the
SetPrimaryDevice, having previously removed the call to
cControl::Shutdown() in MakePrimaryDevice) sometimes it works, sometimes
it doesn't, so it's most probably a timing issue. If so there's no easy
way out. I can live with this problem, it seems ActualDevice it's only
used by some plugins (e.g. femon).

Bye
  
Reinhard Nissl Nov. 2, 2005, 3:19 p.m. UTC | #5
Hi,

Luca Olivetti wrote:

> Well, juggling around the instructions (i.e., calling the
> cControl::Shutdown() after the Skins.Message or after the
> SetPrimaryDevice, having previously removed the call to
> cControl::Shutdown() in MakePrimaryDevice) sometimes it works, sometimes
> it doesn't, so it's most probably a timing issue. If so there's no easy
> way out. I can live with this problem, it seems ActualDevice it's only
> used by some plugins (e.g. femon).

Please provide me a showcase with femon. I could hack vdr-xine for 
multiple devices and try to reproduce this problem here too.

Bye.
  
Luca Olivetti Nov. 2, 2005, 5:49 p.m. UTC | #6
En/na Reinhard Nissl ha escrit:

> Please provide me a showcase with femon. I could hack vdr-xine for
> multiple devices and try to reproduce this problem here too.

femon uses ActualDevice to open the frontend, if it cannot it will
simply not show anything (that's how I spotted the problem, btw, and
looking at syslog to see that there was a transfer thread stopping after
the new one had started).

In femonosd.c, method cFemonOsd::Show:


 asprintf(&dev, FRONTEND_DEVICE, cDevice::ActualDevice()->CardIndex(), 0);
  m_Frontend = open(dev, O_RDONLY | O_NONBLOCK);


I added right after that an

 printf("frontend %s\n",dev);

to see what it's getting.


Grepping for ActualDevice I can see that it's also used in eitscan.c,
actuator[*], streamdev, subtitles, ttxtsubs.

[*]I copied that part from rotor, so it's probably using ActualDevice too.

Bye.
  

Patch

--- ../xine-0.7.6/xineDevice.c	2005-09-11 21:17:06.000000000 +0200
+++ xineDevice.c	2005-11-01 22:41:23.000000000 +0100
@@ -2582,6 +2590,8 @@  store_frame(jumboPESdata, todo, __LINE__
   {
     if (On)
       new cXineOsdProvider(*this);
+    else
+      cOsdProvider::Shutdown();
     
     originalPrimaryDevice = 0;
   }
@@ -2630,7 +2640,12 @@  store_frame(jumboPESdata, todo, __LINE__
     {
       cDevice *primaryDevice = cDevice::PrimaryDevice();
       if (this != primaryDevice)
+      {
+        cControl::Shutdown();
+        Skins.Message(mtInfo, tr("Switching primary DVB to vdr-xine..."));
         SetPrimaryDevice(1 + DeviceNumber());
+      }
+
       originalPrimaryDevice = primaryDevice;
     }
 
@@ -2647,7 +2662,11 @@  store_frame(jumboPESdata, todo, __LINE__
       && originalPrimaryDevice)
     {
       if (this != originalPrimaryDevice)
+      {
+        cControl::Shutdown();
         SetPrimaryDevice(1 + originalPrimaryDevice->DeviceNumber());
+        Skins.Message(mtInfo, tr("Switched primary DVB back from vdr-xine"));
+      }
     }
   }