Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
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
Commits
62a75145
Commit
62a75145
authored
Nov 13, 2012
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
aout: fix flawed resampling logic
parent
17b69f2d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
38 deletions
+27
-38
src/audio_output/dec.c
src/audio_output/dec.c
+26
-37
src/audio_output/filters.c
src/audio_output/filters.c
+1
-1
No files found.
src/audio_output/dec.c
View file @
62a75145
...
...
@@ -333,61 +333,50 @@ static void aout_DecSynchronize (audio_output_t *aout, mtime_t dec_pts,
}
/* Resampling */
if
(
drift
>
+
AOUT_MAX_PTS_DELAY
)
if
(
drift
>
+
AOUT_MAX_PTS_DELAY
&&
owner
->
sync
.
resamp_type
!=
AOUT_RESAMPLING_UP
)
{
if
(
owner
->
sync
.
resamp_type
==
AOUT_RESAMPLING_NONE
)
{
msg_Warn
(
aout
,
"playback too late (%"
PRId64
"): up-sampling"
,
drift
);
owner
->
sync
.
resamp_start_drift
=
+
drift
;
}
msg_Warn
(
aout
,
"playback too late (%"
PRId64
"): up-sampling"
,
drift
);
owner
->
sync
.
resamp_type
=
AOUT_RESAMPLING_UP
;
owner
->
sync
.
resamp_start_drift
=
+
drift
;
}
if
(
drift
<
-
AOUT_MAX_PTS_ADVANCE
)
if
(
drift
<
-
AOUT_MAX_PTS_ADVANCE
&&
owner
->
sync
.
resamp_type
!=
AOUT_RESAMPLING_DOWN
)
{
if
(
owner
->
sync
.
resamp_type
==
AOUT_RESAMPLING_NONE
)
{
msg_Warn
(
aout
,
"playback too early (%"
PRId64
"): down-sampling"
,
drift
);
owner
->
sync
.
resamp_start_drift
=
-
drift
;
}
msg_Warn
(
aout
,
"playback too early (%"
PRId64
"): down-sampling"
,
drift
);
owner
->
sync
.
resamp_type
=
AOUT_RESAMPLING_DOWN
;
owner
->
sync
.
resamp_start_drift
=
-
drift
;
}
if
(
owner
->
sync
.
resamp_type
==
AOUT_RESAMPLING_NONE
)
return
;
/* Everything is fine. Nothing to do. */
if
(
llabs
(
drift
)
>
2
*
owner
->
sync
.
resamp_start_drift
)
{
/* If the drift is ever increasing, then something is seriously wrong.
* Cease resampling and hope for the best. */
msg_Warn
(
aout
,
"timing screwed (drift: %"
PRId64
" us): "
"stopping resampling"
,
drift
);
aout_StopResampling
(
aout
);
return
;
}
/* Resampling has been triggered earlier. This checks if it needs to be
* increased or decreased. Resampling rate changes must be kept slow for
* the comfort of listeners. */
const
int
adj
=
(
owner
->
sync
.
resamp_type
==
AOUT_RESAMPLING_UP
)
?
+
2
:
-
2
;
int
adj
=
(
owner
->
sync
.
resamp_type
==
AOUT_RESAMPLING_UP
)
?
+
2
:
-
2
;
if
(
2
*
llabs
(
drift
)
<=
owner
->
sync
.
resamp_start_drift
)
/* If the drift has been reduced from more than half its initial
* value, then it is time to switch back the resampling direction. */
adj
*=
-
1
;
/* Check if everything is back to normal, then stop resampling. */
if
(
!
aout_FiltersAdjustResampling
(
aout
,
adj
))
{
{
/* Everything is back to normal: stop resampling. */
owner
->
sync
.
resamp_type
=
AOUT_RESAMPLING_NONE
;
msg_Dbg
(
aout
,
"resampling stopped (drift: %"
PRId64
" us)"
,
drift
);
}
else
if
(
2
*
llabs
(
drift
)
<=
owner
->
sync
.
resamp_start_drift
)
{
/* If the drift has been reduced from more than half its initial
* value, then it is time to switch back the resampling direction. */
if
(
owner
->
sync
.
resamp_type
==
AOUT_RESAMPLING_UP
)
owner
->
sync
.
resamp_type
=
AOUT_RESAMPLING_DOWN
;
else
owner
->
sync
.
resamp_type
=
AOUT_RESAMPLING_UP
;
owner
->
sync
.
resamp_start_drift
=
0
;
}
else
if
(
llabs
(
drift
)
>
2
*
owner
->
sync
.
resamp_start_drift
)
{
/* If the drift is ever increasing, then something is seriously wrong.
* Cease resampling and hope for the best. */
msg_Warn
(
aout
,
"timing screwed (drift: %"
PRId64
" us): "
"stopping resampling"
,
drift
);
aout_StopResampling
(
aout
);
}
}
/*****************************************************************************
...
...
src/audio_output/filters.c
View file @
62a75145
...
...
@@ -550,7 +550,7 @@ bool aout_FiltersAdjustResampling (audio_output_t *aout, int adjust)
owner
->
resampling
+=
adjust
;
else
owner
->
resampling
=
0
;
return
!
owner
->
resampling
;
return
owner
->
resampling
!=
0
;
}
block_t
*
aout_FiltersPlay
(
audio_output_t
*
aout
,
block_t
*
block
,
int
rate
)
...
...
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