Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-1.1
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-1.1
Commits
f317dd7a
Commit
f317dd7a
authored
Sep 28, 2008
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get rid of p_root object
parent
80cb2948
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
28 deletions
+24
-28
src/misc/threads.c
src/misc/threads.c
+24
-28
No files found.
src/misc/threads.c
View file @
f317dd7a
...
...
@@ -52,12 +52,11 @@ static pthread_mutex_t once_mutex = PTHREAD_MUTEX_INITIALIZER;
static
vlc_threadvar_t
cancel_key
;
#endif
/**
* Global process-wide VLC object.
* Contains the global named mutexes.
* TODO: remove it.
*/
static
vlc_object_t
*
p_root
;
static
struct
{
vlc_dictionary_t
list
;
vlc_mutex_t
lock
;
}
named_mutexes
;
#ifdef HAVE_EXECINFO_H
# include <execinfo.h>
...
...
@@ -168,8 +167,6 @@ typedef struct vlc_cancel_t
*****************************************************************************/
int
vlc_threads_init
(
void
)
{
int
i_ret
=
VLC_SUCCESS
;
/* If we have lazy mutex initialization, use it. Otherwise, we just
* hope nothing wrong happens. */
#if defined( LIBVLC_USE_PTHREAD )
...
...
@@ -178,29 +175,19 @@ int vlc_threads_init( void )
if
(
i_initializations
==
0
)
{
p_root
=
vlc_custom_create
(
(
vlc_object_t
*
)
NULL
,
sizeof
(
*
p_root
),
VLC_OBJECT_GENERIC
,
"root"
);
if
(
p_root
==
NULL
)
{
i_ret
=
VLC_ENOMEM
;
goto
out
;
}
/* We should be safe now. Do all the initialization stuff we want. */
vlc_dictionary_init
(
&
named_mutexes
.
list
,
0
);
vlc_mutex_init
(
&
named_mutexes
.
lock
);
#ifndef LIBVLC_USE_PTHREAD_CANCEL
vlc_threadvar_create
(
&
cancel_key
,
free
);
#endif
}
i_initializations
++
;
out:
/* If we have lazy mutex initialization support, unlock the mutex.
* Otherwize, we are screwed. */
#if defined( LIBVLC_USE_PTHREAD )
pthread_mutex_unlock
(
&
once_mutex
);
#endif
return
i_ret
;
return
VLC_SUCCESS
;
}
/*****************************************************************************
...
...
@@ -218,10 +205,11 @@ void vlc_threads_end( void )
if
(
i_initializations
==
1
)
{
vlc_object_release
(
p_root
);
#ifndef LIBVLC_USE_PTHREAD
vlc_threadvar_delete
(
&
cancel_key
);
#endif
vlc_mutex_destroy
(
&
named_mutexes
.
lock
);
vlc_dictionary_clear
(
&
named_mutexes
.
list
);
}
i_initializations
--
;
...
...
@@ -1110,15 +1098,23 @@ void vlc_control_cancel (int cmd, ...)
/**
* Finds a process-wide mutex, creates it if needed, and locks it.
* Unlock with vlc_mutex_unlock().
* FIXME: This is very inefficient, this is not memory-safe and this leaks
* memory. Use static locks instead.
*/
vlc_mutex_t
*
var_AcquireMutex
(
const
char
*
name
)
{
vlc_
value_t
val
;
vlc_
mutex_t
*
lock
;
if
(
var_Create
(
p_root
,
name
,
VLC_VAR_MUTEX
)
)
return
NULL
;
vlc_mutex_lock
(
&
named_mutexes
.
lock
);
lock
=
vlc_dictionary_value_for_key
(
&
named_mutexes
.
list
,
name
);
if
(
lock
==
kVLCDictionaryNotFound
)
{
lock
=
malloc
(
sizeof
(
*
lock
));
vlc_mutex_init
(
lock
);
vlc_dictionary_insert
(
&
named_mutexes
.
list
,
name
,
lock
);
}
vlc_mutex_unlock
(
&
named_mutexes
.
lock
);
var_Get
(
p_root
,
name
,
&
val
);
vlc_mutex_lock
(
val
.
p_address
);
return
val
.
p_address
;
vlc_mutex_lock
(
lock
);
return
lock
;
}
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