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
3b25928a
authored
Sep 08, 2014
by
Oliver Woodman
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Make audio renderer more robust to bad getTimestamp values.
parent
a7b88cd6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
5 deletions
library/src/main/java/com/google/android/exoplayer/MediaCodecAudioTrackRenderer.java
library/src/main/java/com/google/android/exoplayer/MediaCodecAudioTrackRenderer.java
View file @
3b25928a
...
@@ -92,6 +92,13 @@ public class MediaCodecAudioTrackRenderer extends MediaCodecTrackRenderer {
...
@@ -92,6 +92,13 @@ public class MediaCodecAudioTrackRenderer extends MediaCodecTrackRenderer {
private
static
final
long
MICROS_PER_SECOND
=
1000000L
;
private
static
final
long
MICROS_PER_SECOND
=
1000000L
;
/**
* 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.
*/
private
static
final
long
MAX_AUDIO_TIMSTAMP_OFFSET_US
=
10
*
MICROS_PER_SECOND
;
private
static
final
int
MAX_PLAYHEAD_OFFSET_COUNT
=
10
;
private
static
final
int
MAX_PLAYHEAD_OFFSET_COUNT
=
10
;
private
static
final
int
MIN_PLAYHEAD_OFFSET_SAMPLE_INTERVAL_US
=
30000
;
private
static
final
int
MIN_PLAYHEAD_OFFSET_SAMPLE_INTERVAL_US
=
30000
;
private
static
final
int
MIN_TIMESTAMP_SAMPLE_INTERVAL_US
=
500000
;
private
static
final
int
MIN_TIMESTAMP_SAMPLE_INTERVAL_US
=
500000
;
...
@@ -502,11 +509,18 @@ public class MediaCodecAudioTrackRenderer extends MediaCodecTrackRenderer {
...
@@ -502,11 +509,18 @@ public class MediaCodecAudioTrackRenderer extends MediaCodecTrackRenderer {
if
(
systemClockUs
-
lastTimestampSampleTimeUs
>=
MIN_TIMESTAMP_SAMPLE_INTERVAL_US
)
{
if
(
systemClockUs
-
lastTimestampSampleTimeUs
>=
MIN_TIMESTAMP_SAMPLE_INTERVAL_US
)
{
audioTimestampSet
=
audioTimestampCompat
.
initTimestamp
(
audioTrack
);
audioTimestampSet
=
audioTimestampCompat
.
initTimestamp
(
audioTrack
);
if
(
audioTimestampSet
if
(
audioTimestampSet
)
{
&&
(
audioTimestampCompat
.
getNanoTime
()
/
1000
)
<
audioTrackResumeSystemTimeUs
)
{
// Perform sanity checks on the timestamp.
// The timestamp was set, but it corresponds to a time before the track was most recently
long
audioTimestampUs
=
audioTimestampCompat
.
getNanoTime
()
/
1000
;
// resumed.
if
(
audioTimestampUs
<
audioTrackResumeSystemTimeUs
)
{
audioTimestampSet
=
false
;
// 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
)
{
// The timestamp time base is probably wrong.
audioTimestampSet
=
false
;
Log
.
w
(
TAG
,
"Spurious audio timestamp: "
+
audioTimestampCompat
.
getFramePosition
()
+
", "
+
audioTimestampUs
+
", "
+
systemClockUs
);
}
}
}
if
(
audioTrackGetLatencyMethod
!=
null
)
{
if
(
audioTrackGetLatencyMethod
!=
null
)
{
try
{
try
{
...
...
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