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
704980f3
Commit
704980f3
authored
Apr 18, 2012
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
libvlc: small simplification of thread initialization
parent
952370a4
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
28 deletions
+18
-28
lib/core.c
lib/core.c
+4
-4
lib/error.c
lib/error.c
+12
-22
lib/libvlc_internal.h
lib/libvlc_internal.h
+2
-2
No files found.
lib/core.c
View file @
704980f3
...
...
@@ -40,12 +40,12 @@ static const char nomemstr[] = "Insufficient memory";
libvlc_instance_t
*
libvlc_new
(
int
argc
,
const
char
*
const
*
argv
)
{
libvlc_threads_init
();
libvlc_instance_t
*
p_new
=
malloc
(
sizeof
(
*
p_new
));
if
(
unlikely
(
p_new
==
NULL
))
return
NULL
;
libvlc_init_threads
();
const
char
*
my_argv
[
argc
+
2
];
my_argv
[
0
]
=
"libvlc"
;
/* dummy arg0, skipped by getopt() et al */
for
(
int
i
=
0
;
i
<
argc
;
i
++
)
...
...
@@ -74,8 +74,8 @@ libvlc_instance_t * libvlc_new( int argc, const char *const *argv )
return
p_new
;
error:
libvlc_deinit_threads
();
free
(
p_new
);
libvlc_threads_deinit
();
return
NULL
;
}
...
...
@@ -107,7 +107,7 @@ void libvlc_release( libvlc_instance_t *p_instance )
libvlc_InternalCleanup
(
p_instance
->
p_libvlc_int
);
libvlc_InternalDestroy
(
p_instance
->
p_libvlc_int
);
free
(
p_instance
);
libvlc_
deinit_threads
();
libvlc_
threads_deinit
();
}
}
...
...
lib/error.c
View file @
704980f3
...
...
@@ -30,34 +30,24 @@ static const char oom[] = "Out of memory";
/* TODO: use only one thread-specific key for whole libvlc */
static
vlc_threadvar_t
context
;
static
void
libvlc_setup_threads
(
bool
init
)
{
static
vlc_mutex_t
lock
=
VLC_STATIC_MUTEX
;
static
uintptr_t
refs
=
0
;
static
vlc_mutex_t
lock
=
VLC_STATIC_MUTEX
;
static
uintptr_t
refs
=
0
;
void
libvlc_threads_init
(
void
)
{
vlc_mutex_lock
(
&
lock
);
if
(
init
)
{
if
(
refs
++
==
0
)
vlc_threadvar_create
(
&
context
,
free
);
}
else
{
assert
(
refs
>
0
);
if
(
--
refs
==
0
)
vlc_threadvar_delete
(
&
context
);
}
vlc_mutex_unlock
(
&
lock
);
}
void
libvlc_
init_threads
(
void
)
void
libvlc_
threads_deinit
(
void
)
{
libvlc_setup_threads
(
true
);
}
void
libvlc_deinit_threads
(
void
)
{
libvlc_setup_threads
(
false
);
vlc_mutex_lock
(
&
lock
);
assert
(
refs
>
0
);
if
(
--
refs
==
0
)
vlc_threadvar_delete
(
&
context
);
vlc_mutex_unlock
(
&
lock
);
}
static
char
*
get_error
(
void
)
...
...
lib/libvlc_internal.h
View file @
704980f3
...
...
@@ -80,8 +80,8 @@ struct libvlc_instance_t
***************************************************************************/
/* Thread context */
void
libvlc_
init_threads
(
void
);
void
libvlc_
deinit_threads
(
void
);
void
libvlc_
threads_init
(
void
);
void
libvlc_
threads_deinit
(
void
);
/* Events */
libvlc_event_manager_t
*
libvlc_event_manager_new
(
...
...
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