NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public Developers v
« Previous 1 … 53 54 55 56 57 … 93 Next »
Plugin clean-shutdown

 
  • 0 Vote(s) - 0 Average
Plugin clean-shutdown
madcat
Offline

Senior Member

Posts: 634
Threads: 104
Joined: Apr 2006
#1
2006-06-19, 04:08 AM
Hi,

I'm doing my first steps in developing a plugin. I'm trying to write a client/server plugin, to control GBPVR playback over a TCP connection.

For this, I need my plugin act as a server, listening on sockets, etc.

I need to know when to close the sockets - in other words, when is GB going down.

I could not find any method in IMenuTask (nor in other interfaces) that will be called when GB is going down.

Event? messege? something I can register on?

Thanks.
* Rogers Analog Cable [Canada]
* Hauppauge WintTV PVR USB2
* IBM Thinkpad T42 / 1GB Mem / Centrino 1.6Ghz / 60GB HD / ATI Mobility Radeon 7500 + VGA/DVI out
* MCE Remote + Keyboard
* Win XP SP2 / GBPVR [Latest version. always]
* Pioneer HDTV via VGA (1360x768)
* MS Remote Keyboard
* Logitech Harmony 880 [via MS Remote Control Reciever]
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,734
Threads: 767
Joined: Nov 2003
#2
2006-06-19, 04:14 AM
This is no notification given to plugins that GB-PVR is closing.

I've always found Windows to be pretty well behaved with freeing sockets when the processes closes unexpectedly, with the sockets not explicitly closed.
madcat
Offline

Senior Member

Posts: 634
Threads: 104
Joined: Apr 2006
#3
2006-06-19, 04:26 AM
I must be doing something wrong, but...
Obviosuly, I need some kind of thread for the sockets, as otherwise the whole application will hang, right?

Now, the behavior I see is that if I close GB (From "Exit" in main menu), although the window closes, the process is still running.

I assume it's because of my thread still running.

Could not find example of plugins (with sources) that use threads and take care of some kind of shutting down.
For example, Weather plugin, starts threads, but does not take care of shutting/closing/killing them in case they get hand and the applicaiton is closing.

What am I missing?
* Rogers Analog Cable [Canada]
* Hauppauge WintTV PVR USB2
* IBM Thinkpad T42 / 1GB Mem / Centrino 1.6Ghz / 60GB HD / ATI Mobility Radeon 7500 + VGA/DVI out
* MCE Remote + Keyboard
* Win XP SP2 / GBPVR [Latest version. always]
* Pioneer HDTV via VGA (1360x768)
* MS Remote Keyboard
* Logitech Harmony 880 [via MS Remote Control Reciever]
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,734
Threads: 767
Joined: Nov 2003
#4
2006-06-19, 04:32 AM
Did you set you thread to be a background thread? You should.

Code:
myThread.IsBackground = true;
madcat
Offline

Senior Member

Posts: 634
Threads: 104
Joined: Apr 2006
#5
2006-06-19, 04:41 AM
sub Wrote:Did you set you thread to be a background thread? You should.

Code:
myThread.IsBackground = true;
thanks, that did it... Big Grin
* Rogers Analog Cable [Canada]
* Hauppauge WintTV PVR USB2
* IBM Thinkpad T42 / 1GB Mem / Centrino 1.6Ghz / 60GB HD / ATI Mobility Radeon 7500 + VGA/DVI out
* MCE Remote + Keyboard
* Win XP SP2 / GBPVR [Latest version. always]
* Pioneer HDTV via VGA (1360x768)
* MS Remote Keyboard
* Logitech Harmony 880 [via MS Remote Control Reciever]
madcat
Offline

Senior Member

Posts: 634
Threads: 104
Joined: Apr 2006
#6
2006-06-19, 03:45 PM
However...

I still can not find any way to get notifications from the app to the plugin.
For example, can the plugin be "notified" that something has happened? e.g. a song is playing, paused, etc. or a video is playing, or whatever happenes.
Messeges? events? callbacks? something?

Thanks.
* Rogers Analog Cable [Canada]
* Hauppauge WintTV PVR USB2
* IBM Thinkpad T42 / 1GB Mem / Centrino 1.6Ghz / 60GB HD / ATI Mobility Radeon 7500 + VGA/DVI out
* MCE Remote + Keyboard
* Win XP SP2 / GBPVR [Latest version. always]
* Pioneer HDTV via VGA (1360x768)
* MS Remote Keyboard
* Logitech Harmony 880 [via MS Remote Control Reciever]
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,734
Threads: 767
Joined: Nov 2003
#7
2006-06-19, 05:17 PM
If your plugin implements the IEventNotification interface, then it's Notify() method will be automatically called each time an event occurs.

The events you will be notified for are:

CurrentAudioTrack,
CurrentVideoTrack,
CurrentChannelNumber,
CurrentChannelName,
VideoStopping,
MusicStopping,
DVDPlaybackStarted,
DVDPlaybackStopping,
MVPConnected,
MVPDisconnected,
ScreenSaverActivated,
ScreenSaverDeactivated,
CurrentVideoPath
madcat
Offline

