[vlc-commits] Events: simplify initialization
Jean-Baptiste Kempf
git at videolan.org
Wed Apr 23 19:28:56 CEST 2014
npapi-vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Wed Apr 23 19:27:38 2014 +0200| [fc49657a180772058104b6d1eb440fbf75986377] | committer: Jean-Baptiste Kempf
Events: simplify initialization
> http://git.videolan.org/gitweb.cgi/npapi-vlc.git/?a=commit;h=fc49657a180772058104b6d1eb440fbf75986377
---
npapi/events.cpp | 3 +--
npapi/events.h | 28 +++++++++++-----------------
npapi/vlcplugin_base.cpp | 3 ---
3 files changed, 12 insertions(+), 22 deletions(-)
diff --git a/npapi/events.cpp b/npapi/events.cpp
index a5a98d7..ad988de 100644
--- a/npapi/events.cpp
+++ b/npapi/events.cpp
@@ -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()
diff --git a/npapi/events.h b/npapi/events.h
index ff6e057..d36b1ff 100644
--- a/npapi/events.h
+++ b/npapi/events.h
@@ -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;
diff --git a/npapi/vlcplugin_base.cpp b/npapi/vlcplugin_base.cpp
index e90dea7..9d99a7f 100644
--- a/npapi/vlcplugin_base.cpp
+++ b/npapi/vlcplugin_base.cpp
@@ -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;
More information about the vlc-commits
mailing list