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
20821641
Commit
20821641
authored
Sep 07, 2008
by
Laurent Aimar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cosmetics (split MainLoop in smaller functions).
parent
dcaafd94
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
169 additions
and
131 deletions
+169
-131
src/input/input.c
src/input/input.c
+169
-131
No files found.
src/input/input.c
View file @
20821641
...
...
@@ -553,27 +553,19 @@ exit:
/*****************************************************************************
* Main loop: Fill buffers from access, and demux
*****************************************************************************/
static
void
MainLoop
(
input_thread_t
*
p_input
)
{
int64_t
i_start_mdate
=
mdate
();
int64_t
i_intf_update
=
0
;
int
i_updates
=
0
;
/* Stop the timer */
stats_TimerStop
(
p_input
,
STATS_TIMER_INPUT_LAUNCHING
);
while
(
!
p_input
->
b_die
&&
!
p_input
->
b_error
&&
!
p_input
->
p
->
input
.
b_eof
)
{
bool
b_force_update
=
false
;
/**
* MainLoopDemux
* It asks the demuxer to demux some data
*/
static
void
MainLoopDemux
(
input_thread_t
*
p_input
,
bool
*
pb_changed
,
mtime_t
*
pi_start_mdate
)
{
int
i_ret
;
int
i_type
;
vlc_value_t
val
;
/* Do the read */
if
(
p_input
->
i_state
!=
PAUSE_S
)
{
*
pb_changed
=
false
;
if
(
(
p_input
->
p
->
i_stop
>
0
&&
p_input
->
i_time
>=
p_input
->
p
->
i_stop
)
||
(
p_input
->
p
->
i_run
>
0
&&
i_start_mdate
+
p_input
->
p
->
i_run
<
mdate
()
)
)
(
p_input
->
p
->
i_run
>
0
&&
*
p
i_start_mdate
+
p_input
->
p
->
i_run
<
mdate
()
)
)
i_ret
=
0
;
/* EOF */
else
i_ret
=
p_input
->
p
->
input
.
p_demux
->
pf_demux
(
p_input
->
p
->
input
.
p_demux
);
...
...
@@ -585,14 +577,14 @@ static void MainLoop( input_thread_t *p_input )
p_input
->
p
->
input
.
p_demux
->
info
.
i_update
)
{
i_ret
=
UpdateFromDemux
(
p_input
);
b_force_update
=
true
;
*
pb_changed
=
true
;
}
else
if
(
!
p_input
->
p
->
input
.
b_title_demux
&&
p_input
->
p
->
input
.
p_access
&&
p_input
->
p
->
input
.
p_access
->
info
.
i_update
)
{
i_ret
=
UpdateFromAccess
(
p_input
);
b_force_update
=
true
;
*
pb_changed
=
true
;
}
}
...
...
@@ -610,6 +602,8 @@ static void MainLoop( input_thread_t *p_input )
}
else
{
vlc_value_t
val
;
msg_Dbg
(
p_input
,
"repeating the same input (%d)"
,
repeat
.
i_int
);
if
(
repeat
.
i_int
>
0
)
...
...
@@ -647,7 +641,7 @@ static void MainLoop( input_thread_t *p_input )
}
/* */
i_start_mdate
=
mdate
();
*
p
i_start_mdate
=
mdate
();
}
}
else
if
(
i_ret
<
0
)
...
...
@@ -659,29 +653,18 @@ static void MainLoop( input_thread_t *p_input )
{
SlaveDemux
(
p_input
);
}
}
else
{
/* Small wait */
msleep
(
10
*
1000
);
}
/* Handle control */
vlc_mutex_lock
(
&
p_input
->
p
->
lock_control
);
ControlReduce
(
p_input
);
while
(
!
ControlPopNoLock
(
p_input
,
&
i_type
,
&
val
)
)
{
msg_Dbg
(
p_input
,
"control type=%d"
,
i_type
);
if
(
Control
(
p_input
,
i_type
,
val
)
)
b_force_update
=
true
;
}
vlc_mutex_unlock
(
&
p_input
->
p
->
lock_control
);
}
if
(
b_force_update
||
i_intf_update
<
mdate
()
)
{
/**
* MainLoopInterface
* It update the variables used by the interfaces
*/
static
void
MainLoopInterface
(
input_thread_t
*
p_input
)
{
vlc_value_t
val
;
double
f_pos
;
int64_t
i_time
,
i_length
;
/* update input status variables */
if
(
!
demux_Control
(
p_input
->
p
->
input
.
p_demux
,
DEMUX_GET_POSITION
,
&
f_pos
)
)
...
...
@@ -711,11 +694,14 @@ static void MainLoop( input_thread_t *p_input )
}
var_SetBool
(
p_input
,
"intf-change"
,
true
);
i_intf_update
=
mdate
()
+
INT64_C
(
150000
);
}
/* 150ms * 8 = ~ 1 second */
if
(
++
i_updates
%
8
==
0
)
{
}
/**
* MainLoopStatistic
* It updates the globals statics
*/
static
void
MainLoopStatistic
(
input_thread_t
*
p_input
)
{
stats_ComputeInputStats
(
p_input
,
p_input
->
p
->
input
.
p_item
->
p_stats
);
/* Are we the thread responsible for computing global stats ? */
if
(
libvlc_priv
(
p_input
->
p_libvlc
)
->
p_stats_computer
==
p_input
)
...
...
@@ -723,7 +709,59 @@ static void MainLoop( input_thread_t *p_input )
stats_ComputeGlobalStats
(
p_input
->
p_libvlc
,
p_input
->
p_libvlc
->
p_stats
);
}
}
/**
* MainLoop
* The main input loop.
*/
static
void
MainLoop
(
input_thread_t
*
p_input
)
{
mtime_t
i_start_mdate
=
mdate
();
int64_t
i_intf_update
=
0
;
int
i_updates
=
0
;
/* Start the timer */
stats_TimerStop
(
p_input
,
STATS_TIMER_INPUT_LAUNCHING
);
while
(
!
p_input
->
b_die
&&
!
p_input
->
b_error
&&
!
p_input
->
p
->
input
.
b_eof
)
{
bool
b_force_update
;
int
i_type
;
vlc_value_t
val
;
/* Do the read */
if
(
p_input
->
i_state
!=
PAUSE_S
)
{
MainLoopDemux
(
p_input
,
&
b_force_update
,
&
i_start_mdate
);
}
else
{
/* Small wait */
b_force_update
=
false
;
msleep
(
10
*
1000
);
}
/* Handle control */
vlc_mutex_lock
(
&
p_input
->
p
->
lock_control
);
ControlReduce
(
p_input
);
while
(
!
ControlPopNoLock
(
p_input
,
&
i_type
,
&
val
)
)
{
msg_Dbg
(
p_input
,
"control type=%d"
,
i_type
);
if
(
Control
(
p_input
,
i_type
,
val
)
)
b_force_update
=
true
;
}
vlc_mutex_unlock
(
&
p_input
->
p
->
lock_control
);
if
(
b_force_update
||
i_intf_update
<
mdate
()
)
{
MainLoopInterface
(
p_input
);
i_intf_update
=
mdate
()
+
INT64_C
(
150000
);
}
/* 150ms * 8 = ~ 1 second */
if
(
++
i_updates
%
8
==
0
)
MainLoopStatistic
(
p_input
);
}
if
(
!
p_input
->
b_eof
&&
!
p_input
->
b_error
&&
p_input
->
p
->
input
.
b_eof
)
...
...
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