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
c0ee267a
authored
Aug 04, 2020
by
olly
Committed by
kim-vde
Aug 07, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Fix E-AC3 format propagation
Issue: Issue: #7611 PiperOrigin-RevId: 324884412
parent
8da7fc7d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
22 deletions
library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java
library/core/src/main/java/com/google/android/exoplayer2/util/TimedValueQueue.java
library/core/src/test/java/com/google/android/exoplayer2/util/TimedValueQueueTest.java
library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java
View file @
c0ee267a
...
@@ -631,6 +631,13 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
...
@@ -631,6 +631,13 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
throws
ExoPlaybackException
{
throws
ExoPlaybackException
{
boolean
outputFormatChanged
=
false
;
boolean
outputFormatChanged
=
false
;
@Nullable
Format
format
=
formatQueue
.
pollFloor
(
presentationTimeUs
);
@Nullable
Format
format
=
formatQueue
.
pollFloor
(
presentationTimeUs
);
if
(
format
==
null
&&
codecOutputMediaFormatChanged
)
{
// If the codec's output MediaFormat has changed then there should be a corresponding Format
// change, which we've not found. Check the Format queue in case the corresponding
// presentation timestamp is greater than presentationTimeUs, which can happen for some codecs
// [Internal ref: b/162719047].
format
=
formatQueue
.
pollFirst
();
}
if
(
format
!=
null
)
{
if
(
format
!=
null
)
{
outputFormat
=
format
;
outputFormat
=
format
;
outputFormatChanged
=
true
;
outputFormatChanged
=
true
;
...
...
library/core/src/main/java/com/google/android/exoplayer2/util/TimedValueQueue.java
View file @
c0ee267a
...
@@ -62,6 +62,12 @@ public final class TimedValueQueue<V> {
...
@@ -62,6 +62,12 @@ public final class TimedValueQueue<V> {
return
size
;
return
size
;
}
}
/** Removes and returns the first value in the queue, or null if the queue is empty. */
@Nullable
public
synchronized
V
pollFirst
()
{
return
size
==
0
?
null
:
popFirst
();
}
/**
/**
* Returns the value with the greatest timestamp which is less than or equal to the given
* Returns the value with the greatest timestamp which is less than or equal to the given
* timestamp. Removes all older values and the returned one from the buffer.
* timestamp. Removes all older values and the returned one from the buffer.
...
@@ -71,7 +77,8 @@ public final class TimedValueQueue<V> {
...
@@ -71,7 +77,8 @@ public final class TimedValueQueue<V> {
* timestamp or null if there is no such value.
* timestamp or null if there is no such value.
* @see #poll(long)
* @see #poll(long)
*/
*/
public
synchronized
@Nullable
V
pollFloor
(
long
timestamp
)
{
@Nullable
public
synchronized
V
pollFloor
(
long
timestamp
)
{
return
poll
(
timestamp
,
/* onlyOlder= */
true
);
return
poll
(
timestamp
,
/* onlyOlder= */
true
);
}
}
...
@@ -83,7 +90,8 @@ public final class TimedValueQueue<V> {
...
@@ -83,7 +90,8 @@ public final class TimedValueQueue<V> {
* @return The value with the closest timestamp or null if the buffer is empty.
* @return The value with the closest timestamp or null if the buffer is empty.
* @see #pollFloor(long)
* @see #pollFloor(long)
*/
*/
public
synchronized
@Nullable
V
poll
(
long
timestamp
)
{
@Nullable
public
synchronized
V
poll
(
long
timestamp
)
{
return
poll
(
timestamp
,
/* onlyOlder= */
false
);
return
poll
(
timestamp
,
/* onlyOlder= */
false
);
}
}
...
@@ -99,7 +107,7 @@ public final class TimedValueQueue<V> {
...
@@ -99,7 +107,7 @@ public final class TimedValueQueue<V> {
*/
*/
@Nullable
@Nullable
private
V
poll
(
long
timestamp
,
boolean
onlyOlder
)
{
private
V
poll
(
long
timestamp
,
boolean
onlyOlder
)
{
V
value
=
null
;
@Nullable
V
value
=
null
;
long
previousTimeDiff
=
Long
.
MAX_VALUE
;
long
previousTimeDiff
=
Long
.
MAX_VALUE
;
while
(
size
>
0
)
{
while
(
size
>
0
)
{
long
timeDiff
=
timestamp
-
timestamps
[
first
];
long
timeDiff
=
timestamp
-
timestamps
[
first
];
...
@@ -107,14 +115,21 @@ public final class TimedValueQueue<V> {
...
@@ -107,14 +115,21 @@ public final class TimedValueQueue<V> {
break
;
break
;
}
}
previousTimeDiff
=
timeDiff
;
previousTimeDiff
=
timeDiff
;
value
=
values
[
first
];
value
=
popFirst
();
values
[
first
]
=
null
;
first
=
(
first
+
1
)
%
values
.
length
;
size
--;
}
}
return
value
;
return
value
;
}
}
@Nullable
private
V
popFirst
()
{
Assertions
.
checkState
(
size
>
0
);
@Nullable
V
value
=
values
[
first
];
values
[
first
]
=
null
;
first
=
(
first
+
1
)
%
values
.
length
;
size
--;
return
value
;
}
private
void
clearBufferOnTimeDiscontinuity
(
long
timestamp
)
{
private
void
clearBufferOnTimeDiscontinuity
(
long
timestamp
)
{
if
(
size
>
0
)
{
if
(
size
>
0
)
{
int
last
=
(
first
+
size
-
1
)
%
values
.
length
;
int
last
=
(
first
+
size
-
1
)
%
values
.
length
;
...
@@ -131,7 +146,7 @@ public final class TimedValueQueue<V> {
...
@@ -131,7 +146,7 @@ public final class TimedValueQueue<V> {
}
}
int
newCapacity
=
capacity
*
2
;
int
newCapacity
=
capacity
*
2
;
long
[]
newTimestamps
=
new
long
[
newCapacity
];
long
[]
newTimestamps
=
new
long
[
newCapacity
];
V
[]
newValues
=
newArray
(
newCapacity
);
@NullableType
V
[]
newValues
=
newArray
(
newCapacity
);
// Reset the loop starting index to 0 while coping to the new buffer.
// Reset the loop starting index to 0 while coping to the new buffer.
// First copy the values from 'first' index to the end of original array.
// First copy the values from 'first' index to the end of original array.
int
length
=
capacity
-
first
;
int
length
=
capacity
-
first
;
...
@@ -155,7 +170,7 @@ public final class TimedValueQueue<V> {
...
@@ -155,7 +170,7 @@ public final class TimedValueQueue<V> {
}
}
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
private
static
<
V
>
V
[]
newArray
(
int
length
)
{
private
static
<
V
>
@NullableType
V
[]
newArray
(
int
length
)
{
return
(
V
[])
new
Object
[
length
];
return
(
V
[])
new
Object
[
length
];
}
}
}
}
library/core/src/test/java/com/google/android/exoplayer2/util/TimedValueQueueTest.java
View file @
c0ee267a
...
@@ -34,22 +34,12 @@ public class TimedValueQueueTest {
...
@@ -34,22 +34,12 @@ public class TimedValueQueueTest {
}
}
@Test
@Test
public
void
addAndPollValues
()
{
queue
.
add
(
0
,
"a"
);
queue
.
add
(
1
,
"b"
);
queue
.
add
(
2
,
"c"
);
assertThat
(
queue
.
poll
(
0
)).
isEqualTo
(
"a"
);
assertThat
(
queue
.
poll
(
1
)).
isEqualTo
(
"b"
);
assertThat
(
queue
.
poll
(
2
)).
isEqualTo
(
"c"
);
}
@Test
public
void
bufferCapacityIncreasesAutomatically
()
{
public
void
bufferCapacityIncreasesAutomatically
()
{
queue
=
new
TimedValueQueue
<>(
1
);
queue
=
new
TimedValueQueue
<>(
1
);
for
(
int
i
=
0
;
i
<
20
;
i
++)
{
for
(
int
i
=
0
;
i
<
20
;
i
++)
{
queue
.
add
(
i
,
""
+
i
);
queue
.
add
(
i
,
""
+
i
);
if
((
i
&
1
)
==
1
)
{
if
((
i
&
1
)
==
1
)
{
assertThat
(
queue
.
poll
(
0
)).
isEqualTo
(
""
+
(
i
/
2
));
assertThat
(
queue
.
poll
First
(
)).
isEqualTo
(
""
+
(
i
/
2
));
}
}
}
}
assertThat
(
queue
.
size
()).
isEqualTo
(
10
);
assertThat
(
queue
.
size
()).
isEqualTo
(
10
);
...
@@ -61,7 +51,7 @@ public class TimedValueQueueTest {
...
@@ -61,7 +51,7 @@ public class TimedValueQueueTest {
queue
.
add
(
2
,
"c"
);
queue
.
add
(
2
,
"c"
);
queue
.
add
(
0
,
"a"
);
queue
.
add
(
0
,
"a"
);
assertThat
(
queue
.
size
()).
isEqualTo
(
1
);
assertThat
(
queue
.
size
()).
isEqualTo
(
1
);
assertThat
(
queue
.
poll
(
0
)).
isEqualTo
(
"a"
);
assertThat
(
queue
.
poll
First
(
)).
isEqualTo
(
"a"
);
}
}
@Test
@Test
...
@@ -71,7 +61,37 @@ public class TimedValueQueueTest {
...
@@ -71,7 +61,37 @@ public class TimedValueQueueTest {
queue
.
add
(
3
,
"c"
);
queue
.
add
(
3
,
"c"
);
queue
.
add
(
2
,
"a"
);
queue
.
add
(
2
,
"a"
);
assertThat
(
queue
.
size
()).
isEqualTo
(
1
);
assertThat
(
queue
.
size
()).
isEqualTo
(
1
);
assertThat
(
queue
.
poll
(
2
)).
isEqualTo
(
"a"
);
assertThat
(
queue
.
pollFirst
()).
isEqualTo
(
"a"
);
}
@Test
public
void
pollFirstReturnsValues
()
{
queue
.
add
(
0
,
"a"
);
queue
.
add
(
1
,
"b"
);
queue
.
add
(
2
,
"c"
);
assertThat
(
queue
.
pollFirst
()).
isEqualTo
(
"a"
);
assertThat
(
queue
.
size
()).
isEqualTo
(
2
);
assertThat
(
queue
.
pollFirst
()).
isEqualTo
(
"b"
);
assertThat
(
queue
.
size
()).
isEqualTo
(
1
);
assertThat
(
queue
.
pollFirst
()).
isEqualTo
(
"c"
);
assertThat
(
queue
.
size
()).
isEqualTo
(
0
);
assertThat
(
queue
.
pollFirst
()).
isEqualTo
(
null
);
assertThat
(
queue
.
size
()).
isEqualTo
(
0
);
}
@Test
public
void
pollReturnsValues
()
{
queue
.
add
(
0
,
"a"
);
queue
.
add
(
1
,
"b"
);
queue
.
add
(
2
,
"c"
);
assertThat
(
queue
.
poll
(
0
)).
isEqualTo
(
"a"
);
assertThat
(
queue
.
size
()).
isEqualTo
(
2
);
assertThat
(
queue
.
poll
(
1
)).
isEqualTo
(
"b"
);
assertThat
(
queue
.
size
()).
isEqualTo
(
1
);
assertThat
(
queue
.
poll
(
2
)).
isEqualTo
(
"c"
);
assertThat
(
queue
.
size
()).
isEqualTo
(
0
);
assertThat
(
queue
.
pollFirst
()).
isEqualTo
(
null
);
assertThat
(
queue
.
size
()).
isEqualTo
(
0
);
}
}
@Test
@Test
...
...
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