mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Remove unnecessary FileDescriptor sync
PiperOrigin-RevId: 255380796
This commit is contained in:
parent
d57a8587d2
commit
cdf70edf6e
2 changed files with 1 additions and 31 deletions
|
|
@ -49,7 +49,6 @@ public final class CacheDataSink implements DataSink {
|
||||||
private final long fragmentSize;
|
private final long fragmentSize;
|
||||||
private final int bufferSize;
|
private final int bufferSize;
|
||||||
|
|
||||||
private boolean syncFileDescriptor;
|
|
||||||
private DataSpec dataSpec;
|
private DataSpec dataSpec;
|
||||||
private long dataSpecFragmentSize;
|
private long dataSpecFragmentSize;
|
||||||
private File file;
|
private File file;
|
||||||
|
|
@ -108,18 +107,6 @@ public final class CacheDataSink implements DataSink {
|
||||||
this.cache = Assertions.checkNotNull(cache);
|
this.cache = Assertions.checkNotNull(cache);
|
||||||
this.fragmentSize = fragmentSize == C.LENGTH_UNSET ? Long.MAX_VALUE : fragmentSize;
|
this.fragmentSize = fragmentSize == C.LENGTH_UNSET ? Long.MAX_VALUE : fragmentSize;
|
||||||
this.bufferSize = bufferSize;
|
this.bufferSize = bufferSize;
|
||||||
syncFileDescriptor = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets whether file descriptors are synced when closing output streams.
|
|
||||||
*
|
|
||||||
* <p>This method is experimental, and will be renamed or removed in a future release.
|
|
||||||
*
|
|
||||||
* @param syncFileDescriptor Whether file descriptors are synced when closing output streams.
|
|
||||||
*/
|
|
||||||
public void experimental_setSyncFileDescriptor(boolean syncFileDescriptor) {
|
|
||||||
this.syncFileDescriptor = syncFileDescriptor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -208,9 +195,6 @@ public final class CacheDataSink implements DataSink {
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
try {
|
try {
|
||||||
outputStream.flush();
|
outputStream.flush();
|
||||||
if (syncFileDescriptor) {
|
|
||||||
underlyingFileOutputStream.getFD().sync();
|
|
||||||
}
|
|
||||||
success = true;
|
success = true;
|
||||||
} finally {
|
} finally {
|
||||||
Util.closeQuietly(outputStream);
|
Util.closeQuietly(outputStream);
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,6 @@ public final class CacheDataSinkFactory implements DataSink.Factory {
|
||||||
private final long fragmentSize;
|
private final long fragmentSize;
|
||||||
private final int bufferSize;
|
private final int bufferSize;
|
||||||
|
|
||||||
private boolean syncFileDescriptor;
|
|
||||||
|
|
||||||
/** @see CacheDataSink#CacheDataSink(Cache, long) */
|
/** @see CacheDataSink#CacheDataSink(Cache, long) */
|
||||||
public CacheDataSinkFactory(Cache cache, long fragmentSize) {
|
public CacheDataSinkFactory(Cache cache, long fragmentSize) {
|
||||||
this(cache, fragmentSize, CacheDataSink.DEFAULT_BUFFER_SIZE);
|
this(cache, fragmentSize, CacheDataSink.DEFAULT_BUFFER_SIZE);
|
||||||
|
|
@ -40,20 +38,8 @@ public final class CacheDataSinkFactory implements DataSink.Factory {
|
||||||
this.bufferSize = bufferSize;
|
this.bufferSize = bufferSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* See {@link CacheDataSink#experimental_setSyncFileDescriptor(boolean)}.
|
|
||||||
*
|
|
||||||
* <p>This method is experimental, and will be renamed or removed in a future release.
|
|
||||||
*/
|
|
||||||
public CacheDataSinkFactory experimental_setSyncFileDescriptor(boolean syncFileDescriptor) {
|
|
||||||
this.syncFileDescriptor = syncFileDescriptor;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataSink createDataSink() {
|
public DataSink createDataSink() {
|
||||||
CacheDataSink dataSink = new CacheDataSink(cache, fragmentSize, bufferSize);
|
return new CacheDataSink(cache, fragmentSize, bufferSize);
|
||||||
dataSink.experimental_setSyncFileDescriptor(syncFileDescriptor);
|
|
||||||
return dataSink;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue