mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +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
|
@Override
|
||||||
public long open(DataSpec dataSpec) throws IOException {
|
public long open(DataSpec dataSpec) throws IOException {
|
||||||
Assertions.checkState(dataSource == null);
|
Assertions.checkState(dataSource == null);
|
||||||
|
dataSource = FILE_URI_SCHEME.equals(dataSpec.uri.getScheme()) ? fileDataSource : httpDataSource;
|
||||||
dataSource = dataSpec.uri.getScheme().equals(FILE_URI_SCHEME) ? fileDataSource : httpDataSource;
|
|
||||||
return dataSource.open(dataSpec);
|
return dataSource.open(dataSpec);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void close() throws IOException {
|
|
||||||
Assertions.checkNotNull(dataSource);
|
|
||||||
|
|
||||||
dataSource.close();
|
|
||||||
dataSource = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int read(byte[] buffer, int offset, int readLength) throws IOException {
|
public int read(byte[] buffer, int offset, int readLength) throws IOException {
|
||||||
Assertions.checkNotNull(dataSource);
|
|
||||||
|
|
||||||
return dataSource.read(buffer, offset, readLength);
|
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