Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
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-gpu
Commits
1074e9da
Commit
1074e9da
authored
Jun 02, 2009
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
inhibit: use callbacks, kill one timer thread
parent
6385ba45
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
61 deletions
+63
-61
modules/misc/inhibit.c
modules/misc/inhibit.c
+63
-61
No files found.
modules/misc/inhibit.c
View file @
1074e9da
...
@@ -52,13 +52,18 @@
...
@@ -52,13 +52,18 @@
static
int
Activate
(
vlc_object_t
*
);
static
int
Activate
(
vlc_object_t
*
);
static
void
Deactivate
(
vlc_object_t
*
);
static
void
Deactivate
(
vlc_object_t
*
);
static
void
Run
(
intf_thread_t
*
p_intf
);
static
int
Inhibit
(
intf_thread_t
*
p_intf
);
static
int
Inhibit
(
intf_thread_t
*
p_intf
);
static
int
UnInhibit
(
intf_thread_t
*
p_intf
);
static
int
UnInhibit
(
intf_thread_t
*
p_intf
);
static
int
InputChange
(
vlc_object_t
*
,
const
char
*
,
vlc_value_t
,
vlc_value_t
,
void
*
);
static
int
StateChange
(
vlc_object_t
*
,
const
char
*
,
vlc_value_t
,
vlc_value_t
,
void
*
);
struct
intf_sys_t
struct
intf_sys_t
{
{
playlist_t
*
p_playlist
;
vlc_object_t
*
p_input
;
DBusConnection
*
p_conn
;
DBusConnection
*
p_conn
;
dbus_uint32_t
i_cookie
;
dbus_uint32_t
i_cookie
;
};
};
...
@@ -78,26 +83,29 @@ vlc_module_end ()
...
@@ -78,26 +83,29 @@ vlc_module_end ()
static
int
Activate
(
vlc_object_t
*
p_this
)
static
int
Activate
(
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
;
DBusError
error
;
DBusError
error
;
p_intf
->
pf_run
=
Run
;
p_sys
=
p_intf
->
p_sys
=
(
intf_sys_t
*
)
calloc
(
1
,
sizeof
(
intf_sys_t
)
);
p_intf
->
p_sys
=
(
intf_sys_t
*
)
calloc
(
1
,
sizeof
(
intf_sys_t
)
);
if
(
!
p_sys
)
if
(
!
p_intf
->
p_sys
)
return
VLC_ENOMEM
;
return
VLC_ENOMEM
;
p_intf
->
p_sys
->
i_cookie
=
0
;
p_sys
->
i_cookie
=
0
;
p_sys
->
p_input
=
NULL
;
dbus_error_init
(
&
error
);
dbus_error_init
(
&
error
);
p_
intf
->
p_
sys
->
p_conn
=
dbus_bus_get
(
DBUS_BUS_SESSION
,
&
error
);
p_sys
->
p_conn
=
dbus_bus_get
(
DBUS_BUS_SESSION
,
&
error
);
if
(
!
p_
intf
->
p_
sys
->
p_conn
)
if
(
!
p_sys
->
p_conn
)
{
{
msg_Err
(
p_this
,
"Failed to connect to the D-Bus session daemon: %s"
,
msg_Err
(
p_this
,
"Failed to connect to the D-Bus session daemon: %s"
,
error
.
message
);
error
.
message
);
dbus_error_free
(
&
error
);
dbus_error_free
(
&
error
);
free
(
p_
intf
->
p_
sys
);
free
(
p_sys
);
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
}
}
p_sys
->
p_playlist
=
pl_Hold
(
p_intf
);
var_AddCallback
(
p_sys
->
p_playlist
,
"item-current"
,
InputChange
,
p_intf
);
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
}
}
...
@@ -107,11 +115,22 @@ static int Activate( vlc_object_t *p_this )
...
@@ -107,11 +115,22 @@ static int Activate( vlc_object_t *p_this )
static
void
Deactivate
(
vlc_object_t
*
p_this
)
static
void
Deactivate
(
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
;
if
(
p_intf
->
p_sys
->
i_cookie
)
intf_sys_t
*
p_sys
=
p_intf
->
p_sys
;
var_DelCallback
(
p_sys
->
p_playlist
,
"item-current"
,
InputChange
,
p_intf
);
pl_Release
(
p_intf
);
if
(
p_sys
->
p_input
)
/* Do delete "state" after "item-changed"! */
{
var_DelCallback
(
p_sys
->
p_input
,
"state"
,
StateChange
,
p_intf
);
vlc_object_release
(
p_sys
->
p_input
);
}
if
(
p_sys
->
i_cookie
)
UnInhibit
(
p_intf
);
UnInhibit
(
p_intf
);
dbus_connection_unref
(
p_sys
->
p_conn
);
dbus_connection_unref
(
p_intf
->
p_sys
->
p_conn
);
free
(
p_sys
);
free
(
p_intf
->
p_sys
);
}
}
/*****************************************************************************
/*****************************************************************************
...
@@ -221,60 +240,43 @@ static int UnInhibit( intf_thread_t *p_intf )
...
@@ -221,60 +240,43 @@ static int UnInhibit( intf_thread_t *p_intf )
return
true
;
return
true
;
}
}
/*****************************************************************************
* Run: main thread
static
int
StateChange
(
vlc_object_t
*
p_input
,
const
char
*
var
,
*****************************************************************************/
vlc_value_t
prev
,
vlc_value_t
value
,
void
*
data
)
static
void
vlc_cleanup_playlist
(
void
*
p_playlist
)
{
pl_Release
(
(
playlist_t
*
)
p_playlist
);
}
static
void
Run
(
intf_thread_t
*
p_intf
)
{
{
int
canc
=
vlc_savecancel
();
intf_thread_t
*
p_intf
=
data
;
const
int
old
=
prev
.
i_int
,
cur
=
value
.
i_int
;
if
(
(
old
==
PLAYING_S
)
==
(
cur
==
PLAYING_S
)
)
return
VLC_SUCCESS
;
/* No interesting change */
if
(
(
p_intf
->
p_sys
->
i_cookie
!=
0
)
==
(
cur
==
PLAYING_S
)
)
return
VLC_SUCCESS
;
/* Already in correct state */
if
(
cur
==
PLAYING_S
)
Inhibit
(
p_intf
);
else
UnInhibit
(
p_intf
);
playlist_t
*
p_playlist
=
pl_Hold
(
p_intf
);
(
void
)
p_input
;
(
void
)
var
;
(
void
)
prev
;
return
VLC_SUCCESS
;
}
vlc_cleanup_push
(
vlc_cleanup_playlist
,
p_intf
);
static
int
InputChange
(
vlc_object_t
*
p_playlist
,
const
char
*
var
,
vlc_value_t
prev
,
vlc_value_t
value
,
void
*
data
)
{
intf_thread_t
*
p_intf
=
data
;
intf_sys_t
*
p_sys
=
p_intf
->
p_sys
;
for
(
;;
)
if
(
p_sys
->
p_input
)
{
{
vlc_restorecancel
(
canc
);
var_DelCallback
(
p_sys
->
p_input
,
"state"
,
StateChange
,
p_intf
);
vlc_object_release
(
p_sys
->
p_input
);
/* FIXME wake up on playlist event instead ?
* Check playing state every 30 seconds */
msleep
(
30
*
CLOCK_FREQ
);
canc
=
vlc_savecancel
();
/* */
input_thread_t
*
p_input
=
playlist_CurrentInput
(
p_playlist
);
if
(
p_input
)
{
const
int
i_state
=
var_GetInteger
(
p_input
,
"state"
);
vlc_object_release
(
p_input
);
if
(
PLAYING_S
==
i_state
)
{
if
(
!
p_intf
->
p_sys
->
i_cookie
)
{
if
(
!
Inhibit
(
p_intf
)
)
break
;
}
}
else
if
(
p_intf
->
p_sys
->
i_cookie
)
{
if
(
!
UnInhibit
(
p_intf
)
)
break
;
}
}
else
if
(
p_intf
->
p_sys
->
i_cookie
)
{
if
(
!
UnInhibit
(
p_intf
)
)
break
;
}
}
}
p_sys
->
p_input
=
VLC_OBJECT
(
playlist_CurrentInput
(
p_sys
->
p_playlist
));
if
(
p_sys
->
p_input
)
var_AddCallback
(
p_sys
->
p_input
,
"state"
,
StateChange
,
p_intf
);
/* */
(
void
)
var
;
(
void
)
prev
;
(
void
)
value
;
(
void
)
p_playlist
;
vlc_cleanup_run
();
return
VLC_SUCCESS
;
vlc_restorecancel
(
canc
);
}
}
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