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
71f542f7
authored
Sep 28, 2015
by
Oliver Woodman
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
If a parser really wants to throw a runtime exception, don't crash.
parent
ee80be92
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
2 deletions
library/src/main/java/com/google/android/exoplayer/text/SubtitleParserHelper.java
library/src/main/java/com/google/android/exoplayer/text/SubtitleParserHelper.java
View file @
71f542f7
...
...
@@ -45,6 +45,7 @@ import java.io.InputStream;
private
boolean
parsing
;
private
PlayableSubtitle
result
;
private
IOException
error
;
private
RuntimeException
runtimeError
;
private
boolean
subtitlesAreRelative
;
private
long
subtitleOffsetUs
;
...
...
@@ -67,6 +68,7 @@ import java.io.InputStream;
parsing
=
false
;
result
=
null
;
error
=
null
;
runtimeError
=
null
;
}
/**
...
...
@@ -111,6 +113,7 @@ import java.io.InputStream;
parsing
=
true
;
result
=
null
;
error
=
null
;
runtimeError
=
null
;
handler
.
obtainMessage
(
MSG_SAMPLE
,
Util
.
getTopInt
(
sampleHolder
.
timeUs
),
Util
.
getBottomInt
(
sampleHolder
.
timeUs
),
sampleHolder
).
sendToTarget
();
}
...
...
@@ -128,11 +131,15 @@ import java.io.InputStream;
try
{
if
(
error
!=
null
)
{
throw
error
;
}
else
if
(
runtimeError
!=
null
)
{
throw
runtimeError
;
}
else
{
return
result
;
}
return
result
;
}
finally
{
error
=
null
;
result
=
null
;
error
=
null
;
runtimeError
=
null
;
}
}
...
...
@@ -159,11 +166,14 @@ import java.io.InputStream;
private
void
handleSample
(
long
sampleTimeUs
,
SampleHolder
holder
)
{
Subtitle
parsedSubtitle
=
null
;
IOException
error
=
null
;
RuntimeException
runtimeError
=
null
;
try
{
InputStream
inputStream
=
new
ByteArrayInputStream
(
holder
.
data
.
array
(),
0
,
holder
.
size
);
parsedSubtitle
=
parser
.
parse
(
inputStream
);
}
catch
(
IOException
e
)
{
error
=
e
;
}
catch
(
RuntimeException
e
)
{
runtimeError
=
e
;
}
synchronized
(
this
)
{
if
(
sampleHolder
!=
holder
)
{
...
...
@@ -172,6 +182,7 @@ import java.io.InputStream;
this
.
result
=
new
PlayableSubtitle
(
parsedSubtitle
,
subtitlesAreRelative
,
sampleTimeUs
,
subtitleOffsetUs
);
this
.
error
=
error
;
this
.
runtimeError
=
runtimeError
;
this
.
parsing
=
false
;
}
}
...
...
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