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
94b66f4c
authored
Aug 14, 2020
by
olly
Committed by
kim-vde
Aug 17, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Specify which function is triggering a TimeoutException
PiperOrigin-RevId: 326666629
parent
977f0d1e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
92 additions
and
12 deletions
library/core/src/main/java/com/google/android/exoplayer2/ExoPlaybackException.java
library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImpl.java
library/core/src/main/java/com/google/android/exoplayer2/ExoPlaybackException.java
View file @
94b66f4c
...
@@ -27,6 +27,7 @@ import java.io.IOException;
...
@@ -27,6 +27,7 @@ import java.io.IOException;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.RetentionPolicy
;
import
java.util.concurrent.TimeoutException
;
/**
/**
* Thrown when a non-recoverable playback failure occurs.
* Thrown when a non-recoverable playback failure occurs.
...
@@ -35,12 +36,20 @@ public final class ExoPlaybackException extends Exception {
...
@@ -35,12 +36,20 @@ public final class ExoPlaybackException extends Exception {
/**
/**
* The type of source that produced the error. One of {@link #TYPE_SOURCE}, {@link #TYPE_RENDERER}
* The type of source that produced the error. One of {@link #TYPE_SOURCE}, {@link #TYPE_RENDERER}
* {@link #TYPE_UNEXPECTED}, {@link #TYPE_REMOTE} or {@link #TYPE_OUT_OF_MEMORY}. Note that new
* {@link #TYPE_UNEXPECTED}, {@link #TYPE_REMOTE}, {@link #TYPE_OUT_OF_MEMORY} or {@link
* types may be added in the future and error handling should handle unknown type values.
* #TYPE_TIMEOUT}. Note that new types may be added in the future and error handling should handle
* unknown type values.
*/
*/
@Documented
@Documented
@Retention
(
RetentionPolicy
.
SOURCE
)
@Retention
(
RetentionPolicy
.
SOURCE
)
@IntDef
({
TYPE_SOURCE
,
TYPE_RENDERER
,
TYPE_UNEXPECTED
,
TYPE_REMOTE
,
TYPE_OUT_OF_MEMORY
})
@IntDef
({
TYPE_SOURCE
,
TYPE_RENDERER
,
TYPE_UNEXPECTED
,
TYPE_REMOTE
,
TYPE_OUT_OF_MEMORY
,
TYPE_TIMEOUT
})
public
@interface
Type
{}
public
@interface
Type
{}
/**
/**
* The error occurred loading data from a {@link MediaSource}.
* The error occurred loading data from a {@link MediaSource}.
...
@@ -68,10 +77,34 @@ public final class ExoPlaybackException extends Exception {
...
@@ -68,10 +77,34 @@ public final class ExoPlaybackException extends Exception {
public
static
final
int
TYPE_REMOTE
=
3
;
public
static
final
int
TYPE_REMOTE
=
3
;
/** The error was an {@link OutOfMemoryError}. */
/** The error was an {@link OutOfMemoryError}. */
public
static
final
int
TYPE_OUT_OF_MEMORY
=
4
;
public
static
final
int
TYPE_OUT_OF_MEMORY
=
4
;
/** The error was a {@link TimeoutException}. */
public
static
final
int
TYPE_TIMEOUT
=
5
;
/** The {@link Type} of the playback failure. */
/** The {@link Type} of the playback failure. */
@Type
public
final
int
type
;
@Type
public
final
int
type
;
/**
* The operation which produced the timeout error. One of {@link #TIMEOUT_OPERATION_RELEASE},
* {@link #TIMEOUT_OPERATION_SET_FOREGROUND_MODE} or {@link #TIMEOUT_OPERATION_UNDEFINED}. Note
* that new operations may be added in the future and error handling should handle unknown
* operation values.
*/
@Documented
@Retention
(
RetentionPolicy
.
SOURCE
)
@IntDef
({
TIMEOUT_OPERATION_UNDEFINED
,
TIMEOUT_OPERATION_RELEASE
,
TIMEOUT_OPERATION_SET_FOREGROUND_MODE
})
public
@interface
TimeoutOperation
{}
/** The operation where this error occurred is not defined. */
public
static
final
int
TIMEOUT_OPERATION_UNDEFINED
=
0
;
/** The error occurred in {@link ExoPlayer#release}. */
public
static
final
int
TIMEOUT_OPERATION_RELEASE
=
1
;
/** The error occurred in {@link ExoPlayer#setForegroundMode}. */
public
static
final
int
TIMEOUT_OPERATION_SET_FOREGROUND_MODE
=
2
;
/** If {@link #type} is {@link #TYPE_RENDERER}, this is the name of the renderer. */
/** If {@link #type} is {@link #TYPE_RENDERER}, this is the name of the renderer. */
@Nullable
public
final
String
rendererName
;
@Nullable
public
final
String
rendererName
;
...
@@ -91,6 +124,11 @@ public final class ExoPlaybackException extends Exception {
...
@@ -91,6 +124,11 @@ public final class ExoPlaybackException extends Exception {
*/
*/
@FormatSupport
public
final
int
rendererFormatSupport
;
@FormatSupport
public
final
int
rendererFormatSupport
;
/**
* If {@link #type} is {@link #TYPE_TIMEOUT}, this is the operation where the timeout happened.
*/
@TimeoutOperation
public
final
int
timeoutOperation
;
/** The value of {@link SystemClock#elapsedRealtime()} when this exception was created. */
/** The value of {@link SystemClock#elapsedRealtime()} when this exception was created. */
public
final
long
timestampMs
;
public
final
long
timestampMs
;
...
@@ -136,7 +174,8 @@ public final class ExoPlaybackException extends Exception {
...
@@ -136,7 +174,8 @@ public final class ExoPlaybackException extends Exception {
rendererName
,
rendererName
,
rendererIndex
,
rendererIndex
,
rendererFormat
,
rendererFormat
,
rendererFormat
==
null
?
RendererCapabilities
.
FORMAT_HANDLED
:
rendererFormatSupport
);
rendererFormat
==
null
?
RendererCapabilities
.
FORMAT_HANDLED
:
rendererFormatSupport
,
TIMEOUT_OPERATION_UNDEFINED
);
}
}
/**
/**
...
@@ -169,6 +208,26 @@ public final class ExoPlaybackException extends Exception {
...
@@ -169,6 +208,26 @@ public final class ExoPlaybackException extends Exception {
return
new
ExoPlaybackException
(
TYPE_OUT_OF_MEMORY
,
cause
);
return
new
ExoPlaybackException
(
TYPE_OUT_OF_MEMORY
,
cause
);
}
}
/**
* Creates an instance of type {@link #TYPE_TIMEOUT}.
*
* @param cause The cause of the failure.
* @param timeoutOperation The operation that caused this timeout.
* @return The created instance.
*/
public
static
ExoPlaybackException
createForTimeoutError
(
TimeoutException
cause
,
@TimeoutOperation
int
timeoutOperation
)
{
return
new
ExoPlaybackException
(
TYPE_OUT_OF_MEMORY
,
cause
,
/* customMessage= */
null
,
/* rendererName= */
null
,
/* rendererIndex= */
C
.
INDEX_UNSET
,
/* rendererFormat= */
null
,
/* rendererFormatSupport= */
RendererCapabilities
.
FORMAT_HANDLED
,
timeoutOperation
);
}
private
ExoPlaybackException
(
@Type
int
type
,
Throwable
cause
)
{
private
ExoPlaybackException
(
@Type
int
type
,
Throwable
cause
)
{
this
(
this
(
type
,
type
,
...
@@ -177,7 +236,8 @@ public final class ExoPlaybackException extends Exception {
...
@@ -177,7 +236,8 @@ public final class ExoPlaybackException extends Exception {
/* rendererName= */
null
,
/* rendererName= */
null
,
/* rendererIndex= */
C
.
INDEX_UNSET
,
/* rendererIndex= */
C
.
INDEX_UNSET
,
/* rendererFormat= */
null
,
/* rendererFormat= */
null
,
/* rendererFormatSupport= */
RendererCapabilities
.
FORMAT_HANDLED
);
/* rendererFormatSupport= */
RendererCapabilities
.
FORMAT_HANDLED
,
TIMEOUT_OPERATION_UNDEFINED
);
}
}
private
ExoPlaybackException
(
@Type
int
type
,
String
message
)
{
private
ExoPlaybackException
(
@Type
int
type
,
String
message
)
{
...
@@ -188,7 +248,8 @@ public final class ExoPlaybackException extends Exception {
...
@@ -188,7 +248,8 @@ public final class ExoPlaybackException extends Exception {
/* rendererName= */
null
,
/* rendererName= */
null
,
/* rendererIndex= */
C
.
INDEX_UNSET
,
/* rendererIndex= */
C
.
INDEX_UNSET
,
/* rendererFormat= */
null
,
/* rendererFormat= */
null
,
/* rendererFormatSupport= */
RendererCapabilities
.
FORMAT_HANDLED
);
/* rendererFormatSupport= */
RendererCapabilities
.
FORMAT_HANDLED
,
/* timeoutOperation= */
TIMEOUT_OPERATION_UNDEFINED
);
}
}
private
ExoPlaybackException
(
private
ExoPlaybackException
(
...
@@ -198,7 +259,8 @@ public final class ExoPlaybackException extends Exception {
...
@@ -198,7 +259,8 @@ public final class ExoPlaybackException extends Exception {
@Nullable
String
rendererName
,
@Nullable
String
rendererName
,
int
rendererIndex
,
int
rendererIndex
,
@Nullable
Format
rendererFormat
,
@Nullable
Format
rendererFormat
,
@FormatSupport
int
rendererFormatSupport
)
{
@FormatSupport
int
rendererFormatSupport
,
@TimeoutOperation
int
timeoutOperation
)
{
this
(
this
(
deriveMessage
(
deriveMessage
(
type
,
type
,
...
@@ -214,6 +276,7 @@ public final class ExoPlaybackException extends Exception {
...
@@ -214,6 +276,7 @@ public final class ExoPlaybackException extends Exception {
rendererFormat
,
rendererFormat
,
rendererFormatSupport
,
rendererFormatSupport
,
/* mediaPeriodId= */
null
,
/* mediaPeriodId= */
null
,
timeoutOperation
,
/* timestampMs= */
SystemClock
.
elapsedRealtime
());
/* timestampMs= */
SystemClock
.
elapsedRealtime
());
}
}
...
@@ -226,6 +289,7 @@ public final class ExoPlaybackException extends Exception {
...
@@ -226,6 +289,7 @@ public final class ExoPlaybackException extends Exception {
@Nullable
Format
rendererFormat
,
@Nullable
Format
rendererFormat
,
@FormatSupport
int
rendererFormatSupport
,
@FormatSupport
int
rendererFormatSupport
,
@Nullable
MediaSource
.
MediaPeriodId
mediaPeriodId
,
@Nullable
MediaSource
.
MediaPeriodId
mediaPeriodId
,
@TimeoutOperation
int
timeoutOperation
,
long
timestampMs
)
{
long
timestampMs
)
{
super
(
message
,
cause
);
super
(
message
,
cause
);
this
.
type
=
type
;
this
.
type
=
type
;
...
@@ -235,6 +299,7 @@ public final class ExoPlaybackException extends Exception {
...
@@ -235,6 +299,7 @@ public final class ExoPlaybackException extends Exception {
this
.
rendererFormat
=
rendererFormat
;
this
.
rendererFormat
=
rendererFormat
;
this
.
rendererFormatSupport
=
rendererFormatSupport
;
this
.
rendererFormatSupport
=
rendererFormatSupport
;
this
.
mediaPeriodId
=
mediaPeriodId
;
this
.
mediaPeriodId
=
mediaPeriodId
;
this
.
timeoutOperation
=
timeoutOperation
;
this
.
timestampMs
=
timestampMs
;
this
.
timestampMs
=
timestampMs
;
}
}
...
@@ -279,6 +344,16 @@ public final class ExoPlaybackException extends Exception {
...
@@ -279,6 +344,16 @@ public final class ExoPlaybackException extends Exception {
}
}
/**
/**
* Retrieves the underlying error when {@link #type} is {@link #TYPE_TIMEOUT}.
*
* @throws IllegalStateException If {@link #type} is not {@link #TYPE_TIMEOUT}.
*/
public
TimeoutException
getTimeoutError
()
{
Assertions
.
checkState
(
type
==
TYPE_TIMEOUT
);
return
(
TimeoutException
)
Assertions
.
checkNotNull
(
cause
);
}
/**
* Returns a copy of this exception with the provided {@link MediaSource.MediaPeriodId}.
* Returns a copy of this exception with the provided {@link MediaSource.MediaPeriodId}.
*
*
* @param mediaPeriodId The {@link MediaSource.MediaPeriodId}.
* @param mediaPeriodId The {@link MediaSource.MediaPeriodId}.
...
@@ -296,6 +371,7 @@ public final class ExoPlaybackException extends Exception {
...
@@ -296,6 +371,7 @@ public final class ExoPlaybackException extends Exception {
rendererFormat
,
rendererFormat
,
rendererFormatSupport
,
rendererFormatSupport
,
mediaPeriodId
,
mediaPeriodId
,
timeoutOperation
,
timestampMs
);
timestampMs
);
}
}
...
@@ -329,6 +405,9 @@ public final class ExoPlaybackException extends Exception {
...
@@ -329,6 +405,9 @@ public final class ExoPlaybackException extends Exception {
case
TYPE_OUT_OF_MEMORY:
case
TYPE_OUT_OF_MEMORY:
message
=
"Out of memory error"
;
message
=
"Out of memory error"
;
break
;
break
;
case
TYPE_TIMEOUT:
message
=
"Timeout error"
;
break
;
case
TYPE_UNEXPECTED:
case
TYPE_UNEXPECTED:
default
:
default
:
message
=
"Unexpected runtime error"
;
message
=
"Unexpected runtime error"
;
...
...
library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImpl.java
View file @
94b66f4c
...
@@ -683,9 +683,9 @@ import java.util.concurrent.TimeoutException;
...
@@ -683,9 +683,9 @@ import java.util.concurrent.TimeoutException;
notifyListeners
(
notifyListeners
(
listener
->
listener
->
listener
.
onPlayerError
(
listener
.
onPlayerError
(
ExoPlaybackException
.
createFor
Unexpected
(
ExoPlaybackException
.
createFor
TimeoutError
(
new
RuntimeException
(
new
TimeoutException
(
"Setting foreground mode timed out."
),
new
TimeoutException
(
"Setting foreground mode timed out."
))
)));
ExoPlaybackException
.
TIMEOUT_OPERATION_SET_FOREGROUND_MODE
)));
}
}
}
}
}
}
...
@@ -724,8 +724,9 @@ import java.util.concurrent.TimeoutException;
...
@@ -724,8 +724,9 @@ import java.util.concurrent.TimeoutException;
notifyListeners
(
notifyListeners
(
listener
->
listener
->
listener
.
onPlayerError
(
listener
.
onPlayerError
(
ExoPlaybackException
.
createForUnexpected
(
ExoPlaybackException
.
createForTimeoutError
(
new
RuntimeException
(
new
TimeoutException
(
"Player release timed out."
)))));
new
TimeoutException
(
"Player release timed out."
),
ExoPlaybackException
.
TIMEOUT_OPERATION_RELEASE
)));
}
}
playbackInfoUpdateHandler
.
removeCallbacksAndMessages
(
null
);
playbackInfoUpdateHandler
.
removeCallbacksAndMessages
(
null
);
if
(
analyticsCollector
!=
null
)
{
if
(
analyticsCollector
!=
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