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
49fa6d63
authored
Feb 03, 2020
by
kimvde
Committed by
Oliver Woodman
Feb 03, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Remove redundant prepared flag in ProgressiveMediaPeriod
PiperOrigin-RevId: 292892407
parent
8ac5698a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
26 deletions
library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaPeriod.java
library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaPeriod.java
View file @
49fa6d63
...
@@ -60,6 +60,7 @@ import java.util.Collections;
...
@@ -60,6 +60,7 @@ import java.util.Collections;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
import
org.checkerframework.checker.nullness.compatqual.NullableType
;
import
org.checkerframework.checker.nullness.compatqual.NullableType
;
import
org.checkerframework.checker.nullness.qual.MonotonicNonNull
;
/** A {@link MediaPeriod} that extracts data using an {@link Extractor}. */
/** A {@link MediaPeriod} that extracts data using an {@link Extractor}. */
/* package */
final
class
ProgressiveMediaPeriod
/* package */
final
class
ProgressiveMediaPeriod
...
@@ -118,9 +119,8 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
...
@@ -118,9 +119,8 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
private
SampleQueue
[]
sampleQueues
;
private
SampleQueue
[]
sampleQueues
;
private
TrackId
[]
sampleQueueTrackIds
;
private
TrackId
[]
sampleQueueTrackIds
;
private
boolean
sampleQueuesBuilt
;
private
boolean
sampleQueuesBuilt
;
private
boolean
prepared
;
@Nullable
private
PreparedState
preparedState
;
private
@MonotonicNonNull
PreparedState
preparedState
;
private
boolean
haveAudioVideoTracks
;
private
boolean
haveAudioVideoTracks
;
private
int
dataType
;
private
int
dataType
;
...
@@ -200,7 +200,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
...
@@ -200,7 +200,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
}
}
public
void
release
()
{
public
void
release
()
{
if
(
prepared
)
{
if
(
prepared
State
!=
null
)
{
// Discard as much as we can synchronously. We only do this if we're prepared, since otherwise
// Discard as much as we can synchronously. We only do this if we're prepared, since otherwise
// sampleQueues may still be being modified by the loading thread.
// sampleQueues may still be being modified by the loading thread.
for
(
SampleQueue
sampleQueue
:
sampleQueues
)
{
for
(
SampleQueue
sampleQueue
:
sampleQueues
)
{
...
@@ -232,14 +232,14 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
...
@@ -232,14 +232,14 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
@Override
@Override
public
void
maybeThrowPrepareError
()
throws
IOException
{
public
void
maybeThrowPrepareError
()
throws
IOException
{
maybeThrowError
();
maybeThrowError
();
if
(
loadingFinished
&&
!
prepared
)
{
if
(
loadingFinished
&&
preparedState
==
null
)
{
throw
new
ParserException
(
"Loading finished before preparation is complete."
);
throw
new
ParserException
(
"Loading finished before preparation is complete."
);
}
}
}
}
@Override
@Override
public
TrackGroupArray
getTrackGroups
()
{
public
TrackGroupArray
getTrackGroups
()
{
return
getPreparedState
(
).
tracks
;
return
Assertions
.
checkNotNull
(
preparedState
).
tracks
;
}
}
@Override
@Override
...
@@ -249,8 +249,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
...
@@ -249,8 +249,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
@NullableType
SampleStream
[]
streams
,
@NullableType
SampleStream
[]
streams
,
boolean
[]
streamResetFlags
,
boolean
[]
streamResetFlags
,
long
positionUs
)
{
long
positionUs
)
{
PreparedState
preparedState
=
getPreparedState
();
TrackGroupArray
tracks
=
Assertions
.
checkNotNull
(
preparedState
).
tracks
;
TrackGroupArray
tracks
=
preparedState
.
tracks
;
boolean
[]
trackEnabledStates
=
preparedState
.
trackEnabledStates
;
boolean
[]
trackEnabledStates
=
preparedState
.
trackEnabledStates
;
int
oldEnabledTrackCount
=
enabledTrackCount
;
int
oldEnabledTrackCount
=
enabledTrackCount
;
// Deselect old tracks.
// Deselect old tracks.
...
@@ -323,7 +322,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
...
@@ -323,7 +322,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
if
(
isPendingReset
())
{
if
(
isPendingReset
())
{
return
;
return
;
}
}
boolean
[]
trackEnabledStates
=
getPreparedState
(
).
trackEnabledStates
;
boolean
[]
trackEnabledStates
=
Assertions
.
checkNotNull
(
preparedState
).
trackEnabledStates
;
int
trackCount
=
sampleQueues
.
length
;
int
trackCount
=
sampleQueues
.
length
;
for
(
int
i
=
0
;
i
<
trackCount
;
i
++)
{
for
(
int
i
=
0
;
i
<
trackCount
;
i
++)
{
sampleQueues
[
i
].
discardTo
(
positionUs
,
toKeyframe
,
trackEnabledStates
[
i
]);
sampleQueues
[
i
].
discardTo
(
positionUs
,
toKeyframe
,
trackEnabledStates
[
i
]);
...
@@ -340,7 +339,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
...
@@ -340,7 +339,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
if
(
loadingFinished
if
(
loadingFinished
||
loader
.
hasFatalError
()
||
loader
.
hasFatalError
()
||
pendingDeferredRetry
||
pendingDeferredRetry
||
(
prepared
&&
enabledTrackCount
==
0
))
{
||
(
prepared
State
!=
null
&&
enabledTrackCount
==
0
))
{
return
false
;
return
false
;
}
}
boolean
continuedLoading
=
loadCondition
.
open
();
boolean
continuedLoading
=
loadCondition
.
open
();
...
@@ -377,7 +376,8 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
...
@@ -377,7 +376,8 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
@Override
@Override
public
long
getBufferedPositionUs
()
{
public
long
getBufferedPositionUs
()
{
boolean
[]
trackIsAudioVideoFlags
=
getPreparedState
().
trackIsAudioVideoFlags
;
boolean
[]
trackIsAudioVideoFlags
=
Assertions
.
checkNotNull
(
preparedState
).
trackIsAudioVideoFlags
;
if
(
loadingFinished
)
{
if
(
loadingFinished
)
{
return
C
.
TIME_END_OF_SOURCE
;
return
C
.
TIME_END_OF_SOURCE
;
}
else
if
(
isPendingReset
())
{
}
else
if
(
isPendingReset
())
{
...
@@ -403,8 +403,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
...
@@ -403,8 +403,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
@Override
@Override
public
long
seekToUs
(
long
positionUs
)
{
public
long
seekToUs
(
long
positionUs
)
{
PreparedState
preparedState
=
getPreparedState
();
SeekMap
seekMap
=
Assertions
.
checkNotNull
(
preparedState
).
seekMap
;
SeekMap
seekMap
=
preparedState
.
seekMap
;
boolean
[]
trackIsAudioVideoFlags
=
preparedState
.
trackIsAudioVideoFlags
;
boolean
[]
trackIsAudioVideoFlags
=
preparedState
.
trackIsAudioVideoFlags
;
// Treat all seeks into non-seekable media as being to t=0.
// Treat all seeks into non-seekable media as being to t=0.
positionUs
=
seekMap
.
isSeekable
()
?
positionUs
:
0
;
positionUs
=
seekMap
.
isSeekable
()
?
positionUs
:
0
;
...
@@ -440,7 +439,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
...
@@ -440,7 +439,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
@Override
@Override
public
long
getAdjustedSeekPositionUs
(
long
positionUs
,
SeekParameters
seekParameters
)
{
public
long
getAdjustedSeekPositionUs
(
long
positionUs
,
SeekParameters
seekParameters
)
{
SeekMap
seekMap
=
getPreparedState
(
).
seekMap
;
SeekMap
seekMap
=
Assertions
.
checkNotNull
(
preparedState
).
seekMap
;
if
(!
seekMap
.
isSeekable
())
{
if
(!
seekMap
.
isSeekable
())
{
// Treat all seeks into non-seekable media as being to t=0.
// Treat all seeks into non-seekable media as being to t=0.
return
0
;
return
0
;
...
@@ -502,8 +501,8 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
...
@@ -502,8 +501,8 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
}
}
private
void
maybeNotifyDownstreamFormat
(
int
track
)
{
private
void
maybeNotifyDownstreamFormat
(
int
track
)
{
PreparedState
preparedState
=
getPreparedState
();
boolean
[]
trackNotifiedDownstreamFormats
=
boolean
[]
trackNotifiedDownstreamFormats
=
preparedState
.
trackNotifiedDownstreamFormats
;
Assertions
.
checkNotNull
(
preparedState
)
.
trackNotifiedDownstreamFormats
;
if
(!
trackNotifiedDownstreamFormats
[
track
])
{
if
(!
trackNotifiedDownstreamFormats
[
track
])
{
Format
trackFormat
=
preparedState
.
tracks
.
get
(
track
).
getFormat
(
/* index= */
0
);
Format
trackFormat
=
preparedState
.
tracks
.
get
(
track
).
getFormat
(
/* index= */
0
);
eventDispatcher
.
downstreamFormatChanged
(
eventDispatcher
.
downstreamFormatChanged
(
...
@@ -517,7 +516,8 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
...
@@ -517,7 +516,8 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
}
}
private
void
maybeStartDeferredRetry
(
int
track
)
{
private
void
maybeStartDeferredRetry
(
int
track
)
{
boolean
[]
trackIsAudioVideoFlags
=
getPreparedState
().
trackIsAudioVideoFlags
;
boolean
[]
trackIsAudioVideoFlags
=
Assertions
.
checkNotNull
(
preparedState
).
trackIsAudioVideoFlags
;
if
(!
pendingDeferredRetry
if
(!
pendingDeferredRetry
||
!
trackIsAudioVideoFlags
[
track
]
||
!
trackIsAudioVideoFlags
[
track
]
||
sampleQueues
[
track
].
isReady
(
/* loadingFinished= */
false
))
{
||
sampleQueues
[
track
].
isReady
(
/* loadingFinished= */
false
))
{
...
@@ -693,7 +693,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
...
@@ -693,7 +693,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
private
void
maybeFinishPrepare
()
{
private
void
maybeFinishPrepare
()
{
SeekMap
seekMap
=
this
.
seekMap
;
SeekMap
seekMap
=
this
.
seekMap
;
if
(
released
||
prepared
||
!
sampleQueuesBuilt
||
seekMap
==
null
)
{
if
(
released
||
prepared
State
!=
null
||
!
sampleQueuesBuilt
||
seekMap
==
null
)
{
return
;
return
;
}
}
for
(
SampleQueue
sampleQueue
:
sampleQueues
)
{
for
(
SampleQueue
sampleQueue
:
sampleQueues
)
{
...
@@ -735,15 +735,10 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
...
@@ -735,15 +735,10 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
dataType
=
isLive
?
C
.
DATA_TYPE_MEDIA_PROGRESSIVE_LIVE
:
C
.
DATA_TYPE_MEDIA
;
dataType
=
isLive
?
C
.
DATA_TYPE_MEDIA_PROGRESSIVE_LIVE
:
C
.
DATA_TYPE_MEDIA
;
preparedState
=
preparedState
=
new
PreparedState
(
seekMap
,
new
TrackGroupArray
(
trackArray
),
trackIsAudioVideoFlags
);
new
PreparedState
(
seekMap
,
new
TrackGroupArray
(
trackArray
),
trackIsAudioVideoFlags
);
prepared
=
true
;
listener
.
onSourceInfoRefreshed
(
durationUs
,
seekMap
.
isSeekable
(),
isLive
);
listener
.
onSourceInfoRefreshed
(
durationUs
,
seekMap
.
isSeekable
(),
isLive
);
Assertions
.
checkNotNull
(
callback
).
onPrepared
(
this
);
Assertions
.
checkNotNull
(
callback
).
onPrepared
(
this
);
}
}
private
PreparedState
getPreparedState
()
{
return
Assertions
.
checkNotNull
(
preparedState
);
}
private
void
copyLengthFromLoader
(
ExtractingLoadable
loadable
)
{
private
void
copyLengthFromLoader
(
ExtractingLoadable
loadable
)
{
if
(
length
==
C
.
LENGTH_UNSET
)
{
if
(
length
==
C
.
LENGTH_UNSET
)
{
length
=
loadable
.
length
;
length
=
loadable
.
length
;
...
@@ -754,8 +749,8 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
...
@@ -754,8 +749,8 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
ExtractingLoadable
loadable
=
ExtractingLoadable
loadable
=
new
ExtractingLoadable
(
new
ExtractingLoadable
(
uri
,
dataSource
,
extractorHolder
,
/* extractorOutput= */
this
,
loadCondition
);
uri
,
dataSource
,
extractorHolder
,
/* extractorOutput= */
this
,
loadCondition
);
if
(
prepared
)
{
if
(
prepared
State
!=
null
)
{
SeekMap
seekMap
=
getPreparedState
()
.
seekMap
;
SeekMap
seekMap
=
preparedState
.
seekMap
;
Assertions
.
checkState
(
isPendingReset
());
Assertions
.
checkState
(
isPendingReset
());
if
(
durationUs
!=
C
.
TIME_UNSET
&&
pendingResetPositionUs
>
durationUs
)
{
if
(
durationUs
!=
C
.
TIME_UNSET
&&
pendingResetPositionUs
>
durationUs
)
{
loadingFinished
=
true
;
loadingFinished
=
true
;
...
@@ -798,7 +793,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
...
@@ -798,7 +793,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
// request data starting from the point it left off.
// request data starting from the point it left off.
extractedSamplesCountAtStartOfLoad
=
currentExtractedSampleCount
;
extractedSamplesCountAtStartOfLoad
=
currentExtractedSampleCount
;
return
true
;
return
true
;
}
else
if
(
prepared
&&
!
suppressRead
())
{
}
else
if
(
prepared
State
!=
null
&&
!
suppressRead
())
{
// We're playing a stream of unknown length and duration. Assume it's live, and therefore that
// We're playing a stream of unknown length and duration. Assume it's live, and therefore that
// the data at the uri is a continuously shifting window of the latest available media. For
// the data at the uri is a continuously shifting window of the latest available media. For
// this case there's no way to continue loading from where a previous load finished, so it's
// this case there's no way to continue loading from where a previous load finished, so it's
...
@@ -815,7 +810,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
...
@@ -815,7 +810,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
// because there's no buffered data to be read. This case also covers an on-demand stream with
// because there's no buffered data to be read. This case also covers an on-demand stream with
// unknown length that has yet to be prepared. This case cannot be disambiguated from the live
// unknown length that has yet to be prepared. This case cannot be disambiguated from the live
// stream case, so we have no option but to load from the start.
// stream case, so we have no option but to load from the start.
notifyDiscontinuity
=
prepared
;
notifyDiscontinuity
=
prepared
State
!=
null
;
lastSeekPositionUs
=
0
;
lastSeekPositionUs
=
0
;
extractedSamplesCountAtStartOfLoad
=
0
;
extractedSamplesCountAtStartOfLoad
=
0
;
for
(
SampleQueue
sampleQueue
:
sampleQueues
)
{
for
(
SampleQueue
sampleQueue
:
sampleQueues
)
{
...
...
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