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
17b69f2d
Commit
17b69f2d
authored
Nov 13, 2012
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
aout: fix potential live loop
parent
bdd77785
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
31 deletions
+47
-31
src/audio_output/dec.c
src/audio_output/dec.c
+47
-31
No files found.
src/audio_output/dec.c
View file @
17b69f2d
...
@@ -270,7 +270,6 @@ static void aout_DecSynchronize (audio_output_t *aout, mtime_t dec_pts,
...
@@ -270,7 +270,6 @@ static void aout_DecSynchronize (audio_output_t *aout, mtime_t dec_pts,
aout_owner_t
*
owner
=
aout_owner
(
aout
);
aout_owner_t
*
owner
=
aout_owner
(
aout
);
mtime_t
aout_pts
,
drift
;
mtime_t
aout_pts
,
drift
;
retry:
/**
/**
* Depending on the drift between the actual and intended playback times,
* Depending on the drift between the actual and intended playback times,
* the audio core may ignore the drift, trigger upsampling or downsampling,
* the audio core may ignore the drift, trigger upsampling or downsampling,
...
@@ -289,55 +288,72 @@ retry:
...
@@ -289,55 +288,72 @@ retry:
*/
*/
if
(
aout_OutputTimeGet
(
aout
,
&
aout_pts
)
!=
0
)
if
(
aout_OutputTimeGet
(
aout
,
&
aout_pts
)
!=
0
)
return
;
/* nothing can be done if timing is unknown */
return
;
/* nothing can be done if timing is unknown */
drift
=
aout_pts
-
dec_pts
;
/* Late audio output.
* This can happen due to insufficient caching, scheduling jitter
* or bug in the decoder. Ideally, the output would seek backward. But that
* is not portable, not supported by some hardware and often unsafe/buggy
* where supported. The other alternative is to flush the buffers
* completely. */
if
(
drift
>
(
owner
->
sync
.
discontinuity
?
0
:
+
3
*
input_rate
*
AOUT_MAX_PTS_DELAY
/
INPUT_RATE_DEFAULT
))
{
if
(
!
owner
->
sync
.
discontinuity
)
msg_Warn
(
aout
,
"playback way too late (%"
PRId64
"): "
"flushing buffers"
,
drift
);
else
msg_Dbg
(
aout
,
"playback too late (%"
PRId64
"): "
"flushing buffers"
,
drift
);
aout_OutputFlush
(
aout
,
false
);
aout_StopResampling
(
aout
);
owner
->
sync
.
end
=
VLC_TS_INVALID
;
owner
->
sync
.
discontinuity
=
true
;
/* Now the output might be too early... Recheck. */
if
(
aout_OutputTimeGet
(
aout
,
&
aout_pts
)
!=
0
)
return
;
/* nothing can be done if timing is unknown */
drift
=
aout_pts
-
dec_pts
;
drift
=
aout_pts
-
dec_pts
;
}
/* Early audio output.
* This is rare except at startup when the buffers are still empty. */
if
(
drift
<
(
owner
->
sync
.
discontinuity
?
0
if
(
drift
<
(
owner
->
sync
.
discontinuity
?
0
:
-
3
*
input_rate
*
AOUT_MAX_PTS_ADVANCE
/
INPUT_RATE_DEFAULT
))
:
-
3
*
input_rate
*
AOUT_MAX_PTS_ADVANCE
/
INPUT_RATE_DEFAULT
))
{
/* If the audio output is very early (which is rare other than during
{
* prebuffering), hold with silence. */
if
(
!
owner
->
sync
.
discontinuity
)
if
(
!
owner
->
sync
.
discontinuity
)
msg_
Err
(
aout
,
"playback way too early (%"
PRId64
"): "
msg_
Warn
(
aout
,
"playback way too early (%"
PRId64
"): "
"playing silence"
,
drift
);
"playing silence"
,
drift
);
aout_StopResampling
(
aout
);
aout_DecSilence
(
aout
,
-
drift
);
aout_DecSilence
(
aout
,
-
drift
);
owner
->
sync
.
discontinuity
=
false
;
drift
=
0
;
}
else
if
(
drift
>
(
owner
->
sync
.
discontinuity
?
0
:
+
3
*
input_rate
*
AOUT_MAX_PTS_DELAY
/
INPUT_RATE_DEFAULT
))
{
/* If the audio output is very late, drop the buffers.
* This should make some room and advance playback quickly. */
if
(
!
owner
->
sync
.
discontinuity
)
msg_Err
(
aout
,
"playback way too late (%"
PRId64
"): "
"flushing buffers"
,
drift
);
aout_StopResampling
(
aout
);
aout_StopResampling
(
aout
);
owner
->
sync
.
end
=
VLC_TS_INVALID
;
owner
->
sync
.
discontinuity
=
true
;
aout_OutputFlush
(
aout
,
false
);
drift
=
0
;
goto
retry
;
/* may be too early now... retry */
}
}
if
(
drift
<
-
AOUT_MAX_PTS_ADVANCE
)
/* Resampling */
if
(
drift
>
+
AOUT_MAX_PTS_DELAY
)
{
{
if
(
owner
->
sync
.
resamp_type
==
AOUT_RESAMPLING_NONE
)
if
(
owner
->
sync
.
resamp_type
==
AOUT_RESAMPLING_NONE
)
{
{
msg_Warn
(
aout
,
"playback too
early (%"
PRId64
"): down
-sampling"
,
msg_Warn
(
aout
,
"playback too
late (%"
PRId64
"): up
-sampling"
,
drift
);
drift
);
owner
->
sync
.
resamp_start_drift
=
-
drift
;
owner
->
sync
.
resamp_start_drift
=
+
drift
;
}
}
owner
->
sync
.
resamp_type
=
AOUT_RESAMPLING_
DOWN
;
owner
->
sync
.
resamp_type
=
AOUT_RESAMPLING_
UP
;
}
}
else
if
(
drift
>
+
AOUT_MAX_PTS_DELAY
)
if
(
drift
<
-
AOUT_MAX_PTS_ADVANCE
)
{
{
if
(
owner
->
sync
.
resamp_type
==
AOUT_RESAMPLING_NONE
)
if
(
owner
->
sync
.
resamp_type
==
AOUT_RESAMPLING_NONE
)
{
{
msg_Warn
(
aout
,
"playback too
late (%"
PRId64
"): up
-sampling"
,
msg_Warn
(
aout
,
"playback too
early (%"
PRId64
"): down
-sampling"
,
drift
);
drift
);
owner
->
sync
.
resamp_start_drift
=
+
drift
;
owner
->
sync
.
resamp_start_drift
=
-
drift
;
}
}
owner
->
sync
.
resamp_type
=
AOUT_RESAMPLING_
UP
;
owner
->
sync
.
resamp_type
=
AOUT_RESAMPLING_
DOWN
;
}
}
if
(
owner
->
sync
.
resamp_type
==
AOUT_RESAMPLING_NONE
)
if
(
owner
->
sync
.
resamp_type
==
AOUT_RESAMPLING_NONE
)
...
@@ -368,7 +384,7 @@ retry:
...
@@ -368,7 +384,7 @@ retry:
if
(
llabs
(
drift
)
>
2
*
owner
->
sync
.
resamp_start_drift
)
if
(
llabs
(
drift
)
>
2
*
owner
->
sync
.
resamp_start_drift
)
{
/* If the drift is ever increasing, then something is seriously wrong.
{
/* If the drift is ever increasing, then something is seriously wrong.
* Cease resampling and hope for the best. */
* Cease resampling and hope for the best. */
msg_
Err
(
aout
,
"timing screwed (drift: %"
PRId64
" us): "
msg_
Warn
(
aout
,
"timing screwed (drift: %"
PRId64
" us): "
"stopping resampling"
,
drift
);
"stopping resampling"
,
drift
);
aout_StopResampling
(
aout
);
aout_StopResampling
(
aout
);
}
}
...
...
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