Skip to content
This repository has been archived by the owner on Feb 9, 2018. It is now read-only.

Commit

Permalink
fix NPE in renderer requests for external subtitles
Browse files Browse the repository at this point in the history
  • Loading branch information
chocolateboy committed Nov 22, 2012
1 parent ece4d6d commit 42359a9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/main/java/net/pms/network/Request.java
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,11 @@ public void answer(OutputStream output, StartStopListenerDelegate startStopListe
if (subs != null && !subs.isEmpty()) {
// TODO: maybe loop subs to get the requested subtitle type instead of using the first one
DLNAMediaSubtitle sub = subs.get(0);
inputStream = new java.io.FileInputStream(sub.getExternalFile());
// XXX external file is null if the first subtitle track is embedded:
// http://www.ps3mediaserver.org/forum/viewtopic.php?f=3&t=15805&p=75534#p75534
if (sub.isExternal()) {
inputStream = new java.io.FileInputStream(sub.getExternalFile());
}
}
} else {
// This is a request for a regular file.
Expand Down Expand Up @@ -715,7 +719,7 @@ public void answer(OutputStream output, StartStopListenerDelegate startStopListe

LOGGER.trace("Sending stream: " + sendB + " bytes of " + argument);
PMS.get().getFrame().setStatusLine(null);
} else {
} else { // inputStream is null
if (lowRange > 0 && highRange > 0) {
output(output, "Content-Length: " + (highRange - lowRange + 1));
} else {
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/net/pms/network/RequestV2.java
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,11 @@ public ChannelFuture answer(
if (subs != null && !subs.isEmpty()) {
// TODO: maybe loop subs to get the requested subtitle type instead of using the first one
DLNAMediaSubtitle sub = subs.get(0);
inputStream = new java.io.FileInputStream(sub.getExternalFile());
// XXX external file is null if the first subtitle track is embedded:
// http://www.ps3mediaserver.org/forum/viewtopic.php?f=3&t=15805&p=75534#p75534
if (sub.isExternal()) {
inputStream = new java.io.FileInputStream(sub.getExternalFile());
}
}
} else {
// This is a request for a regular file.
Expand Down

0 comments on commit 42359a9

Please sign in to comment.