mirror of
https://github.com/androidx/media.git
synced 2025-05-18 04:59:54 +08:00
Enable buffering for CacheDataSink by default
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=146221487
This commit is contained in:
parent
74acbe04e3
commit
025a67cae9
@ -32,6 +32,9 @@ import java.io.OutputStream;
|
||||
*/
|
||||
public final class CacheDataSink implements DataSink {
|
||||
|
||||
/** Default buffer size. */
|
||||
public static final int DEFAULT_BUFFER_SIZE = 20480;
|
||||
|
||||
private final Cache cache;
|
||||
private final long maxCacheFileSize;
|
||||
private final int bufferSize;
|
||||
@ -56,13 +59,15 @@ public final class CacheDataSink implements DataSink {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a CacheDataSink using the {@link #DEFAULT_BUFFER_SIZE}.
|
||||
*
|
||||
* @param cache The cache into which data should be written.
|
||||
* @param maxCacheFileSize The maximum size of a cache file, in bytes. If the sink is opened for
|
||||
* a {@link DataSpec} whose size exceeds this value, then the data will be fragmented into
|
||||
* multiple cache files.
|
||||
*/
|
||||
public CacheDataSink(Cache cache, long maxCacheFileSize) {
|
||||
this(cache, maxCacheFileSize, 0);
|
||||
this(cache, maxCacheFileSize, DEFAULT_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -24,18 +24,27 @@ public final class CacheDataSinkFactory implements DataSink.Factory {
|
||||
|
||||
private final Cache cache;
|
||||
private final long maxCacheFileSize;
|
||||
private final int bufferSize;
|
||||
|
||||
/**
|
||||
* @see CacheDataSink#CacheDataSink(Cache, long)
|
||||
*/
|
||||
public CacheDataSinkFactory(Cache cache, long maxCacheFileSize) {
|
||||
this(cache, maxCacheFileSize, CacheDataSink.DEFAULT_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see CacheDataSink#CacheDataSink(Cache, long, int)
|
||||
*/
|
||||
public CacheDataSinkFactory(Cache cache, long maxCacheFileSize, int bufferSize) {
|
||||
this.cache = cache;
|
||||
this.maxCacheFileSize = maxCacheFileSize;
|
||||
this.bufferSize = bufferSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSink createDataSink() {
|
||||
return new CacheDataSink(cache, maxCacheFileSize);
|
||||
return new CacheDataSink(cache, maxCacheFileSize, bufferSize);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user