Senior Member

Posts: 634
Threads: 104
Joined: Apr 2006
#8
2006-06-19, 05:42 PM
Once again... what am I doing wrong?

I justed added the
Code:
public class RemotePlugin : IMenuTask , IEventNotification
and
Code:
public void Notify(EventTypes eventType, string eventText)
        {
            Logger.Verbose("NOTIFY:\n\ttype=" + eventType.ToString() + "\n\ttext=" + eventText);
        }

(OR even an empty method) and what I get in the log file is:

Code:
19/06/2006 13:34:15.080    ERROR    [1]    Error initializing event plugin: C:\Program Files\devnz\gbpvr\plugins\RemotePlugin.dll
19/06/2006 13:34:15.080    ERROR    [1]    Exception has been thrown by the target of an invocation.
19/06/2006 13:34:15.090    ERROR    [1]       at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic)
   at System.Activator.CreateInstance(Type type)
   at GBPVR.Backend.Common.xc4f12ec3a8a4c96b.xb77fa95273e0c228()
* Rogers Analog Cable [Canada]
* Hauppauge WintTV PVR USB2
* IBM Thinkpad T42 / 1GB Mem / Centrino 1.6Ghz / 60GB HD / ATI Mobility Radeon 7500 + VGA/DVI out
* MCE Remote + Keyboard
* Win XP SP2 / GBPVR [Latest version. always]
* Pioneer HDTV via VGA (1360x768)
* MS Remote Keyboard
* Logitech Harmony 880 [via MS Remote Control Reciever]
madcat
Offline

Senior Member

Posts: 634
Threads: 104
Joined: Apr 2006
#9
2006-06-19, 05:46 PM
And (not terribly important), why not add to it something like ApplicationExiting, can help for cleanups if needed (although we solved my thread problems already... Wink
* Rogers Analog Cable [Canada]
* Hauppauge WintTV PVR USB2
* IBM Thinkpad T42 / 1GB Mem / Centrino 1.6Ghz / 60GB HD / ATI Mobility Radeon 7500 + VGA/DVI out
* MCE Remote + Keyboard
* Win XP SP2 / GBPVR [Latest version. always]
* Pioneer HDTV via VGA (1360x768)
* MS Remote Keyboard
* Logitech Harmony 880 [via MS Remote Control Reciever]
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,734
Threads: 767
Joined: Nov 2003
#10
2006-06-19, 06:55 PM
madcat Wrote:Once again... what am I doing wrong?

I justed added the
Code:
public class RemotePlugin : IMenuTask , IEventNotification
and
Code:
public void Notify(EventTypes eventType, string eventText)
        {
            Logger.Verbose("NOTIFY:\n\ttype=" + eventType.ToString() + "\n\ttext=" + eventText);
        }

(OR even an empty method) and what I get in the log file is:

Code:
19/06/2006 13:34:15.080    ERROR    [1]    Error initializing event plugin: C:\Program Files\devnz\gbpvr\plugins\RemotePlugin.dll
19/06/2006 13:34:15.080    ERROR    [1]    Exception has been thrown by the target of an invocation.
19/06/2006 13:34:15.090    ERROR    [1]       at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic)
   at System.Activator.CreateInstance(Type type)
   at GBPVR.Backend.Common.xc4f12ec3a8a4c96b.xb77fa95273e0c228()
Tons of other plugins are doing this without any problems. I'd have to guess your plugin is generating an exception in the constructor.
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)

Pages (2): 1 2 Next »


Possibly Related Threads…
Thread Author Replies Views Last Post
  PIP plugin for Kodi sgilani 2 2,943 2022-10-17, 12:44 AM
Last Post: sgilani
  New Systems Plugin kirschey 10 3,442 2020-11-14, 08:01 PM
Last Post: sub
  VIdeo playback from plugin mvallevand 5 3,513 2015-08-06, 10:43 PM
Last Post: sub
  Attention Sub: Open TV / Custom Data Grabber plugin Benoire 2 2,951 2014-11-14, 02:05 AM
Last Post: Benoire
  API docs to help with plugin development? McBainUK 3 2,802 2013-06-08, 06:14 PM
Last Post: sub
  Refreshing TV Guide Data (after System plugin EPG update) imilne 13 6,187 2013-03-24, 08:03 PM
Last Post: imilne
  sabnzbd plugin to show processed files Wakalaka 1 1,980 2013-03-12, 06:48 AM
Last Post: psycik
  Plugin problems with started from the command line mvallevand 11 5,064 2012-08-12, 07:56 PM
Last Post: sub
  Get NextPVR data directory from outside a plugin McBainUK 3 2,276 2012-02-11, 05:42 PM
Last Post: mvallevand
  Weather Plugin imilne 0 1,458 2012-01-15, 08:33 PM
Last Post: imilne

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode