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
6accad54
Commit
6accad54
authored
Jan 05, 2009
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use a proper condition variable for variable callback handling
parent
a235278d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
11 deletions
+11
-11
src/libvlc.h
src/libvlc.h
+1
-0
src/misc/objects.c
src/misc/objects.c
+2
-0
src/misc/variables.c
src/misc/variables.c
+8
-11
No files found.
src/libvlc.h
View file @
6accad54
...
...
@@ -150,6 +150,7 @@ typedef struct vlc_object_internals_t
/* Object variables */
variable_t
*
p_vars
;
vlc_mutex_t
var_lock
;
vlc_cond_t
var_wait
;
int
i_vars
;
/* Thread properties, if any */
...
...
src/misc/objects.c
View file @
6accad54
...
...
@@ -173,6 +173,7 @@ void *__vlc_custom_create( vlc_object_t *p_this, size_t i_size,
vlc_mutex_init
(
&
p_priv
->
lock
);
vlc_cond_init
(
&
p_priv
->
wait
);
vlc_mutex_init
(
&
p_priv
->
var_lock
);
vlc_cond_init
(
&
p_priv
->
var_wait
);
vlc_spin_init
(
&
p_priv
->
spin
);
p_priv
->
pipes
[
0
]
=
p_priv
->
pipes
[
1
]
=
-
1
;
...
...
@@ -296,6 +297,7 @@ static void vlc_object_destroy( vlc_object_t *p_this )
}
free
(
p_priv
->
p_vars
);
vlc_cond_destroy
(
&
p_priv
->
var_wait
);
vlc_mutex_destroy
(
&
p_priv
->
var_lock
);
free
(
p_this
->
psz_header
);
...
...
src/misc/variables.c
View file @
6accad54
...
...
@@ -762,6 +762,7 @@ int var_SetChecked( vlc_object_t *p_this, const char *psz_name,
p_var
=
&
p_priv
->
p_vars
[
i_var
];
p_var
->
b_incallback
=
false
;
vlc_cond_broadcast
(
&
p_priv
->
var_wait
);
}
/* Free data if needed */
...
...
@@ -978,6 +979,7 @@ int __var_TriggerCallback( vlc_object_t *p_this, const char *psz_name )
p_var
=
&
p_priv
->
p_vars
[
i_var
];
p_var
->
b_incallback
=
false
;
vlc_cond_broadcast
(
&
p_priv
->
var_wait
);
}
vlc_mutex_unlock
(
&
p_priv
->
var_lock
);
...
...
@@ -1134,18 +1136,19 @@ cleanup:
/* Following functions are local */
/*****************************************************************************
* GetUnused: find an unused variable from its name
* GetUnused: find an unused
(not in callback)
variable from its name
*****************************************************************************
* We do i_tries tries before giving up, just in case the variable is being
* modified and called from a callback.
*****************************************************************************/
static
int
GetUnused
(
vlc_object_t
*
p_this
,
const
char
*
psz_name
)
{
int
i_var
,
i_tries
=
0
;
vlc_object_internals_t
*
p_priv
=
vlc_internals
(
p_this
);
while
(
true
)
{
int
i_var
;
i_var
=
Lookup
(
p_priv
->
p_vars
,
p_priv
->
i_vars
,
psz_name
);
if
(
i_var
<
0
)
{
...
...
@@ -1157,15 +1160,9 @@ static int GetUnused( vlc_object_t *p_this, const char *psz_name )
return
i_var
;
}
if
(
i_tries
++
>
100
)
{
msg_Err
(
p_this
,
"caught in a callback deadlock? ('%s')"
,
psz_name
);
return
VLC_ETIMEOUT
;
}
vlc_mutex_unlock
(
&
p_priv
->
var_lock
);
msleep
(
THREAD_SLEEP
);
vlc_mutex_lock
(
&
p_priv
->
var_lock
);
mutex_cleanup_push
(
&
p_priv
->
var_lock
);
vlc_cond_wait
(
&
p_priv
->
var_wait
,
&
p_priv
->
var_lock
);
vlc_cleanup_pop
(
);
}
}
...
...
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