mirror of
https://github.com/samsonjs/media.git
synced 2026-04-15 12:55:46 +00:00
Minor tweak to UriDataSource.
This commit is contained in:
parent
b5c4148f8f
commit
c34f7368ae
1 changed files with 9 additions and 12 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue