calling MainMenuAction() from an other plugin

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Reinhard Nissl wrote:
> Hi,
> 
> Udo Richter wrote:
> 
>>>> if (ShowMessage && !Skins.IsOpen() && !cOsd::IsOpen()) {
>>>>    ShowMessage = false;
>>>>    cRemote::CallPlugin("myShowMessage");
>>>>    }
>>>
>>>
>>> this looks racy to me. What if two different threads do this?
>>> The OSD could open between the if () and ::CallPlugin
>>
>>
>> CallPlugin is always racy, as only one plugin call will be remembered.
>>
>> The only safe way is to set up a signal and wait for MainMenuAction 
>> being called. If it is not called within timeout, try again.
>>
>> The IsOpen() calls should ideally be made from foreground thread, but 
>> usually there's no way to get there. Testing from within 
>> MainMenuAction is pointless, as OSD and menu get closed right before 
>> MainMenuAction.
> 
> 
> I did something similar in my vdr-xine plugin. Things could be improved 
> using the attached patch.
> 
> It allows to remember up to 16 calls to different plugins and the caller 
> can detect, whether putting the call in the remote key fifo was successful.

Just so I get this right: with your patch it will be possible
to put several plugin calls into the key queue. Let's assume that
there are 3 plugin calls currently in the queue. When VDR goes through
the next main loop, it will encounter a k_Plugin in the queue and call
the first plugin's MainMenuAction(). Since there is more input in the
queue, that plugin's OSD won't be displayed, yet (that's only
done in cInterface::GetKey() in case the queue is empty). So it takes
the next k_Plugin out of the queue, deletes the menu it just created
and call the second plugin's MainMenuAction(). Before displaying that one
it will get the third k_Plugin out of the queue, call that plugin's
MainMenuAction(), and that's what will be finally displayed.

Unless I'm missing something here, queueing (up to 16) k_Plugins
doesn't have any different result (from the user's point of view)
than just overwriting any previously stored plugin call. The only thing
that appears to be important is the (currently missing) mutex lock
in cRemote::CallPlugin().

Am I missing something here?

Klaus


[Index of Archives]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Big List of Linux Books]     [Fedora Users]     [Fedora Women]     [ALSA Devel]     [Linux USB]

  Powered by Linux