Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
39a5661e
Commit
39a5661e
authored
Feb 25, 2010
by
Jean-Paul Saman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mozilla: use locking wrapper
parent
cc59f655
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
85 additions
and
36 deletions
+85
-36
projects/mozilla/vlcplugin.cpp
projects/mozilla/vlcplugin.cpp
+71
-32
projects/mozilla/vlcplugin.h
projects/mozilla/vlcplugin.h
+14
-4
No files found.
projects/mozilla/vlcplugin.cpp
View file @
39a5661e
...
...
@@ -37,13 +37,71 @@
#include <ctype.h>
#if defined(XP_UNIX)
# include <pthread.h>
# include <pthread.h>
#elif defined(XP_WIN)
/* windows headers */
# include <winbase.h>
#else
#warning "locking not implemented for this platform"
#endif
#include <stdio.h>
/*****************************************************************************
* utilitiy functions
*****************************************************************************/
static
void
plugin_lock_init
(
plugin_lock_t
*
lock
)
{
assert
(
lock
);
#if defined(XP_UNIX)
pthread_mutex_init
(
&
lock
->
mutex
,
NULL
);
#elif defined(XP_WIN)
InitializeCriticalSection
(
&
lock
->
cs
);
#else
#warning "locking not implemented in this platform"
#endif
}
static
void
plugin_lock_destroy
(
plugin_lock_t
*
lock
)
{
assert
(
lock
);
#if defined(XP_UNIX)
pthread_mutex_destroy
(
&
lock
->
mutex
);
#elif defined(XP_WIN)
DeleteCriticalSection
(
&
lock
->
cs
);
#else
#warning "locking not implemented in this platform"
#endif
}
static
void
plugin_lock
(
plugin_lock_t
*
lock
)
{
assert
(
lock
);
#if defined(XP_UNIX)
pthread_mutex_lock
(
&
lock
->
mutex
);
#elif defined(XP_WIN)
EnterCriticalSection
(
&
lock
->
cs
);
#else
#warning "locking not implemented in this platform"
#endif
}
static
void
plugin_unlock
(
plugin_lock_t
*
lock
)
{
assert
(
lock
);
#if defined(XP_UNIX)
pthread_mutex_unlock
(
&
lock
->
mutex
);
#elif defined(XP_WIN)
LeaveCriticalSection
(
&
lock
->
cs
);
#else
#warning "locking not implemented in this platform"
#endif
}
/*****************************************************************************
* VlcPlugin constructor and destructor
*****************************************************************************/
...
...
@@ -95,20 +153,13 @@ static bool boolValue(const char *value) {
bool
EventObj
::
init
()
{
#if defined(XP_UNIX)
return
pthread_mutex_init
(
&
mutex
,
NULL
)
==
0
;
#else
#warning "locking not implemented for this platform"
#endif
plugin_lock_init
(
&
lock
);
return
true
;
}
EventObj
::~
EventObj
()
{
#if defined(XP_UNIX)
pthread_mutex_destroy
(
&
mutex
);
#else
#warning "locking not implemented for this platform"
#endif
plugin_lock_destroy
(
&
lock
);
}
void
EventObj
::
deliver
(
NPP
browser
)
...
...
@@ -116,11 +167,8 @@ void EventObj::deliver(NPP browser)
NPVariant
result
;
NPVariant
params
[
1
];
#if defined(XP_UNIX)
pthread_mutex_lock
(
&
mutex
);
#else
#warning "locking not implemented for this platform"
#endif
plugin_lock
(
&
lock
);
for
(
ev_l
::
iterator
i
=
_elist
.
begin
();
i
!=
_elist
.
end
();
++
i
)
{
libvlc_event_type_t
event
=
*
i
;
...
...
@@ -139,11 +187,8 @@ void EventObj::deliver(NPP browser)
}
}
_elist
.
clear
();
#if defined(XP_UNIX)
pthread_mutex_unlock
(
&
mutex
);
#else
#warning "locking not implemented for this platform"
#endif
plugin_unlock
(
&
lock
);
}
void
VlcPlugin
::
eventAsync
(
void
*
param
)
...
...
@@ -154,18 +199,12 @@ void VlcPlugin::eventAsync(void *param)
void
EventObj
::
callback
(
const
libvlc_event_t
*
event
)
{
#if defined(XP_UNIX)
pthread_mutex_lock
(
&
mutex
);
#else
#warning "locking not implemented for this platform"
#endif
plugin_lock
(
&
lock
);
if
(
have_event
(
event
->
type
)
)
_elist
.
push_back
(
event
->
type
);
#if defined(XP_UNIX)
pthread_mutex_unlock
(
&
mutex
);
#else
#warning "locking not implemented for this platform"
#endif
plugin_unlock
(
&
lock
);
}
void
VlcPlugin
::
event_callback
(
const
libvlc_event_t
*
event
,
void
*
param
)
...
...
@@ -176,7 +215,7 @@ void VlcPlugin::event_callback(const libvlc_event_t* event, void *param)
NPN_PluginThreadAsyncCall
(
plugin
->
getBrowser
(),
eventAsync
,
plugin
);
#else
#warning NPN_PluginThreadAsyncCall not implemented yet.
printf
(
"
%s"
,
"No NPN_PluginThreadAsyncCall(), doing nothing."
);
printf
(
"
No NPN_PluginThreadAsyncCall(), doing nothing."
);
#endif
}
...
...
projects/mozilla/vlcplugin.h
View file @
39a5661e
...
...
@@ -30,7 +30,6 @@
#define __VLCPLUGIN_H__
#include <vlc/vlc.h>
#include <pthread.h>
#include <npapi.h>
#include <vector>
...
...
@@ -44,6 +43,7 @@
#ifdef XP_WIN
/* Windows stuff */
# include <winbase.h>
#endif
#ifdef XP_MACOSX
...
...
@@ -52,6 +52,7 @@
#endif
#ifdef XP_UNIX
# include <pthread.h>
/* X11 stuff */
# include <X11/Xlib.h>
# include <X11/Intrinsic.h>
...
...
@@ -70,6 +71,17 @@
# define __MIN(a, b) ( ((a) < (b)) ? (a) : (b) )
#endif
typedef
struct
{
#if defined(XP_UNIX)
pthread_mutex_t
mutex
;
#elif defined(XP_WIN)
CRITICAL_SECTION
cs
;
#else
#warning "locking not implemented in this platform"
#endif
}
plugin_lock_t
;
typedef
enum
vlc_toolbar_clicked_e
{
clicked_Unknown
=
0
,
clicked_Play
,
...
...
@@ -151,9 +163,7 @@ private:
lr_l
_llist
;
ev_l
_elist
;
#if defined(XP_UNIX)
pthread_mutex_t
mutex
;
#endif
plugin_lock_t
lock
;
bool
ask_for_event
(
event_t
e
);
void
unask_for_event
(
event_t
e
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment