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
0a3fa2c8
Commit
0a3fa2c8
authored
Jun 08, 2003
by
Cyril Deguet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* better implementation of timers for X11 skins
parent
9ca2bbfb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
93 additions
and
21 deletions
+93
-21
modules/gui/skins/x11/x11_run.cpp
modules/gui/skins/x11/x11_run.cpp
+2
-2
modules/gui/skins/x11/x11_timer.cpp
modules/gui/skins/x11/x11_timer.cpp
+75
-13
modules/gui/skins/x11/x11_timer.h
modules/gui/skins/x11/x11_timer.h
+14
-4
modules/gui/skins/x11/x11_window.cpp
modules/gui/skins/x11/x11_window.cpp
+2
-2
No files found.
modules/gui/skins/x11/x11_run.cpp
View file @
0a3fa2c8
...
...
@@ -2,7 +2,7 @@
* x11_run.cpp:
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: x11_run.cpp,v 1.1
8 2003/06/08 00:32:07
asmax Exp $
* $Id: x11_run.cpp,v 1.1
9 2003/06/08 11:33:14
asmax Exp $
*
* Authors: Cyril Deguet <asmax@videolan.org>
*
...
...
@@ -168,7 +168,7 @@ void OSRun( intf_thread_t *p_intf )
// Timer for SkinManage
X11Timer
*
refreshTimer
=
new
X11Timer
(
p_intf
,
100
,
RefreshCallback
,
X11Timer
*
refreshTimer
=
new
X11Timer
(
p_intf
,
100
000
,
RefreshCallback
,
(
void
*
)
p_intf
);
X11TimerManager
*
timerManager
=
X11TimerManager
::
Instance
(
p_intf
);
timerManager
->
addTimer
(
refreshTimer
);
...
...
modules/gui/skins/x11/x11_timer.cpp
View file @
0a3fa2c8
...
...
@@ -2,7 +2,7 @@
* x11_timer.cpp: helper class to implement timers
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: x11_timer.cpp,v 1.
2 2003/06/07 12:19:23
asmax Exp $
* $Id: x11_timer.cpp,v 1.
3 2003/06/08 11:33:14
asmax Exp $
*
* Authors: Cyril Deguet <asmax@videolan.org>
*
...
...
@@ -41,22 +41,32 @@ X11Timer::X11Timer( intf_thread_t *p_intf, mtime_t interval, callback_t func,
_interval
=
interval
;
_callback
=
func
;
_data
=
data
;
_nextDate
=
0
;
vlc_mutex_init
(
p_intf
,
&
_lock
);
}
X11Timer
::~
X11Timer
()
{
vlc_mutex_destroy
(
&
_lock
);
}
mtime_t
X11Timer
::
getNextDate
(
mtime_t
current
)
void
X11Timer
::
SetDate
(
mtime_t
date
)
{
return
(
current
/
_interval
+
1
)
*
_interval
;
_nextDate
=
date
+
_interval
;
}
mtime_t
X11Timer
::
GetNextDate
()
{
return
_nextDate
;
}
bool
X11Timer
::
Execute
()
{
_nextDate
+=
_interval
;
return
(
*
_callback
)(
_data
);
}
...
...
@@ -70,6 +80,8 @@ X11TimerManager::X11TimerManager( intf_thread_t *p_intf )
{
_p_intf
=
p_intf
;
vlc_mutex_init
(
p_intf
,
&
_lock
);
// Create the timer thread
_p_timer
=
(
timer_thread_t
*
)
vlc_object_create
(
_p_intf
,
sizeof
(
timer_thread_t
)
);
...
...
@@ -81,6 +93,8 @@ X11TimerManager::~X11TimerManager()
{
_p_timer
->
die
=
1
;
vlc_thread_join
(
_p_timer
);
vlc_mutex_destroy
(
&
_lock
);
}
...
...
@@ -115,19 +129,67 @@ void *X11TimerManager::Thread( void *p_timer )
while
(
!
((
timer_thread_t
*
)
p_timer
)
->
die
)
{
list
<
X11Timer
*>::
iterator
timer
;
// FIXME temporary
for
(
timer
=
_instance
->
_timers
.
begin
();
timer
!=
_instance
->
_timers
.
end
();
timer
++
)
_instance
->
WaitNextTimer
();
}
}
void
X11TimerManager
::
WaitNextTimer
()
{
mtime_t
curDate
=
mdate
();
mtime_t
nextDate
=
LAST_MDATE
;
X11Timer
*
nextTimer
=
NULL
;
Lock
();
// Find the next timer to execute
list
<
X11Timer
*>::
iterator
timer
;
for
(
timer
=
_timers
.
begin
();
timer
!=
_timers
.
end
();
timer
++
)
{
mtime_t
timerDate
=
(
*
timer
)
->
GetNextDate
();
if
(
timerDate
<
nextDate
)
{
nextTimer
=
*
timer
;
nextDate
=
timerDate
;
}
}
Unlock
();
if
(
nextTimer
==
NULL
)
{
// FIXME: should wait on a cond instead
msleep
(
10000
);
}
else
{
if
(
nextDate
>
curDate
)
{
bool
ret
=
(
*
timer
)
->
Execute
();
if
(
!
ret
)
{
_instance
->
_timers
.
remove
(
*
timer
);
break
;
}
mwait
(
nextDate
);
}
bool
ret
=
nextTimer
->
Execute
();
if
(
!
ret
)
{
_timers
.
remove
(
nextTimer
);
}
msleep
(
100000
);
}
}
void
X11TimerManager
::
addTimer
(
X11Timer
*
timer
)
{
timer
->
SetDate
(
mdate
()
);
_timers
.
push_back
(
timer
);
}
void
X11TimerManager
::
removeTimer
(
X11Timer
*
timer
)
{
Lock
();
timer
->
Lock
();
_timers
.
remove
(
timer
);
Unlock
();
timer
->
Unlock
();
}
#endif
modules/gui/skins/x11/x11_timer.h
View file @
0a3fa2c8
...
...
@@ -2,7 +2,7 @@
* x11_timer.h: helper class to implement timers
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: x11_timer.h,v 1.
2 2003/06/07 12:19:23
asmax Exp $
* $Id: x11_timer.h,v 1.
3 2003/06/08 11:33:14
asmax Exp $
*
* Authors: Cyril Deguet <asmax@videolan.org>
*
...
...
@@ -46,14 +46,20 @@ class X11Timer
mtime_t
_interval
;
callback_t
_callback
;
void
*
_data
;
vlc_mutex_t
_lock
;
mtime_t
_nextDate
;
public:
X11Timer
(
intf_thread_t
*
p_intf
,
mtime_t
interval
,
callback_t
func
,
void
*
data
);
~
X11Timer
();
mtime_t
getNextDate
(
mtime_t
current
);
void
SetDate
(
mtime_t
date
);
mtime_t
GetNextDate
();
bool
Execute
();
inline
void
Lock
()
{
vlc_mutex_lock
(
&
_lock
);
}
inline
void
Unlock
()
{
vlc_mutex_unlock
(
&
_lock
);
}
};
//---------------------------------------------------------------------------
class
X11TimerManager
...
...
@@ -63,19 +69,23 @@ class X11TimerManager
intf_thread_t
*
_p_intf
;
timer_thread_t
*
_p_timer
;
list
<
X11Timer
*>
_timers
;
vlc_mutex_t
_lock
;
X11TimerManager
(
intf_thread_t
*
p_intf
);
~
X11TimerManager
();
static
void
*
Thread
(
void
*
p_timer
);
void
WaitNextTimer
();
public:
static
X11TimerManager
*
Instance
(
intf_thread_t
*
p_intf
);
void
Destroy
();
void
addTimer
(
X11Timer
*
timer
)
{
_timers
.
push_back
(
timer
);
}
void
removeTimer
(
X11Timer
*
timer
)
{
_timers
.
remove
(
timer
);
}
void
addTimer
(
X11Timer
*
timer
)
;
void
removeTimer
(
X11Timer
*
timer
)
;
inline
void
Lock
()
{
vlc_mutex_lock
(
&
_lock
);
}
inline
void
Unlock
()
{
vlc_mutex_unlock
(
&
_lock
);
}
};
//---------------------------------------------------------------------------
#endif
modules/gui/skins/x11/x11_window.cpp
View file @
0a3fa2c8
...
...
@@ -2,7 +2,7 @@
* x11_window.cpp: X11 implementation of the Window class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: x11_window.cpp,v 1.1
3 2003/06/08 00:32:07
asmax Exp $
* $Id: x11_window.cpp,v 1.1
4 2003/06/08 11:33:14
asmax Exp $
*
* Authors: Cyril Deguet <asmax@videolan.org>
*
...
...
@@ -116,7 +116,7 @@ X11Window::X11Window( intf_thread_t *p_intf, Window wnd, int x, int y,
XUNLOCK
;
ToolTip
.
display
=
display
;
X11Timer
*
timer
=
new
X11Timer
(
p_intf
,
1
00
,
ToolTipCallback
,
&
ToolTip
);
X11Timer
*
timer
=
new
X11Timer
(
p_intf
,
5000
00
,
ToolTipCallback
,
&
ToolTip
);
ToolTip
.
p_intf
=
p_intf
;
ToolTip
.
timer
=
timer
;
...
...
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