Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
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-gpu
Commits
50e969ef
Commit
50e969ef
authored
May 03, 2008
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify threads init
parent
0d7bc734
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
40 deletions
+11
-40
src/libvlc-common.c
src/libvlc-common.c
+2
-3
src/misc/threads.c
src/misc/threads.c
+9
-37
No files found.
src/libvlc-common.c
View file @
50e969ef
...
...
@@ -151,14 +151,13 @@ libvlc_int_t * vlc_current_object( int i_object )
*/
libvlc_int_t
*
libvlc_InternalCreate
(
void
)
{
int
i_ret
;
libvlc_int_t
*
p_libvlc
=
NULL
;
char
*
psz_env
=
NULL
;
/* vlc_threads_init *must* be the first internal call! No other call is
* allowed before the thread system has been initialized. */
i
_ret
=
vlc_threads_init
(
p_libvlc_global
);
if
(
i_ret
<
0
)
return
NULL
;
i
f
(
vlc_threads_init
(
p_libvlc_global
)
)
return
NULL
;
/* Now that the thread system is initialized, we don't have much, but
* at least we have variables */
...
...
src/misc/threads.c
View file @
50e969ef
...
...
@@ -45,7 +45,6 @@
* Global mutex for lazy initialization of the threads system
*****************************************************************************/
static
volatile
unsigned
i_initializations
=
0
;
static
volatile
int
i_status
=
VLC_THREADS_UNINITIALIZED
;
static
vlc_object_t
*
p_root
;
#if defined( UNDER_CE )
...
...
@@ -130,53 +129,32 @@ int __vlc_threads_init( vlc_object_t *p_this )
pthread_mutex_lock
(
&
once_mutex
);
#endif
if
(
i_
status
==
VLC_THREADS_UNINITIALIZED
)
if
(
i_
initializations
==
0
)
{
i_status
=
VLC_THREADS_PENDING
;
/* We should be safe now. Do all the initialization stuff we want. */
p_libvlc_global
->
b_ready
=
false
;
p_root
=
vlc_custom_create
(
VLC_OBJECT
(
p_libvlc_global
),
0
,
VLC_OBJECT_GLOBAL
,
"global"
);
if
(
p_root
==
NULL
)
i_ret
=
VLC_ENOMEM
;
if
(
i_ret
)
{
i_status
=
VLC_THREADS_ERROR
;
}
else
{
i_
initializations
++
;
i_status
=
VLC_THREADS_READY
;
i_
ret
=
VLC_ENOMEM
;
goto
out
;
}
vlc_threadvar_create
(
p_root
,
&
msg_context_global_key
);
}
else
{
/* Just increment the initialization count */
i_initializations
++
;
}
i_initializations
++
;
/* If we have lazy mutex initialization support, unlock the mutex;
* otherwize, do a naive wait loop. */
out:
/* If we have lazy mutex initialization support, unlock the mutex.
* Otherwize, we are screwed. */
#if defined( UNDER_CE )
while
(
i_status
==
VLC_THREADS_PENDING
)
msleep
(
THREAD_SLEEP
);
#elif defined( WIN32 )
while
(
i_status
==
VLC_THREADS_PENDING
)
msleep
(
THREAD_SLEEP
);
#elif defined( HAVE_KERNEL_SCHEDULER_H )
while
(
i_status
==
VLC_THREADS_PENDING
)
msleep
(
THREAD_SLEEP
);
#elif defined( LIBVLC_USE_PTHREAD )
pthread_mutex_unlock
(
&
once_mutex
);
#endif
if
(
i_status
!=
VLC_THREADS_READY
)
{
return
VLC_ETHREAD
;
}
return
i_ret
;
}
...
...
@@ -195,15 +173,9 @@ int __vlc_threads_end( vlc_object_t *p_this )
pthread_mutex_lock
(
&
once_mutex
);
#endif
if
(
i_initializations
==
0
)
return
VLC_EGENERIC
;
i_initializations
--
;
if
(
i_initializations
==
0
)
{
i_status
=
VLC_THREADS_UNINITIALIZED
;
assert
(
i_initializations
>
0
);
if
(
--
i_initializations
==
0
)
vlc_object_release
(
p_root
);
}
#if defined( UNDER_CE )
#elif defined( WIN32 )
...
...
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