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
ca287ba5
authored
Dec 23, 2020
by
olly
Committed by
Ian Baker
Jan 11, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Fix bypass mode when the stream is empty
Issue: #8374 PiperOrigin-RevId: 348792965
parent
858fa26e
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
23 deletions
RELEASENOTES.md
library/core/src/main/java/com/google/android/exoplayer2/mediacodec/BatchBuffer.java
library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java
RELEASENOTES.md
View file @
ca287ba5
...
@@ -5,6 +5,8 @@
...
@@ -5,6 +5,8 @@
*
Core library:
*
Core library:
*
Fix playback issues after seeking during an ad
*
Fix playback issues after seeking during an ad
(
[
#8349
](
https://github.com/google/ExoPlayer/issues/8349
)
).
(
[
#8349
](
https://github.com/google/ExoPlayer/issues/8349
)
).
*
Fix
`MediaCodecRenderer`
issue where empty streams would fail to play in
bypass mode (
[
#8374
](
https://github.com/google/ExoPlayer/issues/8374
)
).
*
UI:
*
UI:
*
Fix issue where pop-up menus belonging to
`StyledPlayerControlView`
*
Fix issue where pop-up menus belonging to
`StyledPlayerControlView`
would not be dismissed when tapping outside of the menu area or pressing
would not be dismissed when tapping outside of the menu area or pressing
...
...
library/core/src/main/java/com/google/android/exoplayer2/mediacodec/BatchBuffer.java
View file @
ca287ba5
...
@@ -153,27 +153,27 @@ import java.nio.ByteBuffer;
...
@@ -153,27 +153,27 @@ import java.nio.ByteBuffer;
}
}
private
void
putAccessUnit
(
DecoderInputBuffer
accessUnit
)
{
private
void
putAccessUnit
(
DecoderInputBuffer
accessUnit
)
{
@Nullable
ByteBuffer
accessUnitData
=
accessUnit
.
data
;
if
(
accessUnitData
!=
null
)
{
accessUnit
.
flip
();
ensureSpaceForWrite
(
accessUnitData
.
remaining
());
this
.
data
.
put
(
accessUnitData
);
}
if
(
accessUnit
.
isEndOfStream
())
{
if
(
accessUnit
.
isEndOfStream
())
{
setFlags
(
C
.
BUFFER_FLAG_END_OF_STREAM
);
setFlags
(
C
.
BUFFER_FLAG_END_OF_STREAM
);
}
}
else
{
timeUs
=
accessUnit
.
timeUs
;
if
(
accessUnit
.
isDecodeOnly
())
{
if
(
accessUnit
.
isDecodeOnly
())
{
setFlags
(
C
.
BUFFER_FLAG_DECODE_ONLY
);
setFlags
(
C
.
BUFFER_FLAG_DECODE_ONLY
);
}
}
if
(
accessUnit
.
isKeyFrame
())
{
if
(
accessUnit
.
isKeyFrame
())
{
setFlags
(
C
.
BUFFER_FLAG_KEY_FRAME
);
setFlags
(
C
.
BUFFER_FLAG_KEY_FRAME
);
}
}
@Nullable
ByteBuffer
accessUnitData
=
accessUnit
.
data
;
if
(
accessUnitData
!=
null
)
{
accessUnit
.
flip
();
ensureSpaceForWrite
(
accessUnitData
.
remaining
());
this
.
data
.
put
(
accessUnitData
);
}
accessUnitCount
++;
accessUnitCount
++;
timeUs
=
accessUnit
.
timeUs
;
if
(
accessUnitCount
==
1
)
{
if
(
accessUnitCount
==
1
)
{
// First read of the buffer
firstAccessUnitTimeUs
=
timeUs
;
firstAccessUnitTimeUs
=
timeUs
;
}
}
}
accessUnit
.
clear
();
accessUnit
.
clear
();
}
}
...
...
library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java
View file @
ca287ba5
...
@@ -450,6 +450,11 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
...
@@ -450,6 +450,11 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
outputStreamStartPositionUs
=
C
.
TIME_UNSET
;
outputStreamStartPositionUs
=
C
.
TIME_UNSET
;
outputStreamOffsetUs
=
C
.
TIME_UNSET
;
outputStreamOffsetUs
=
C
.
TIME_UNSET
;
bypassBatchBuffer
=
new
BatchBuffer
();
bypassBatchBuffer
=
new
BatchBuffer
();
bypassBatchBuffer
.
ensureSpaceForWrite
(
/* length= */
0
);
// MediaCodec outputs audio buffers in native endian:
// https://developer.android.com/reference/android/media/MediaCodec#raw-audio-buffers
// and code called from MediaCodecAudioRenderer.processOutputBuffer expects this endianness.
bypassBatchBuffer
.
data
.
order
(
ByteOrder
.
nativeOrder
());
resetCodecStateForRelease
();
resetCodecStateForRelease
();
}
}
...
@@ -2134,7 +2139,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
...
@@ -2134,7 +2139,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
* iteration of the rendering loop.
* iteration of the rendering loop.
* @param elapsedRealtimeUs {@link SystemClock#elapsedRealtime()} in microseconds, measured at the
* @param elapsedRealtimeUs {@link SystemClock#elapsedRealtime()} in microseconds, measured at the
* start of the current iteration of the rendering loop.
* start of the current iteration of the rendering loop.
* @return
If more buffers are ready to be rendered
.
* @return
Whether immediately calling this method again will make more progress
.
* @throws ExoPlaybackException If an error occurred while processing a buffer or handling a
* @throws ExoPlaybackException If an error occurred while processing a buffer or handling a
* format change.
* format change.
*/
*/
...
@@ -2142,7 +2147,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
...
@@ -2142,7 +2147,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
throws
ExoPlaybackException
{
throws
ExoPlaybackException
{
BatchBuffer
batchBuffer
=
bypassBatchBuffer
;
BatchBuffer
batchBuffer
=
bypassBatchBuffer
;
//
Let's process the pending buffer if any
.
//
Process any data in the batch buffer
.
checkState
(!
outputStreamEnded
);
checkState
(!
outputStreamEnded
);
if
(!
batchBuffer
.
isEmpty
())
{
// Optimisation: Do not process buffer if empty.
if
(!
batchBuffer
.
isEmpty
())
{
// Optimisation: Do not process buffer if empty.
if
(
processOutputBuffer
(
if
(
processOutputBuffer
(
...
@@ -2157,12 +2162,13 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
...
@@ -2157,12 +2162,13 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
batchBuffer
.
isDecodeOnly
(),
batchBuffer
.
isDecodeOnly
(),
batchBuffer
.
isEndOfStream
(),
batchBuffer
.
isEndOfStream
(),
outputFormat
))
{
outputFormat
))
{
// Buffer completely processed
onProcessedOutputBuffer
(
batchBuffer
.
getLastAccessUnitTimeUs
());
onProcessedOutputBuffer
(
batchBuffer
.
getLastAccessUnitTimeUs
());
}
else
{
}
else
{
return
false
;
// Could not process buffer, let's try later.
// Could not process the whole buffer. Try again later.
return
false
;
}
}
}
}
// Process the end of stream, if it has been reached.
if
(
batchBuffer
.
isEndOfStream
())
{
if
(
batchBuffer
.
isEndOfStream
())
{
outputStreamEnded
=
true
;
outputStreamEnded
=
true
;
return
false
;
return
false
;
...
@@ -2197,19 +2203,17 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
...
@@ -2197,19 +2203,17 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
onInputFormatChanged
(
formatHolder
);
onInputFormatChanged
(
formatHolder
);
}
}
boolean
haveDataToProcess
=
false
;
if
(
batchBuffer
.
isEndOfStream
())
{
if
(
batchBuffer
.
isEndOfStream
())
{
inputStreamEnded
=
true
;
inputStreamEnded
=
true
;
haveDataToProcess
=
true
;
}
}
if
(!
batchBuffer
.
isEmpty
())
{
if
(
batchBuffer
.
isEmpty
())
{
batchBuffer
.
flip
();
return
false
;
// The buffer could not be filled, there is nothing more to do.
haveDataToProcess
=
true
;
}
}
batchBuffer
.
flip
();
// Buffer at least partially full, it can now be processed.
// MediaCodec outputs buffers in native endian:
return
haveDataToProcess
;
// https://developer.android.com/reference/android/media/MediaCodec#raw-audio-buffers
// and code called from processOutputBuffer expects this endianness.
batchBuffer
.
data
.
order
(
ByteOrder
.
nativeOrder
());
return
true
;
}
}
/**
/**
...
...
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