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
ab50befa
Commit
ab50befa
authored
Sep 06, 2008
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hotkeys: use normal thread synchronization APIs
parent
c35c18a6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
19 deletions
+33
-19
modules/control/hotkeys.c
modules/control/hotkeys.c
+33
-19
No files found.
modules/control/hotkeys.c
View file @
ab50befa
...
@@ -59,6 +59,8 @@ struct intf_sys_t
...
@@ -59,6 +59,8 @@ struct intf_sys_t
* channel IDs */
* channel IDs */
input_thread_t
*
p_input
;
/* pointer to input */
input_thread_t
*
p_input
;
/* pointer to input */
vout_thread_t
*
p_vout
;
/* pointer to vout object */
vout_thread_t
*
p_vout
;
/* pointer to vout object */
vlc_mutex_t
lock
;
/* callback lock */
vlc_cond_t
wait
;
/* callback event */
};
};
/*****************************************************************************
/*****************************************************************************
...
@@ -106,11 +108,16 @@ vlc_module_end();
...
@@ -106,11 +108,16 @@ vlc_module_end();
static
int
Open
(
vlc_object_t
*
p_this
)
static
int
Open
(
vlc_object_t
*
p_this
)
{
{
intf_thread_t
*
p_intf
=
(
intf_thread_t
*
)
p_this
;
intf_thread_t
*
p_intf
=
(
intf_thread_t
*
)
p_this
;
MALLOC_ERR
(
p_intf
->
p_sys
,
intf_sys_t
);
intf_sys_t
*
p_sys
;
MALLOC_ERR
(
p_sys
,
intf_sys_t
);
p_intf
->
p_sys
->
i_size
=
0
;
p_intf
->
p_sys
=
p_sys
;
p_intf
->
pf_run
=
Run
;
p_intf
->
pf_run
=
Run
;
p_sys
->
i_size
=
0
;
vlc_mutex_init
(
&
p_sys
->
lock
);
vlc_cond_init
(
&
p_sys
->
wait
);
var_AddCallback
(
p_intf
->
p_libvlc
,
"key-pressed"
,
SpecialKeyEvent
,
p_intf
);
var_AddCallback
(
p_intf
->
p_libvlc
,
"key-pressed"
,
SpecialKeyEvent
,
p_intf
);
var_AddCallback
(
p_intf
->
p_libvlc
,
"key-action"
,
ActionEvent
,
p_intf
);
var_AddCallback
(
p_intf
->
p_libvlc
,
"key-action"
,
ActionEvent
,
p_intf
);
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
...
@@ -122,10 +129,14 @@ static int Open( vlc_object_t *p_this )
...
@@ -122,10 +129,14 @@ static int Open( vlc_object_t *p_this )
static
void
Close
(
vlc_object_t
*
p_this
)
static
void
Close
(
vlc_object_t
*
p_this
)
{
{
intf_thread_t
*
p_intf
=
(
intf_thread_t
*
)
p_this
;
intf_thread_t
*
p_intf
=
(
intf_thread_t
*
)
p_this
;
intf_sys_t
*
p_sys
=
p_intf
->
p_sys
;
var_DelCallback
(
p_intf
->
p_libvlc
,
"key-action"
,
ActionEvent
,
p_intf
);
var_DelCallback
(
p_intf
->
p_libvlc
,
"key-action"
,
ActionEvent
,
p_intf
);
var_DelCallback
(
p_intf
->
p_libvlc
,
"key-pressed"
,
SpecialKeyEvent
,
p_intf
);
var_DelCallback
(
p_intf
->
p_libvlc
,
"key-pressed"
,
SpecialKeyEvent
,
p_intf
);
vlc_cond_destroy
(
&
p_sys
->
wait
);
vlc_mutex_destroy
(
&
p_sys
->
lock
);
/* Destroy structure */
/* Destroy structure */
free
(
p_intf
->
p_sys
);
free
(
p_intf
->
p_sys
);
}
}
...
@@ -141,6 +152,8 @@ static void Run( intf_thread_t *p_intf )
...
@@ -141,6 +152,8 @@ static void Run( intf_thread_t *p_intf )
playlist_t
*
p_playlist
=
pl_Yield
(
p_intf
);
playlist_t
*
p_playlist
=
pl_Yield
(
p_intf
);
int
canc
=
vlc_savecancel
();
int
canc
=
vlc_savecancel
();
vlc_cleanup_push
(
__pl_Release
,
p_intf
);
/* Initialize hotkey structure */
/* Initialize hotkey structure */
for
(
struct
hotkey
*
p_hotkey
=
p_intf
->
p_libvlc
->
p_hotkeys
;
for
(
struct
hotkey
*
p_hotkey
=
p_intf
->
p_libvlc
->
p_hotkeys
;
p_hotkey
->
psz_action
!=
NULL
;
p_hotkey
->
psz_action
!=
NULL
;
...
@@ -153,10 +166,12 @@ static void Run( intf_thread_t *p_intf )
...
@@ -153,10 +166,12 @@ static void Run( intf_thread_t *p_intf )
{
{
input_thread_t
*
p_input
;
input_thread_t
*
p_input
;
vout_thread_t
*
p_last_vout
;
vout_thread_t
*
p_last_vout
;
int
i_action
=
GetAction
(
p_intf
);
int
i_action
;
vlc_restorecancel
(
canc
);
i_action
=
GetAction
(
p_intf
);
if
(
i_action
==
-
1
)
canc
=
vlc_savecancel
();
break
;
/* die */
/* Update the input */
/* Update the input */
PL_LOCK
;
PL_LOCK
;
...
@@ -830,30 +845,29 @@ static void Run( intf_thread_t *p_intf )
...
@@ -830,30 +845,29 @@ static void Run( intf_thread_t *p_intf )
if
(
p_input
)
if
(
p_input
)
vlc_object_release
(
p_input
);
vlc_object_release
(
p_input
);
}
}
pl_Release
(
p_intf
);
vlc_restorecancel
(
canc
);
/* dead code */
abort
();
vlc_cleanup_pop
();
}
}
static
int
GetAction
(
intf_thread_t
*
p_intf
)
static
int
GetAction
(
intf_thread_t
*
p_intf
)
{
{
intf_sys_t
*
p_sys
=
p_intf
->
p_sys
;
intf_sys_t
*
p_sys
=
p_intf
->
p_sys
;
int
i_ret
=
-
1
;
int
i_ret
;
vlc_mutex_lock
(
&
p_sys
->
lock
);
mutex_cleanup_push
(
&
p_sys
->
lock
);
vlc_object_lock
(
p_intf
);
while
(
p_sys
->
i_size
==
0
)
while
(
p_sys
->
i_size
==
0
)
{
vlc_cond_wait
(
&
p_sys
->
wait
,
&
p_sys
->
lock
);
if
(
!
vlc_object_alive
(
p_intf
)
)
goto
out
;
vlc_object_wait
(
p_intf
);
}
i_ret
=
p_sys
->
p_actions
[
0
];
i_ret
=
p_sys
->
p_actions
[
0
];
p_sys
->
i_size
--
;
p_sys
->
i_size
--
;
for
(
int
i
=
0
;
i
<
p_sys
->
i_size
;
i
++
)
for
(
int
i
=
0
;
i
<
p_sys
->
i_size
;
i
++
)
p_sys
->
p_actions
[
i
]
=
p_sys
->
p_actions
[
i
+
1
];
p_sys
->
p_actions
[
i
]
=
p_sys
->
p_actions
[
i
+
1
];
out:
vlc_cleanup_run
();
vlc_object_unlock
(
p_intf
);
return
i_ret
;
return
i_ret
;
}
}
...
@@ -862,14 +876,14 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
...
@@ -862,14 +876,14 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
intf_sys_t
*
p_sys
=
p_intf
->
p_sys
;
intf_sys_t
*
p_sys
=
p_intf
->
p_sys
;
int
i_ret
=
VLC_EGENERIC
;
int
i_ret
=
VLC_EGENERIC
;
vlc_
object_lock
(
p_intf
);
vlc_
mutex_lock
(
&
p_sys
->
lock
);
if
(
p_sys
->
i_size
>=
BUFFER_SIZE
)
if
(
p_sys
->
i_size
>=
BUFFER_SIZE
)
msg_Warn
(
p_intf
,
"event buffer full, dropping key actions"
);
msg_Warn
(
p_intf
,
"event buffer full, dropping key actions"
);
else
else
p_sys
->
p_actions
[
p_sys
->
i_size
++
]
=
i_action
;
p_sys
->
p_actions
[
p_sys
->
i_size
++
]
=
i_action
;
vlc_
object_signal_unlocked
(
p_intf
);
vlc_
cond_signal
(
&
p_sys
->
wait
);
vlc_
object_unlock
(
p_intf
);
vlc_
mutex_unlock
(
&
p_sys
->
lock
);
return
i_ret
;
return
i_ret
;
}
}
...
...
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