From c34f7368aeb28d21a9255e995f8b0e346dc61527 Mon Sep 17 00:00:00 2001 From: Oliver Woodman Date: Tue, 28 Oct 2014 14:12:55 +0000 Subject: [PATCH] Minor tweak to UriDataSource. --- .../exoplayer/upstream/UriDataSource.java | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/library/src/main/java/com/google/android/exoplayer/upstream/UriDataSource.java b/library/src/main/java/com/google/android/exoplayer/upstream/UriDataSource.java index 1243576b17..0655381191 100644 --- a/library/src/main/java/com/google/android/exoplayer/upstream/UriDataSource.java +++ b/library/src/main/java/com/google/android/exoplayer/upstream/UriDataSource.java @@ -62,24 +62,21 @@ public final class UriDataSource implements DataSource { @Override public long open(DataSpec dataSpec) throws IOException { Assertions.checkState(dataSource == null); - - dataSource = dataSpec.uri.getScheme().equals(FILE_URI_SCHEME) ? fileDataSource : httpDataSource; + dataSource = FILE_URI_SCHEME.equals(dataSpec.uri.getScheme()) ? fileDataSource : httpDataSource; return dataSource.open(dataSpec); } - @Override - public void close() throws IOException { - Assertions.checkNotNull(dataSource); - - dataSource.close(); - dataSource = null; - } - @Override public int read(byte[] buffer, int offset, int readLength) throws IOException { - Assertions.checkNotNull(dataSource); - return dataSource.read(buffer, offset, readLength); } + @Override + public void close() throws IOException { + if (dataSource != null) { + dataSource.close(); + dataSource = null; + } + } + }