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
ffc6a0d5
authored
Nov 23, 2020
by
samrobinson
Committed by
kim-vde
Nov 24, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add Format field to AudioSink.ConfigurationException
#exofixit PiperOrigin-RevId: 343857564
parent
aec3e458
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
33 additions
and
16 deletions
library/core/src/main/java/com/google/android/exoplayer2/audio/AudioSink.java
library/core/src/main/java/com/google/android/exoplayer2/audio/DecoderAudioRenderer.java
library/core/src/main/java/com/google/android/exoplayer2/audio/DefaultAudioSink.java
library/core/src/main/java/com/google/android/exoplayer2/audio/MediaCodecAudioRenderer.java
library/core/src/test/java/com/google/android/exoplayer2/audio/DefaultAudioSinkTest.java
library/core/src/test/java/com/google/android/exoplayer2/audio/MediaCodecAudioRendererTest.java
library/core/src/main/java/com/google/android/exoplayer2/audio/AudioSink.java
View file @
ffc6a0d5
...
@@ -144,20 +144,20 @@ public interface AudioSink {
...
@@ -144,20 +144,20 @@ public interface AudioSink {
*/
*/
final
class
ConfigurationException
extends
Exception
{
final
class
ConfigurationException
extends
Exception
{
/**
/** Input {@link Format} of the sink when the configuration failure occurs. */
* Creates a new configuration exception with the specified {@code cause} and no message.
public
final
Format
format
;
*/
public
ConfigurationException
(
Throwable
cause
)
{
/** Creates a new configuration exception with the specified {@code cause} and no message. */
public
ConfigurationException
(
Throwable
cause
,
Format
format
)
{
super
(
cause
);
super
(
cause
);
this
.
format
=
format
;
}
}
/**
/** Creates a new configuration exception with the specified {@code message} and no cause. */
* Creates a new configuration exception with the specified {@code message} and no cause.
public
ConfigurationException
(
String
message
,
Format
format
)
{
*/
public
ConfigurationException
(
String
message
)
{
super
(
message
);
super
(
message
);
this
.
format
=
format
;
}
}
}
}
/** Thrown when a failure occurs initializing the sink. */
/** Thrown when a failure occurs initializing the sink. */
...
...
library/core/src/main/java/com/google/android/exoplayer2/audio/DecoderAudioRenderer.java
View file @
ffc6a0d5
...
@@ -300,8 +300,10 @@ public abstract class DecoderAudioRenderer<
...
@@ -300,8 +300,10 @@ public abstract class DecoderAudioRenderer<
while
(
drainOutputBuffer
())
{}
while
(
drainOutputBuffer
())
{}
while
(
feedInputBuffer
())
{}
while
(
feedInputBuffer
())
{}
TraceUtil
.
endSection
();
TraceUtil
.
endSection
();
}
catch
(
DecoderException
|
AudioSink
.
ConfigurationException
e
)
{
}
catch
(
DecoderException
e
)
{
throw
createRendererException
(
e
,
inputFormat
);
throw
createRendererException
(
e
,
inputFormat
);
}
catch
(
AudioSink
.
ConfigurationException
e
)
{
throw
createRendererException
(
e
,
e
.
format
);
}
catch
(
AudioSink
.
InitializationException
e
)
{
}
catch
(
AudioSink
.
InitializationException
e
)
{
throw
createRendererException
(
e
,
inputFormat
,
e
.
isRecoverable
);
throw
createRendererException
(
e
,
inputFormat
,
e
.
isRecoverable
);
}
catch
(
AudioSink
.
WriteException
e
)
{
}
catch
(
AudioSink
.
WriteException
e
)
{
...
...
library/core/src/main/java/com/google/android/exoplayer2/audio/DefaultAudioSink.java
View file @
ffc6a0d5
...
@@ -535,7 +535,7 @@ public final class DefaultAudioSink implements AudioSink {
...
@@ -535,7 +535,7 @@ public final class DefaultAudioSink implements AudioSink {
outputFormat
=
nextFormat
;
outputFormat
=
nextFormat
;
}
}
}
catch
(
UnhandledAudioFormatException
e
)
{
}
catch
(
UnhandledAudioFormatException
e
)
{
throw
new
ConfigurationException
(
e
);
throw
new
ConfigurationException
(
e
,
inputFormat
);
}
}
}
}
...
@@ -562,7 +562,8 @@ public final class DefaultAudioSink implements AudioSink {
...
@@ -562,7 +562,8 @@ public final class DefaultAudioSink implements AudioSink {
Pair
<
Integer
,
Integer
>
encodingAndChannelConfig
=
Pair
<
Integer
,
Integer
>
encodingAndChannelConfig
=
getEncodingAndChannelConfigForPassthrough
(
inputFormat
,
audioCapabilities
);
getEncodingAndChannelConfigForPassthrough
(
inputFormat
,
audioCapabilities
);
if
(
encodingAndChannelConfig
==
null
)
{
if
(
encodingAndChannelConfig
==
null
)
{
throw
new
ConfigurationException
(
"Unable to configure passthrough for: "
+
inputFormat
);
throw
new
ConfigurationException
(
"Unable to configure passthrough for: "
+
inputFormat
,
inputFormat
);
}
}
outputEncoding
=
encodingAndChannelConfig
.
first
;
outputEncoding
=
encodingAndChannelConfig
.
first
;
outputChannelConfig
=
encodingAndChannelConfig
.
second
;
outputChannelConfig
=
encodingAndChannelConfig
.
second
;
...
@@ -571,11 +572,12 @@ public final class DefaultAudioSink implements AudioSink {
...
@@ -571,11 +572,12 @@ public final class DefaultAudioSink implements AudioSink {
if
(
outputEncoding
==
C
.
ENCODING_INVALID
)
{
if
(
outputEncoding
==
C
.
ENCODING_INVALID
)
{
throw
new
ConfigurationException
(
throw
new
ConfigurationException
(
"Invalid output encoding (mode="
+
outputMode
+
") for: "
+
inputFormat
);
"Invalid output encoding (mode="
+
outputMode
+
") for: "
+
inputFormat
,
inputFormat
);
}
}
if
(
outputChannelConfig
==
AudioFormat
.
CHANNEL_INVALID
)
{
if
(
outputChannelConfig
==
AudioFormat
.
CHANNEL_INVALID
)
{
throw
new
ConfigurationException
(
throw
new
ConfigurationException
(
"Invalid output channel config (mode="
+
outputMode
+
") for: "
+
inputFormat
);
"Invalid output channel config (mode="
+
outputMode
+
") for: "
+
inputFormat
,
inputFormat
);
}
}
offloadDisabledUntilNextConfiguration
=
false
;
offloadDisabledUntilNextConfiguration
=
false
;
...
...
library/core/src/main/java/com/google/android/exoplayer2/audio/MediaCodecAudioRenderer.java
View file @
ffc6a0d5
...
@@ -436,7 +436,7 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
...
@@ -436,7 +436,7 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
try
{
try
{
audioSink
.
configure
(
audioSinkInputFormat
,
/* specifiedBufferSize= */
0
,
channelMap
);
audioSink
.
configure
(
audioSinkInputFormat
,
/* specifiedBufferSize= */
0
,
channelMap
);
}
catch
(
AudioSink
.
ConfigurationException
e
)
{
}
catch
(
AudioSink
.
ConfigurationException
e
)
{
throw
createRendererException
(
e
,
format
);
throw
createRendererException
(
e
,
e
.
format
);
}
}
}
}
...
...
library/core/src/test/java/com/google/android/exoplayer2/audio/DefaultAudioSinkTest.java
View file @
ffc6a0d5
...
@@ -30,6 +30,7 @@ import com.google.android.exoplayer2.util.MimeTypes;
...
@@ -30,6 +30,7 @@ import com.google.android.exoplayer2.util.MimeTypes;
import
java.nio.ByteBuffer
;
import
java.nio.ByteBuffer
;
import
java.nio.ByteOrder
;
import
java.nio.ByteOrder
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
...
@@ -307,6 +308,18 @@ public final class DefaultAudioSinkTest {
...
@@ -307,6 +308,18 @@ public final class DefaultAudioSinkTest {
.
isEqualTo
(
CURRENT_POSITION_NOT_SET
);
.
isEqualTo
(
CURRENT_POSITION_NOT_SET
);
}
}
@Test
public
void
configure_throwsConfigurationException_withInvalidInput
()
{
Format
format
=
new
Format
.
Builder
().
setSampleMimeType
(
MimeTypes
.
AUDIO_AAC
).
build
();
AudioSink
.
ConfigurationException
thrown
=
Assert
.
assertThrows
(
AudioSink
.
ConfigurationException
.
class
,
()
->
defaultAudioSink
.
configure
(
format
,
/* specifiedBufferSize= */
0
,
/* outputChannels= */
null
));
assertThat
(
thrown
.
format
).
isEqualTo
(
format
);
}
private
void
configureDefaultAudioSink
(
int
channelCount
)
throws
AudioSink
.
ConfigurationException
{
private
void
configureDefaultAudioSink
(
int
channelCount
)
throws
AudioSink
.
ConfigurationException
{
configureDefaultAudioSink
(
channelCount
,
/* trimStartFrames= */
0
,
/* trimEndFrames= */
0
);
configureDefaultAudioSink
(
channelCount
,
/* trimStartFrames= */
0
,
/* trimEndFrames= */
0
);
}
}
...
...
library/core/src/test/java/com/google/android/exoplayer2/audio/MediaCodecAudioRendererTest.java
View file @
ffc6a0d5
...
@@ -236,7 +236,7 @@ public class MediaCodecAudioRendererTest {
...
@@ -236,7 +236,7 @@ public class MediaCodecAudioRendererTest {
if
(!
format
.
equals
(
AUDIO_AAC
))
{
if
(!
format
.
equals
(
AUDIO_AAC
))
{
setPendingPlaybackException
(
setPendingPlaybackException
(
ExoPlaybackException
.
createForRenderer
(
ExoPlaybackException
.
createForRenderer
(
new
AudioSink
.
ConfigurationException
(
"Test"
),
new
AudioSink
.
ConfigurationException
(
"Test"
,
format
),
"rendererName"
,
"rendererName"
,
/* rendererIndex= */
0
,
/* rendererIndex= */
0
,
format
,
format
,
...
...
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