Commit fc49657a authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Events: simplify initialization

parent d7d59888
......@@ -110,10 +110,9 @@ static vlcplugin_event_t vlcevents[] = {
{ "MediaPlayerLengthChanged", libvlc_MediaPlayerLengthChanged, handle_changed_event },
};
bool EventObj::init()
EventObj::EventObj() : _em(NULL), _already_in_deliver(false)
{
plugin_lock_init(&lock);
return true;
}
EventObj::~EventObj()
......
......@@ -49,14 +49,11 @@ private:
public:
Listener(vlcplugin_event_t *event, NPObject *p_object, bool b_bubble):
_event(event), _listener(p_object), _bubble(b_bubble)
{
{
assert(event);
assert(p_object);
}
Listener(): _event(NULL), _listener(NULL), _bubble(false) { }
~Listener()
{
}
}
libvlc_event_type_t event_type() const { return _event->libvlc_type; }
NPObject *listener() const { return _listener; }
bool bubble() const { return _bubble; }
......@@ -71,12 +68,8 @@ private:
public:
VLCEvent(libvlc_event_type_t libvlc_event_type, NPVariant *npparams, uint32_t npcount):
_libvlc_event_type(libvlc_event_type), _npparams(npparams), _npcount(npcount)
{
}
VLCEvent(): _libvlc_event_type(0), _npparams(NULL), _npcount(0) { }
~VLCEvent()
{
}
{}
libvlc_event_type_t event_type() const { return _libvlc_event_type; }
NPVariant *params() const { return _npparams; }
uint32_t count() const { return _npcount; }
......@@ -87,16 +80,17 @@ private:
};
public:
EventObj(): _em(NULL), _already_in_deliver(false) { /* deferred to init() */ }
bool init();
~EventObj();
EventObj();
virtual ~EventObj();
void unhook_manager(void *);
void hook_manager(libvlc_event_manager_t *, void *);
void deliver(NPP browser);
void callback(const libvlc_event_t *event, NPVariant *npparams, uint32_t count);
bool insert(const NPString &name, NPObject *listener, bool bubble);
bool remove(const NPString &name, NPObject *listener, bool bubble);
void unhook_manager(void *);
void hook_manager(libvlc_event_manager_t *, void *);
private:
libvlc_event_manager_t *_em; /* libvlc media_player event manager */
vlcplugin_event_t *find_event(const NPString &name) const;
......
......@@ -255,9 +255,6 @@ NPError VlcPluginBase::init(int argc, char* const argn[], char* const argv[])
/* new APIs */
p_scriptClass = RuntimeNPClass<LibvlcRootNPObject>::getClass();
if( !events.init() )
return NPERR_GENERIC_ERROR;
libvlc_media_player_t *p_md = getMD();
if( p_md ) {
libvlc_event_manager_t *p_em;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment