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
f1c646b7
authored
Nov 13, 2014
by
Oliver Woodman
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add diagnostic info to decoder exceptions + minor cleanup
parent
59688397
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
14 deletions
library/src/main/java/com/google/android/exoplayer/MediaCodecAudioTrackRenderer.java
library/src/main/java/com/google/android/exoplayer/MediaCodecTrackRenderer.java
library/src/main/java/com/google/android/exoplayer/MediaCodecAudioTrackRenderer.java
View file @
f1c646b7
...
@@ -68,8 +68,8 @@ public class MediaCodecAudioTrackRenderer extends MediaCodecTrackRenderer {
...
@@ -68,8 +68,8 @@ public class MediaCodecAudioTrackRenderer extends MediaCodecTrackRenderer {
public
AudioTrackInitializationException
(
int
audioTrackState
,
int
sampleRate
,
public
AudioTrackInitializationException
(
int
audioTrackState
,
int
sampleRate
,
int
channelConfig
,
int
bufferSize
)
{
int
channelConfig
,
int
bufferSize
)
{
super
(
"AudioTrack init failed: "
+
audioTrackState
+
", Config("
+
sampleRate
+
", "
+
super
(
"AudioTrack init failed: "
+
audioTrackState
+
", Config("
+
sampleRate
+
", "
channelConfig
+
", "
+
bufferSize
+
")"
);
+
channelConfig
+
", "
+
bufferSize
+
")"
);
this
.
audioTrackState
=
audioTrackState
;
this
.
audioTrackState
=
audioTrackState
;
}
}
...
@@ -538,8 +538,8 @@ public class MediaCodecAudioTrackRenderer extends MediaCodecTrackRenderer {
...
@@ -538,8 +538,8 @@ public class MediaCodecAudioTrackRenderer extends MediaCodecTrackRenderer {
// Compute the audio track latency, excluding the latency due to the buffer (leaving
// Compute the audio track latency, excluding the latency due to the buffer (leaving
// latency due to the mixer and audio hardware driver).
// latency due to the mixer and audio hardware driver).
audioTrackLatencyUs
=
audioTrackLatencyUs
=
(
Integer
)
audioTrackGetLatencyMethod
.
invoke
(
audioTrack
,
(
Object
[])
null
)
*
1000L
-
(
Integer
)
audioTrackGetLatencyMethod
.
invoke
(
audioTrack
,
(
Object
[])
null
)
*
1000L
framesToDurationUs
(
bufferSize
/
frameSize
);
-
framesToDurationUs
(
bufferSize
/
frameSize
);
// Sanity check that the latency is non-negative.
// Sanity check that the latency is non-negative.
audioTrackLatencyUs
=
Math
.
max
(
audioTrackLatencyUs
,
0
);
audioTrackLatencyUs
=
Math
.
max
(
audioTrackLatencyUs
,
0
);
// Sanity check that the latency isn't too large.
// Sanity check that the latency isn't too large.
...
@@ -612,19 +612,19 @@ public class MediaCodecAudioTrackRenderer extends MediaCodecTrackRenderer {
...
@@ -612,19 +612,19 @@ public class MediaCodecAudioTrackRenderer extends MediaCodecTrackRenderer {
if
(
temporaryBufferSize
==
0
)
{
if
(
temporaryBufferSize
==
0
)
{
// This is the first time we've seen this {@code buffer}.
// This is the first time we've seen this {@code buffer}.
// Note: presentationTimeUs corresponds to the end of the sample, not the start.
// Note: presentationTimeUs corresponds to the end of the sample, not the start.
long
bufferStartTime
=
bufferInfo
.
presentationTimeUs
-
long
bufferStartTime
=
bufferInfo
.
presentationTimeUs
framesToDurationUs
(
bufferInfo
.
size
/
frameSize
);
-
framesToDurationUs
(
bufferInfo
.
size
/
frameSize
);
if
(
audioTrackStartMediaTimeState
==
START_NOT_SET
)
{
if
(
audioTrackStartMediaTimeState
==
START_NOT_SET
)
{
audioTrackStartMediaTimeUs
=
Math
.
max
(
0
,
bufferStartTime
);
audioTrackStartMediaTimeUs
=
Math
.
max
(
0
,
bufferStartTime
);
audioTrackStartMediaTimeState
=
START_IN_SYNC
;
audioTrackStartMediaTimeState
=
START_IN_SYNC
;
}
else
{
}
else
{
// Sanity check that bufferStartTime is consistent with the expected value.
// Sanity check that bufferStartTime is consistent with the expected value.
long
expectedBufferStartTime
=
audioTrackStartMediaTimeUs
+
long
expectedBufferStartTime
=
audioTrackStartMediaTimeUs
framesToDurationUs
(
submittedBytes
/
frameSize
);
+
framesToDurationUs
(
submittedBytes
/
frameSize
);
if
(
audioTrackStartMediaTimeState
==
START_IN_SYNC
if
(
audioTrackStartMediaTimeState
==
START_IN_SYNC
&&
Math
.
abs
(
expectedBufferStartTime
-
bufferStartTime
)
>
200000
)
{
&&
Math
.
abs
(
expectedBufferStartTime
-
bufferStartTime
)
>
200000
)
{
Log
.
e
(
TAG
,
"Discontinuity detected [expected "
+
expectedBufferStartTime
+
", got "
+
Log
.
e
(
TAG
,
"Discontinuity detected [expected "
+
expectedBufferStartTime
+
", got "
bufferStartTime
+
"]"
);
+
bufferStartTime
+
"]"
);
audioTrackStartMediaTimeState
=
START_NEED_SYNC
;
audioTrackStartMediaTimeState
=
START_NEED_SYNC
;
}
}
if
(
audioTrackStartMediaTimeState
==
START_NEED_SYNC
)
{
if
(
audioTrackStartMediaTimeState
==
START_NEED_SYNC
)
{
...
@@ -679,7 +679,7 @@ public class MediaCodecAudioTrackRenderer extends MediaCodecTrackRenderer {
...
@@ -679,7 +679,7 @@ public class MediaCodecAudioTrackRenderer extends MediaCodecTrackRenderer {
}
}
@TargetApi
(
21
)
@TargetApi
(
21
)
private
int
writeNonBlockingV21
(
AudioTrack
audioTrack
,
ByteBuffer
buffer
,
int
size
)
{
private
static
int
writeNonBlockingV21
(
AudioTrack
audioTrack
,
ByteBuffer
buffer
,
int
size
)
{
return
audioTrack
.
write
(
buffer
,
size
,
AudioTrack
.
WRITE_NON_BLOCKING
);
return
audioTrack
.
write
(
buffer
,
size
,
AudioTrack
.
WRITE_NON_BLOCKING
);
}
}
...
@@ -703,8 +703,8 @@ public class MediaCodecAudioTrackRenderer extends MediaCodecTrackRenderer {
...
@@ -703,8 +703,8 @@ public class MediaCodecAudioTrackRenderer extends MediaCodecTrackRenderer {
}
}
private
int
getPendingFrameCount
()
{
private
int
getPendingFrameCount
()
{
return
audioTrack
==
null
?
return
audioTrack
==
null
0
:
(
int
)
(
submittedBytes
/
frameSize
-
getPlaybackHeadPosition
());
?
0
:
(
int
)
(
submittedBytes
/
frameSize
-
getPlaybackHeadPosition
());
}
}
@Override
@Override
...
...
library/src/main/java/com/google/android/exoplayer/MediaCodecTrackRenderer.java
View file @
f1c646b7
...
@@ -21,6 +21,7 @@ import com.google.android.exoplayer.util.Util;
...
@@ -21,6 +21,7 @@ import com.google.android.exoplayer.util.Util;
import
android.annotation.TargetApi
;
import
android.annotation.TargetApi
;
import
android.media.MediaCodec
;
import
android.media.MediaCodec
;
import
android.media.MediaCodec.CodecException
;
import
android.media.MediaCodec.CryptoException
;
import
android.media.MediaCodec.CryptoException
;
import
android.media.MediaCrypto
;
import
android.media.MediaCrypto
;
import
android.media.MediaExtractor
;
import
android.media.MediaExtractor
;
...
@@ -70,10 +71,24 @@ public abstract class MediaCodecTrackRenderer extends TrackRenderer {
...
@@ -70,10 +71,24 @@ public abstract class MediaCodecTrackRenderer extends TrackRenderer {
*/
*/
public
final
String
decoderName
;
public
final
String
decoderName
;
/**
* An optional developer-readable diagnostic information string. May be null.
*/
public
final
String
diagnosticInfo
;
public
DecoderInitializationException
(
String
decoderName
,
MediaFormat
mediaFormat
,
public
DecoderInitializationException
(
String
decoderName
,
MediaFormat
mediaFormat
,
Exception
cause
)
{
Throwable
cause
)
{
super
(
"Decoder init failed: "
+
decoderName
+
", "
+
mediaFormat
,
cause
);
super
(
"Decoder init failed: "
+
decoderName
+
", "
+
mediaFormat
,
cause
);
this
.
decoderName
=
decoderName
;
this
.
decoderName
=
decoderName
;
this
.
diagnosticInfo
=
Util
.
SDK_INT
>=
21
?
getDiagnosticInfoV21
(
cause
)
:
null
;
}
@TargetApi
(
21
)
private
static
String
getDiagnosticInfoV21
(
Throwable
cause
)
{
if
(
cause
instanceof
CodecException
)
{
return
((
CodecException
)
cause
).
getDiagnosticInfo
();
}
return
null
;
}
}
}
}
...
@@ -235,6 +250,7 @@ public abstract class MediaCodecTrackRenderer extends TrackRenderer {
...
@@ -235,6 +250,7 @@ public abstract class MediaCodecTrackRenderer extends TrackRenderer {
codec
.
configure
(
x
,
null
,
crypto
,
0
);
codec
.
configure
(
x
,
null
,
crypto
,
0
);
}
}
@SuppressWarnings
(
"deprecation"
)
protected
final
void
maybeInitCodec
()
throws
ExoPlaybackException
{
protected
final
void
maybeInitCodec
()
throws
ExoPlaybackException
{
if
(!
shouldInitCodec
())
{
if
(!
shouldInitCodec
())
{
return
;
return
;
...
@@ -694,6 +710,7 @@ public abstract class MediaCodecTrackRenderer extends TrackRenderer {
...
@@ -694,6 +710,7 @@ public abstract class MediaCodecTrackRenderer extends TrackRenderer {
* @return True if it may be possible to drain more output data. False otherwise.
* @return True if it may be possible to drain more output data. False otherwise.
* @throws ExoPlaybackException If an error occurs draining the output buffer.
* @throws ExoPlaybackException If an error occurs draining the output buffer.
*/
*/
@SuppressWarnings
(
"deprecation"
)
private
boolean
drainOutputBuffer
(
long
positionUs
,
long
elapsedRealtimeUs
)
private
boolean
drainOutputBuffer
(
long
positionUs
,
long
elapsedRealtimeUs
)
throws
ExoPlaybackException
{
throws
ExoPlaybackException
{
if
(
outputStreamEnded
)
{
if
(
outputStreamEnded
)
{
...
...
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