Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
43712ce4
authored
Oct 09, 2014
by
Oliver Woodman
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Cap AudioTrack latencies at 10 seconds and log a warning if too large.
parent
ac18ac08
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
4 deletions
library/src/main/java/com/google/android/exoplayer/MediaCodecAudioTrackRenderer.java
library/src/main/java/com/google/android/exoplayer/MediaCodecAudioTrackRenderer.java
View file @
43712ce4
...
...
@@ -94,10 +94,18 @@ public class MediaCodecAudioTrackRenderer extends MediaCodecTrackRenderer {
/**
* AudioTrack timestamps are deemed spurious if they are offset from the system clock by more
* than this amount. This is a fail safe that should not be required on correctly functioning
* devices.
* than this amount.
* <p>
* This is a fail safe that should not be required on correctly functioning devices.
*/
private
static
final
long
MAX_AUDIO_TIMESTAMP_OFFSET_US
=
10
*
MICROS_PER_SECOND
;
/**
* AudioTrack latencies are deemed impossibly large if they are greater than this amount.
* <p>
* This is a fail safe that should not be required on correctly functioning devices.
*/
private
static
final
long
MAX_AUDIO_T
IMSTAMP_OFFSET
_US
=
10
*
MICROS_PER_SECOND
;
private
static
final
long
MAX_AUDIO_T
RACK_LATENCY
_US
=
10
*
MICROS_PER_SECOND
;
private
static
final
int
MAX_PLAYHEAD_OFFSET_COUNT
=
10
;
private
static
final
int
MIN_PLAYHEAD_OFFSET_SAMPLE_INTERVAL_US
=
30000
;
...
...
@@ -515,7 +523,7 @@ public class MediaCodecAudioTrackRenderer extends MediaCodecTrackRenderer {
if
(
audioTimestampUs
<
audioTrackResumeSystemTimeUs
)
{
// The timestamp corresponds to a time before the track was most recently resumed.
audioTimestampSet
=
false
;
}
else
if
(
Math
.
abs
(
audioTimestampUs
-
systemClockUs
)
>
MAX_AUDIO_TIMSTAMP_OFFSET_US
)
{
}
else
if
(
Math
.
abs
(
audioTimestampUs
-
systemClockUs
)
>
MAX_AUDIO_TIM
E
STAMP_OFFSET_US
)
{
// The timestamp time base is probably wrong.
audioTimestampSet
=
false
;
Log
.
w
(
TAG
,
"Spurious audio timestamp: "
+
audioTimestampCompat
.
getFramePosition
()
+
", "
...
...
@@ -531,6 +539,11 @@ public class MediaCodecAudioTrackRenderer extends MediaCodecTrackRenderer {
framesToDurationUs
(
bufferSize
/
frameSize
);
// Sanity check that the latency is non-negative.
audioTrackLatencyUs
=
Math
.
max
(
audioTrackLatencyUs
,
0
);
// Sanity check that the latency isn't too large.
if
(
audioTrackLatencyUs
>
MAX_AUDIO_TRACK_LATENCY_US
)
{
Log
.
w
(
TAG
,
"Ignoring impossibly large audio latency: "
+
audioTrackLatencyUs
);
audioTrackLatencyUs
=
0
;
}
}
catch
(
Exception
e
)
{
// The method existed, but doesn't work. Don't try again.
audioTrackGetLatencyMethod
=
null
;
...
...
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