Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
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-2-2
Commits
a508c29e
Commit
a508c29e
authored
Oct 13, 2012
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dbus: simplify input event handling and reduce lock scope
parent
a125b0ad
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
43 deletions
+42
-43
modules/control/dbus/dbus.c
modules/control/dbus/dbus.c
+39
-41
modules/control/dbus/dbus_common.h
modules/control/dbus/dbus_common.h
+3
-2
No files found.
modules/control/dbus/dbus.c
View file @
a508c29e
...
...
@@ -108,6 +108,7 @@ static void Run ( intf_thread_t * );
static
int
TrackChange
(
intf_thread_t
*
);
static
int
AllCallback
(
vlc_object_t
*
,
const
char
*
,
vlc_value_t
,
vlc_value_t
,
void
*
);
static
int
InputCallback
(
vlc_object_t
*
,
const
char
*
,
vlc_value_t
,
vlc_value_t
,
void
*
);
static
dbus_bool_t
add_timeout
(
DBusTimeout
*
p_timeout
,
void
*
p_data
);
static
dbus_bool_t
add_watch
(
DBusWatch
*
p_watch
,
void
*
p_data
);
...
...
@@ -304,7 +305,7 @@ static void Close ( vlc_object_t *p_this )
if
(
p_sys
->
p_input
)
{
var_DelCallback
(
p_sys
->
p_input
,
"intf-event"
,
All
Callback
,
p_intf
);
var_DelCallback
(
p_sys
->
p_input
,
"intf-event"
,
Input
Callback
,
p_intf
);
var_DelCallback
(
p_sys
->
p_input
,
"can-pause"
,
AllCallback
,
p_intf
);
var_DelCallback
(
p_sys
->
p_input
,
"can-seek"
,
AllCallback
,
p_intf
);
vlc_object_release
(
p_sys
->
p_input
);
...
...
@@ -872,30 +873,27 @@ static void wakeup_main_loop( void *p_data )
msg_Err
(
p_intf
,
"Could not wake up the main loop: %m"
);
}
/*
InputIntfEventCallback() fi
lls a callback_info_t data structure in response
/*
F
lls a callback_info_t data structure in response
* to an "intf-event" input event.
*
*
Caution: This function executes in the input thread
*
@warning This function executes in the input thread.
*
* This function must be called with p_sys->lock locked
*
* @return int VLC_SUCCESS on success, VLC_E* on error
* @param intf_thread_t *p_intf the interface thread
* @param input_thread_t *p_input This input thread
* @param const int i_event input event type
* @param callback_info_t *p_info Location of the callback info to fill
* @return VLC_SUCCESS on success, VLC_E* on error.
*/
static
int
InputIntfEventCallback
(
intf_thread_t
*
p_intf
,
input_thread_t
*
p_input
,
const
int
i_event
,
callback_info_t
*
p_info
)
static
int
InputCallback
(
vlc_object_t
*
p_this
,
const
char
*
psz_var
,
vlc_value_t
oldval
,
vlc_value_t
newval
,
void
*
data
)
{
input_thread_t
*
p_input
=
(
input_thread_t
*
)
p_this
;
intf_thread_t
*
p_intf
=
data
;
intf_sys_t
*
p_sys
=
p_intf
->
p_sys
;
dbus_int32_t
i_state
=
PLAYBACK_STATE_INVALID
;
assert
(
!
p_info
->
signal
);
mtime_t
i_now
=
mdate
(),
i_pos
,
i_projected_pos
,
i_interval
;
float
f_current_rate
;
switch
(
i_event
)
callback_info_t
*
p_info
=
calloc
(
1
,
sizeof
(
callback_info_t
)
);
if
(
unlikely
(
p_info
==
NULL
)
)
return
VLC_ENOMEM
;
switch
(
newval
.
i_int
)
{
case
INPUT_EVENT_DEAD
:
case
INPUT_EVENT_ABORT
:
...
...
@@ -922,6 +920,10 @@ static int InputIntfEventCallback( intf_thread_t *p_intf,
p_info
->
signal
=
SIGNAL_RATE
;
return
VLC_SUCCESS
;
case
INPUT_EVENT_POSITION
:
{
mtime_t
i_now
=
mdate
(),
i_pos
,
i_projected_pos
,
i_interval
;
float
f_current_rate
;
/* Detect seeks
* XXX: This is way more convoluted than it should be... */
i_pos
=
var_GetTime
(
p_input
,
"time"
);
...
...
@@ -949,19 +951,30 @@ static int InputIntfEventCallback( intf_thread_t *p_intf,
p_info
->
signal
=
SIGNAL_SEEK
;
p_info
->
i_item
=
input_GetItem
(
p_input
)
->
i_id
;
break
;
}
default:
return
VLC_EGENERIC
;
free
(
p_info
);
return
VLC_SUCCESS
;
/* don't care */
}
vlc_mutex_lock
(
&
p_sys
->
lock
);
if
(
i_state
!=
PLAYBACK_STATE_INVALID
&&
i_state
!=
p_
intf
->
p_
sys
->
i_playing_state
)
i_state
!=
p_sys
->
i_playing_state
)
{
p_
intf
->
p_
sys
->
i_playing_state
=
i_state
;
p_sys
->
i_playing_state
=
i_state
;
p_info
->
signal
=
SIGNAL_STATE
;
}
if
(
p_info
->
signal
)
vlc_array_append
(
p_intf
->
p_sys
->
p_events
,
p_info
);
else
free
(
p_info
);
vlc_mutex_unlock
(
&
p_intf
->
p_sys
->
lock
);
wakeup_main_loop
(
p_intf
);
return
p_info
->
signal
?
VLC_SUCCESS
:
VLC_EGENERIC
;
(
void
)
psz_var
;
(
void
)
oldval
;
return
VLC_SUCCESS
;
}
// Get all the callbacks
...
...
@@ -977,8 +990,6 @@ static int AllCallback( vlc_object_t *p_this, const char *psz_var,
if
(
!
info
)
return
VLC_ENOMEM
;
vlc_mutex_lock
(
&
p_intf
->
p_sys
->
lock
);
// Wich event is it ?
if
(
!
strcmp
(
"item-current"
,
psz_var
)
)
info
->
signal
=
SIGNAL_ITEM_CURRENT
;
...
...
@@ -1013,20 +1024,6 @@ static int AllCallback( vlc_object_t *p_this, const char *psz_var,
else
if
(
!
strcmp
(
"loop"
,
psz_var
)
)
info
->
signal
=
SIGNAL_LOOP
;
else
if
(
!
strcmp
(
"intf-event"
,
psz_var
)
)
{
int
i_res
=
InputIntfEventCallback
(
p_intf
,
(
input_thread_t
*
)
p_this
,
newval
.
i_int
,
info
);
if
(
VLC_SUCCESS
!=
i_res
)
{
vlc_mutex_unlock
(
&
p_intf
->
p_sys
->
lock
);
free
(
info
);
return
i_res
;
}
}
else
if
(
!
strcmp
(
"can-seek"
,
psz_var
)
)
info
->
signal
=
SIGNAL_CAN_SEEK
;
...
...
@@ -1037,6 +1034,7 @@ static int AllCallback( vlc_object_t *p_this, const char *psz_var,
assert
(
0
);
// Append the event
vlc_mutex_lock
(
&
p_intf
->
p_sys
->
lock
);
vlc_array_append
(
p_intf
->
p_sys
->
p_events
,
info
);
vlc_mutex_unlock
(
&
p_intf
->
p_sys
->
lock
);
...
...
@@ -1060,7 +1058,7 @@ static int TrackChange( intf_thread_t *p_intf )
if
(
p_sys
->
p_input
)
{
var_DelCallback
(
p_sys
->
p_input
,
"intf-event"
,
All
Callback
,
p_intf
);
var_DelCallback
(
p_sys
->
p_input
,
"intf-event"
,
Input
Callback
,
p_intf
);
var_DelCallback
(
p_sys
->
p_input
,
"can-pause"
,
AllCallback
,
p_intf
);
var_DelCallback
(
p_sys
->
p_input
,
"can-seek"
,
AllCallback
,
p_intf
);
vlc_object_release
(
p_sys
->
p_input
);
...
...
@@ -1086,7 +1084,7 @@ static int TrackChange( intf_thread_t *p_intf )
p_sys
->
b_meta_read
=
true
;
p_sys
->
p_input
=
p_input
;
var_AddCallback
(
p_input
,
"intf-event"
,
All
Callback
,
p_intf
);
var_AddCallback
(
p_input
,
"intf-event"
,
Input
Callback
,
p_intf
);
var_AddCallback
(
p_input
,
"can-pause"
,
AllCallback
,
p_intf
);
var_AddCallback
(
p_input
,
"can-seek"
,
AllCallback
,
p_intf
);
...
...
modules/control/dbus/dbus_common.h
View file @
a508c29e
...
...
@@ -101,8 +101,9 @@ struct intf_sys_t
int
p_pipe_fds
[
2
];
vlc_mutex_t
lock
;
input_thread_t
*
p_input
;
mtime_t
i_last_input_pos
;
/* Only access it from the input thread */
mtime_t
i_last_input_pos_event
;
/* idem */
mtime_t
i_last_input_pos
;
/* Only access from input thread */
mtime_t
i_last_input_pos_event
;
/* Same as above */
};
enum
...
...
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