Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
3a54d744
authored
Jan 23, 2019
by
olly
Committed by
Oliver Woodman
Jan 29, 2019
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Default to respecting the DataSpec cache fragmentation flag
Issue: #4253 PiperOrigin-RevId: 230497544
parent
52f25f6e
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
2 additions
and
35 deletions
library/core/src/main/java/com/google/android/exoplayer2/offline/DownloaderConstructorHelper.java
library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheDataSink.java
library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheDataSinkFactory.java
library/core/src/main/java/com/google/android/exoplayer2/offline/DownloaderConstructorHelper.java
View file @
3a54d744
...
...
@@ -110,10 +110,8 @@ public final class DownloaderConstructorHelper {
?
cacheReadDataSourceFactory
:
new
FileDataSourceFactory
();
if
(
cacheWriteDataSinkFactory
==
null
)
{
CacheDataSinkFactory
f
actory
=
cacheWriteDataSinkF
actory
=
new
CacheDataSinkFactory
(
cache
,
CacheDataSink
.
DEFAULT_FRAGMENT_SIZE
);
factory
.
experimental_setRespectCacheFragmentationFlag
(
true
);
cacheWriteDataSinkFactory
=
factory
;
}
onlineCacheDataSourceFactory
=
new
CacheDataSourceFactory
(
...
...
library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheDataSink.java
View file @
3a54d744
...
...
@@ -50,7 +50,6 @@ public final class CacheDataSink implements DataSink {
private
final
int
bufferSize
;
private
boolean
syncFileDescriptor
;
private
boolean
respectCacheFragmentationFlag
;
private
DataSpec
dataSpec
;
private
long
dataSpecFragmentSize
;
private
File
file
;
...
...
@@ -123,20 +122,6 @@ public final class CacheDataSink implements DataSink {
this
.
syncFileDescriptor
=
syncFileDescriptor
;
}
/**
* Sets whether this instance respects the {@link DataSpec#FLAG_ALLOW_CACHE_FRAGMENTATION} flag.
* If set to {@code false} requests will always be fragmented. If set to {@code true} requests
* will be fragmented only if the flag is set.
*
* <p>This method is experimental, and will be renamed or removed in a future release.
*
* @param respectCacheFragmentationFlag Whether to respect the {@link
* DataSpec#FLAG_ALLOW_CACHE_FRAGMENTATION} flag.
*/
public
void
experimental_setRespectCacheFragmentationFlag
(
boolean
respectCacheFragmentationFlag
)
{
this
.
respectCacheFragmentationFlag
=
respectCacheFragmentationFlag
;
}
@Override
public
void
open
(
DataSpec
dataSpec
)
throws
CacheDataSinkException
{
if
(
dataSpec
.
length
==
C
.
LENGTH_UNSET
...
...
@@ -146,10 +131,7 @@ public final class CacheDataSink implements DataSink {
}
this
.
dataSpec
=
dataSpec
;
this
.
dataSpecFragmentSize
=
!
respectCacheFragmentationFlag
||
dataSpec
.
isFlagSet
(
DataSpec
.
FLAG_ALLOW_CACHE_FRAGMENTATION
)
?
fragmentSize
:
Long
.
MAX_VALUE
;
dataSpec
.
isFlagSet
(
DataSpec
.
FLAG_ALLOW_CACHE_FRAGMENTATION
)
?
fragmentSize
:
Long
.
MAX_VALUE
;
dataSpecBytesWritten
=
0
;
try
{
openNextOutputStream
();
...
...
library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheDataSinkFactory.java
View file @
3a54d744
...
...
@@ -27,7 +27,6 @@ public final class CacheDataSinkFactory implements DataSink.Factory {
private
final
int
bufferSize
;
private
boolean
syncFileDescriptor
;
private
boolean
respectCacheFragmentationFlag
;
/** @see CacheDataSink#CacheDataSink(Cache, long) */
public
CacheDataSinkFactory
(
Cache
cache
,
long
fragmentSize
)
{
...
...
@@ -51,22 +50,10 @@ public final class CacheDataSinkFactory implements DataSink.Factory {
return
this
;
}
/**
* See {@link CacheDataSink#experimental_setRespectCacheFragmentationFlag(boolean)}.
*
* <p>This method is experimental, and will be renamed or removed in a future release.
*/
public
CacheDataSinkFactory
experimental_setRespectCacheFragmentationFlag
(
boolean
respectCacheFragmentationFlag
)
{
this
.
respectCacheFragmentationFlag
=
respectCacheFragmentationFlag
;
return
this
;
}
@Override
public
DataSink
createDataSink
()
{
CacheDataSink
dataSink
=
new
CacheDataSink
(
cache
,
fragmentSize
,
bufferSize
);
dataSink
.
experimental_setSyncFileDescriptor
(
syncFileDescriptor
);
dataSink
.
experimental_setRespectCacheFragmentationFlag
(
respectCacheFragmentationFlag
);
return
dataSink
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment