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
4e51dbbd
Commit
4e51dbbd
authored
Jan 12, 2009
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Interaction: use dedicated condition variable
parent
bc9ec45e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
41 deletions
+49
-41
src/interface/interaction.c
src/interface/interaction.c
+49
-27
src/interface/interface.h
src/interface/interface.h
+0
-14
No files found.
src/interface/interaction.c
View file @
4e51dbbd
...
@@ -46,9 +46,27 @@
...
@@ -46,9 +46,27 @@
/*****************************************************************************
/*****************************************************************************
* Local prototypes
* Local prototypes
*****************************************************************************/
*****************************************************************************/
/**
* This structure contains the active interaction dialogs, and is
* used by the manager
*/
struct
interaction_t
{
VLC_COMMON_MEMBERS
vlc_thread_t
thread
;
vlc_cond_t
wait
;
int
i_dialogs
;
///< Number of dialogs
interaction_dialog_t
**
pp_dialogs
;
///< Dialogs
intf_thread_t
*
p_intf
;
///< Interface to use
int
i_last_id
;
///< Last attributed ID
};
static
interaction_t
*
InteractionGet
(
vlc_object_t
*
);
static
interaction_t
*
InteractionGet
(
vlc_object_t
*
);
static
intf_thread_t
*
SearchInterface
(
interaction_t
*
);
static
intf_thread_t
*
SearchInterface
(
interaction_t
*
);
static
void
*
InteractionLoop
(
v
lc_object_t
*
);
static
void
*
InteractionLoop
(
v
oid
*
);
static
void
InteractionManage
(
interaction_t
*
);
static
void
InteractionManage
(
interaction_t
*
);
static
interaction_dialog_t
*
DialogGetById
(
interaction_t
*
,
int
);
static
interaction_dialog_t
*
DialogGetById
(
interaction_t
*
,
int
);
...
@@ -219,7 +237,7 @@ void __intf_ProgressUpdate( vlc_object_t *p_this, int i_id,
...
@@ -219,7 +237,7 @@ void __intf_ProgressUpdate( vlc_object_t *p_this, int i_id,
p_dialog
->
i_status
=
UPDATED_DIALOG
;
p_dialog
->
i_status
=
UPDATED_DIALOG
;
vlc_
object_signal_unlocked
(
p_interaction
);
vlc_
cond_signal
(
&
p_interaction
->
wait
);
vlc_object_unlock
(
p_interaction
);
vlc_object_unlock
(
p_interaction
);
vlc_object_release
(
p_interaction
);
vlc_object_release
(
p_interaction
);
}
}
...
@@ -345,7 +363,7 @@ void __intf_UserHide( vlc_object_t *p_this, int i_id )
...
@@ -345,7 +363,7 @@ void __intf_UserHide( vlc_object_t *p_this, int i_id )
if
(
p_dialog
)
if
(
p_dialog
)
{
{
p_dialog
->
i_status
=
ANSWERED_DIALOG
;
p_dialog
->
i_status
=
ANSWERED_DIALOG
;
vlc_
object_signal_unlocked
(
p_interaction
);
vlc_
cond_signal
(
&
p_interaction
->
wait
);
}
}
vlc_object_unlock
(
p_interaction
);
vlc_object_unlock
(
p_interaction
);
...
@@ -377,9 +395,10 @@ interaction_t * interaction_Init( libvlc_int_t *p_libvlc )
...
@@ -377,9 +395,10 @@ interaction_t * interaction_Init( libvlc_int_t *p_libvlc )
p_interaction
->
p_intf
=
NULL
;
p_interaction
->
p_intf
=
NULL
;
p_interaction
->
i_last_id
=
0
;
p_interaction
->
i_last_id
=
0
;
if
(
vlc_thread_create
(
p_interaction
,
"Interaction control"
,
vlc_cond_init
(
&
p_interaction
->
wait
);
InteractionLoop
,
VLC_THREAD_PRIORITY_LOW
,
false
)
)
if
(
vlc_clone
(
&
p_interaction
->
thread
,
InteractionLoop
,
p_interaction
,
VLC_THREAD_PRIORITY_LOW
)
)
{
{
msg_Err
(
p_interaction
,
"Interaction control thread creation failed, "
msg_Err
(
p_interaction
,
"Interaction control thread creation failed, "
"interaction will not be displayed"
);
"interaction will not be displayed"
);
...
@@ -396,8 +415,17 @@ void interaction_Destroy( interaction_t *p_interaction )
...
@@ -396,8 +415,17 @@ void interaction_Destroy( interaction_t *p_interaction )
if
(
!
p_interaction
)
if
(
!
p_interaction
)
return
;
return
;
vlc_object_kill
(
p_interaction
);
vlc_cancel
(
p_interaction
->
thread
);
vlc_thread_join
(
p_interaction
);
vlc_join
(
p_interaction
->
thread
,
NULL
);
vlc_cond_destroy
(
&
p_interaction
->
wait
);
/* Remove all dialogs - Interfaces must be able to clean up their data */
for
(
int
i
=
p_interaction
->
i_dialogs
-
1
;
i
>=
0
;
i
--
)
{
interaction_dialog_t
*
p_dialog
=
p_interaction
->
pp_dialogs
[
i
];
DialogDestroy
(
p_dialog
);
REMOVE_ELEM
(
p_interaction
->
pp_dialogs
,
p_interaction
->
i_dialogs
,
i
);
}
vlc_object_release
(
p_interaction
);
vlc_object_release
(
p_interaction
);
}
}
...
@@ -538,7 +566,7 @@ static int DialogSend( vlc_object_t *p_this, interaction_dialog_t *p_dialog )
...
@@ -538,7 +566,7 @@ static int DialogSend( vlc_object_t *p_this, interaction_dialog_t *p_dialog )
if
(
p_dialog
->
i_type
==
INTERACT_DIALOG_TWOWAY
)
/* Wait for answer */
if
(
p_dialog
->
i_type
==
INTERACT_DIALOG_TWOWAY
)
/* Wait for answer */
{
{
vlc_
object_signal_unlocked
(
p_interaction
);
vlc_
cond_signal
(
&
p_interaction
->
wait
);
while
(
p_dialog
->
i_status
!=
ANSWERED_DIALOG
&&
while
(
p_dialog
->
i_status
!=
ANSWERED_DIALOG
&&
p_dialog
->
i_status
!=
HIDING_DIALOG
&&
p_dialog
->
i_status
!=
HIDING_DIALOG
&&
p_dialog
->
i_status
!=
HIDDEN_DIALOG
&&
p_dialog
->
i_status
!=
HIDDEN_DIALOG
&&
...
@@ -554,7 +582,7 @@ static int DialogSend( vlc_object_t *p_this, interaction_dialog_t *p_dialog )
...
@@ -554,7 +582,7 @@ static int DialogSend( vlc_object_t *p_this, interaction_dialog_t *p_dialog )
p_dialog
->
i_status
=
ANSWERED_DIALOG
;
p_dialog
->
i_status
=
ANSWERED_DIALOG
;
}
}
p_dialog
->
i_flags
|=
DIALOG_GOT_ANSWER
;
p_dialog
->
i_flags
|=
DIALOG_GOT_ANSWER
;
vlc_
object_signal_unlocked
(
p_interaction
);
vlc_
cond_signal
(
&
p_interaction
->
wait
);
vlc_object_unlock
(
p_interaction
);
vlc_object_unlock
(
p_interaction
);
vlc_object_release
(
p_interaction
);
vlc_object_release
(
p_interaction
);
return
p_dialog
->
i_return
;
return
p_dialog
->
i_return
;
...
@@ -563,7 +591,7 @@ static int DialogSend( vlc_object_t *p_this, interaction_dialog_t *p_dialog )
...
@@ -563,7 +591,7 @@ static int DialogSend( vlc_object_t *p_this, interaction_dialog_t *p_dialog )
{
{
/* Pretend we already retrieved the "answer" */
/* Pretend we already retrieved the "answer" */
p_dialog
->
i_flags
|=
DIALOG_GOT_ANSWER
;
p_dialog
->
i_flags
|=
DIALOG_GOT_ANSWER
;
vlc_
object_signal_unlocked
(
p_interaction
);
vlc_
cond_signal
(
&
p_interaction
->
wait
);
vlc_object_unlock
(
p_interaction
);
vlc_object_unlock
(
p_interaction
);
vlc_object_release
(
p_interaction
);
vlc_object_release
(
p_interaction
);
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
...
@@ -576,28 +604,22 @@ static int DialogSend( vlc_object_t *p_this, interaction_dialog_t *p_dialog )
...
@@ -576,28 +604,22 @@ static int DialogSend( vlc_object_t *p_this, interaction_dialog_t *p_dialog )
}
}
}
}
static
void
*
InteractionLoop
(
v
lc_object_t
*
p_this
)
static
void
*
InteractionLoop
(
v
oid
*
p_this
)
{
{
interaction_t
*
p_interaction
=
(
interaction_t
*
)
p_this
;
interaction_t
*
p_interaction
=
p_this
;
int
canc
=
vlc_savecancel
();
vlc_object_lock
(
p_this
);
vlc_object_lock
(
p_interaction
);
while
(
vlc_object_alive
(
p_this
)
)
mutex_cleanup_push
(
&
(
vlc_internals
(
p_interaction
)
->
lock
)
);
for
(
;;
)
{
{
int
canc
=
vlc_savecancel
();
InteractionManage
(
p_interaction
);
InteractionManage
(
p_interaction
);
vlc_object_wait
(
p_this
);
vlc_restorecancel
(
canc
);
}
vlc_object_unlock
(
p_this
);
/* Remove all dialogs - Interfaces must be able to clean up their data */
vlc_cond_wait
(
&
p_interaction
->
wait
,
&
(
vlc_internals
(
p_interaction
)
->
lock
)
);
for
(
int
i
=
p_interaction
->
i_dialogs
-
1
;
i
>=
0
;
i
--
)
{
interaction_dialog_t
*
p_dialog
=
p_interaction
->
pp_dialogs
[
i
];
DialogDestroy
(
p_dialog
);
REMOVE_ELEM
(
p_interaction
->
pp_dialogs
,
p_interaction
->
i_dialogs
,
i
);
}
}
vlc_
restorecancel
(
canc
);
vlc_
cleanup_pop
(
);
return
NULL
;
assert
(
0
)
;
}
}
/**
/**
...
...
src/interface/interface.h
View file @
4e51dbbd
...
@@ -34,20 +34,6 @@
...
@@ -34,20 +34,6 @@
* Interaction
* Interaction
**********************************************************************/
**********************************************************************/
/**
* This structure contains the active interaction dialogs, and is
* used by the manager
*/
struct
interaction_t
{
VLC_COMMON_MEMBERS
int
i_dialogs
;
///< Number of dialogs
interaction_dialog_t
**
pp_dialogs
;
///< Dialogs
intf_thread_t
*
p_intf
;
///< Interface to use
int
i_last_id
;
///< Last attributed ID
};
interaction_t
*
interaction_Init
(
libvlc_int_t
*
p_libvlc
);
interaction_t
*
interaction_Init
(
libvlc_int_t
*
p_libvlc
);
void
interaction_Destroy
(
interaction_t
*
);
void
interaction_Destroy
(
interaction_t
*
);
...
...
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