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
4525d695
Commit
4525d695
authored
Mar 05, 2009
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Custom lock for interaction
parent
eb087300
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
26 deletions
+31
-26
include/vlc_interface.h
include/vlc_interface.h
+1
-1
modules/gui/macosx/interaction.m
modules/gui/macosx/interaction.m
+8
-8
modules/gui/qt4/dialogs/interaction.cpp
modules/gui/qt4/dialogs/interaction.cpp
+3
-2
src/interface/interaction.c
src/interface/interaction.c
+19
-15
No files found.
include/vlc_interface.h
View file @
4525d695
...
...
@@ -221,10 +221,10 @@ struct interaction_dialog_t
int
i_flags
;
///< Misc flags
int
i_return
;
///< Return status
interaction_t
*
p_interaction
;
///< Parent interaction object
vlc_object_t
*
p_parent
;
///< The vlc object that asked
//for interaction
intf_thread_t
*
p_interface
;
vlc_mutex_t
*
p_lock
;
};
/**
...
...
modules/gui/macosx/interaction.m
View file @
4525d695
...
...
@@ -248,7 +248,7 @@
-
(
void
)
sheetDidEnd
:(
NSWindow
*
)
o_sheet
returnCode
:(
int
)
i_return
contextInfo
:(
void
*
)
o_context
{
vlc_
object_lock
(
(
vlc_object_t
*
)(
p_dialog
->
p_interaction
)
);
vlc_
mutex_lock
(
p_dialog
->
p_lock
);
if
(
i_return
==
NSAlertDefaultReturn
)
{
p_dialog
->
i_return
=
DIALOG_OK_YES
;
...
...
@@ -262,7 +262,7 @@
p_dialog
->
i_return
=
DIALOG_CANCELLED
;
}
p_dialog
->
i_status
=
ANSWERED_DIALOG
;
vlc_
object_unlock
(
(
vlc_object_t
*
)(
p_dialog
->
p_interaction
)
);
vlc_
mutex_unlock
(
p_dialog
->
p_lock
);
}
-
(
void
)
updateDialog
...
...
@@ -348,10 +348,10 @@
-
(
IBAction
)
cancelAndClose
:(
id
)
sender
{
/* tell the core that the dialog was cancelled in a yes/no-style dialogue */
vlc_
object_lock
(
(
vlc_object_t
*
)(
p_dialog
->
p_interaction
)
);
vlc_
mutex_lock
(
p_dialog
->
p_lock
);
p_dialog
->
i_return
=
DIALOG_CANCELLED
;
p_dialog
->
i_status
=
ANSWERED_DIALOG
;
vlc_
object_unlock
(
(
vlc_object_t
*
)(
p_dialog
->
p_interaction
)
);
vlc_
mutex_unlock
(
p_dialog
->
p_lock
);
msg_Dbg
(
p_intf
,
"dialog cancelled"
);
}
...
...
@@ -359,16 +359,16 @@
{
/* tell core that the user wishes to cancel the dialogue
* Use this function if cancelling is optionally like in the progress-dialogue */
vlc_
object_lock
(
(
vlc_object_t
*
)(
p_dialog
->
p_interaction
)
);
vlc_
mutex_lock
(
p_dialog
->
p_lock
);
p_dialog
->
b_cancelled
=
true
;
vlc_
object_unlock
(
(
vlc_object_t
*
)(
p_dialog
->
p_interaction
)
);
vlc_
mutex_unlock
(
p_dialog
->
p_lock
);
msg_Dbg
(
p_intf
,
"cancelling dialog, will close it later on"
);
}
-
(
IBAction
)
okayAndClose
:(
id
)
sender
{
msg_Dbg
(
p_intf
,
"running okayAndClose"
);
vlc_
object_lock
(
(
vlc_object_t
*
)(
p_dialog
->
p_interaction
)
);
vlc_
mutex_lock
(
p_dialog
->
p_lock
);
if
(
p_dialog
->
i_flags
==
DIALOG_LOGIN_PW_OK_CANCEL
)
{
p_dialog
->
psz_returned
[
0
]
=
strdup
(
[[
o_auth_login_fld
stringValue
]
UTF8String
]
);
...
...
@@ -378,7 +378,7 @@
p_dialog
->
psz_returned
[
0
]
=
strdup
(
[[
o_input_fld
stringValue
]
UTF8String
]
);
p_dialog
->
i_return
=
DIALOG_OK_YES
;
p_dialog
->
i_status
=
ANSWERED_DIALOG
;
vlc_
object_unlock
(
(
vlc_object_t
*
)(
p_dialog
->
p_interaction
)
);
vlc_
mutex_unlock
(
p_dialog
->
p_lock
);
msg_Dbg
(
p_intf
,
"dialog acknowledged"
);
}
...
...
modules/gui/qt4/dialogs/interaction.cpp
View file @
4525d695
...
...
@@ -240,7 +240,7 @@ void InteractionDialog::otherB()
void
InteractionDialog
::
Finish
(
int
i_ret
)
{
vlc_
object_lock
(
(
vlc_object_t
*
)(
p_dialog
->
p_interaction
)
);
vlc_
mutex_lock
(
p_dialog
->
p_lock
);
/* Special cases when we have to return psz to the core */
if
(
p_dialog
->
i_flags
&
DIALOG_LOGIN_PW_OK_CANCEL
)
...
...
@@ -262,7 +262,8 @@ void InteractionDialog::Finish( int i_ret )
p_dialog
->
i_flags
&
DIALOG_INTF_PROGRESS
)
p_dialog
->
b_cancelled
=
true
;
vlc_mutex_unlock
(
p_dialog
->
p_lock
);
hide
();
vlc_object_unlock
(
(
vlc_object_t
*
)(
p_dialog
->
p_interaction
)
);
}
src/interface/interaction.c
View file @
4525d695
...
...
@@ -56,6 +56,7 @@ struct interaction_t
VLC_COMMON_MEMBERS
vlc_thread_t
thread
;
vlc_mutex_t
lock
;
vlc_cond_t
wait
;
int
i_dialogs
;
///< Number of dialogs
...
...
@@ -223,7 +224,7 @@ void intf_ProgressUpdate( interaction_dialog_t *p_dialog,
interaction_t
*
p_interaction
=
InteractionGet
(
p_dialog
->
p_parent
);
assert
(
p_interaction
);
vlc_
object_lock
(
p_interaction
);
vlc_
mutex_lock
(
&
p_interaction
->
lock
);
free
(
p_dialog
->
psz_description
);
p_dialog
->
psz_description
=
strdup
(
psz_status
);
...
...
@@ -233,7 +234,7 @@ void intf_ProgressUpdate( interaction_dialog_t *p_dialog,
p_dialog
->
i_status
=
UPDATED_DIALOG
;
vlc_cond_signal
(
&
p_interaction
->
wait
);
vlc_
object_unlock
(
p_interaction
);
vlc_
mutex_unlock
(
&
p_interaction
->
lock
);
vlc_object_release
(
p_interaction
);
}
...
...
@@ -250,9 +251,9 @@ bool intf_ProgressIsCancelled( interaction_dialog_t *p_dialog )
bool
b_cancel
;
assert
(
p_interaction
);
vlc_
object_lock
(
p_interaction
);
vlc_
mutex_lock
(
&
p_interaction
->
lock
);
b_cancel
=
p_dialog
->
b_cancelled
;
vlc_
object_unlock
(
p_interaction
);
vlc_
mutex_unlock
(
&
p_interaction
->
lock
);
vlc_object_release
(
p_interaction
);
return
b_cancel
;
}
...
...
@@ -342,10 +343,10 @@ void intf_UserHide( interaction_dialog_t *p_dialog )
interaction_t
*
p_interaction
=
InteractionGet
(
p_dialog
->
p_parent
);
assert
(
p_interaction
);
vlc_
object_lock
(
p_interaction
);
vlc_
mutex_lock
(
&
p_interaction
->
lock
);
p_dialog
->
i_status
=
ANSWERED_DIALOG
;
vlc_cond_signal
(
&
p_interaction
->
wait
);
vlc_
object_unlock
(
p_interaction
);
vlc_
mutex_unlock
(
&
p_interaction
->
lock
);
vlc_object_release
(
p_interaction
);
}
...
...
@@ -373,6 +374,7 @@ interaction_t * interaction_Init( libvlc_int_t *p_libvlc )
p_interaction
->
pp_dialogs
=
NULL
;
p_interaction
->
p_intf
=
NULL
;
vlc_mutex_init
(
&
p_interaction
->
lock
);
vlc_cond_init
(
&
p_interaction
->
wait
);
if
(
vlc_clone
(
&
p_interaction
->
thread
,
InteractionLoop
,
p_interaction
,
...
...
@@ -396,6 +398,7 @@ void interaction_Destroy( interaction_t *p_interaction )
vlc_cancel
(
p_interaction
->
thread
);
vlc_join
(
p_interaction
->
thread
,
NULL
);
vlc_cond_destroy
(
&
p_interaction
->
wait
);
vlc_mutex_destroy
(
&
p_interaction
->
lock
);
/* Remove all dialogs - Interfaces must be able to clean up their data */
for
(
int
i
=
p_interaction
->
i_dialogs
-
1
;
i
>=
0
;
i
--
)
...
...
@@ -495,6 +498,8 @@ static int DialogSend( interaction_dialog_t *p_dialog )
if
(
!
p_interaction
)
return
VLC_EGENERIC
;
p_dialog
->
p_lock
=
&
p_interaction
->
lock
;
p_intf
=
SearchInterface
(
p_interaction
);
if
(
p_intf
==
NULL
)
{
...
...
@@ -513,13 +518,12 @@ static int DialogSend( interaction_dialog_t *p_dialog )
{
vlc_value_t
val
;
p_dialog
->
p_interaction
=
p_interaction
;
p_dialog
->
i_action
=
INTERACT_NEW
;
val
.
p_address
=
p_dialog
;
var_Set
(
p_dialog
->
p_interface
,
"interaction"
,
val
);
/* Check if we have already added this dialog */
vlc_
object_lock
(
p_interaction
);
vlc_
mutex_lock
(
&
p_interaction
->
lock
);
/* Add it to the queue, the main loop will send the orders to the
* interface */
INSERT_ELEM
(
p_interaction
->
pp_dialogs
,
p_interaction
->
i_dialogs
,
...
...
@@ -533,9 +537,9 @@ static int DialogSend( interaction_dialog_t *p_dialog )
p_dialog
->
i_status
!=
HIDDEN_DIALOG
&&
!
p_dialog
->
p_parent
->
b_die
)
{
vlc_
object_unlock
(
p_interaction
);
vlc_
mutex_unlock
(
&
p_interaction
->
lock
);
msleep
(
100000
);
vlc_
object_lock
(
p_interaction
);
vlc_
mutex_lock
(
&
p_interaction
->
lock
);
}
if
(
p_dialog
->
p_parent
->
b_die
)
{
...
...
@@ -544,7 +548,7 @@ static int DialogSend( interaction_dialog_t *p_dialog )
}
p_dialog
->
i_flags
|=
DIALOG_GOT_ANSWER
;
vlc_cond_signal
(
&
p_interaction
->
wait
);
vlc_
object_unlock
(
p_interaction
);
vlc_
mutex_unlock
(
&
p_interaction
->
lock
);
vlc_object_release
(
p_interaction
);
return
p_dialog
->
i_return
;
}
...
...
@@ -553,7 +557,7 @@ static int DialogSend( interaction_dialog_t *p_dialog )
/* Pretend we already retrieved the "answer" */
p_dialog
->
i_flags
|=
DIALOG_GOT_ANSWER
;
vlc_cond_signal
(
&
p_interaction
->
wait
);
vlc_
object_unlock
(
p_interaction
);
vlc_
mutex_unlock
(
&
p_interaction
->
lock
);
vlc_object_release
(
p_interaction
);
return
VLC_SUCCESS
;
}
...
...
@@ -569,15 +573,15 @@ static void* InteractionLoop( void *p_this )
{
interaction_t
*
p_interaction
=
p_this
;
vlc_
object_lock
(
p_interaction
);
mutex_cleanup_push
(
&
(
vlc_internals
(
p_interaction
)
->
lock
)
);
vlc_
mutex_lock
(
&
p_interaction
->
lock
);
mutex_cleanup_push
(
&
p_interaction
->
lock
);
for
(
;;
)
{
int
canc
=
vlc_savecancel
();
InteractionManage
(
p_interaction
);
vlc_restorecancel
(
canc
);
vlc_cond_wait
(
&
p_interaction
->
wait
,
&
(
vlc_internals
(
p_interaction
)
->
lock
)
);
vlc_cond_wait
(
&
p_interaction
->
wait
,
&
p_interaction
->
lock
);
}
vlc_cleanup_pop
(
);
assert
(
0
);
...
...
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