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
ae65bcec
authored
Jan 02, 2019
by
olly
Committed by
Oliver Woodman
Jan 08, 2019
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Move syncFileDescriptor to use an experimental method
PiperOrigin-RevId: 227520168
parent
1e992240
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
30 deletions
library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheDataSink.java
library/core/src/main/java/com/google/android/exoplayer2/util/AtomicFile.java
library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheDataSink.java
View file @
ae65bcec
...
@@ -42,8 +42,8 @@ public final class CacheDataSink implements DataSink {
...
@@ -42,8 +42,8 @@ public final class CacheDataSink implements DataSink {
private
final
Cache
cache
;
private
final
Cache
cache
;
private
final
long
maxCacheFileSize
;
private
final
long
maxCacheFileSize
;
private
final
int
bufferSize
;
private
final
int
bufferSize
;
private
final
boolean
syncFileDescriptor
;
private
boolean
syncFileDescriptor
;
private
DataSpec
dataSpec
;
private
DataSpec
dataSpec
;
private
File
file
;
private
File
file
;
private
OutputStream
outputStream
;
private
OutputStream
outputStream
;
...
@@ -67,25 +67,12 @@ public final class CacheDataSink implements DataSink {
...
@@ -67,25 +67,12 @@ public final class CacheDataSink implements DataSink {
* Constructs a CacheDataSink using the {@link #DEFAULT_BUFFER_SIZE}.
* Constructs a CacheDataSink using the {@link #DEFAULT_BUFFER_SIZE}.
*
*
* @param cache The cache into which data should be written.
* @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
,
DEFAULT_BUFFER_SIZE
,
true
);
}
/**
* 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
* @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
* {@link DataSpec} whose size exceeds this value, then the data will be fragmented into
* multiple cache files.
* multiple cache files.
* @param syncFileDescriptor Whether file descriptors are sync'd when closing output streams.
*/
*/
public
CacheDataSink
(
Cache
cache
,
long
maxCacheFileSize
,
boolean
syncFileDescriptor
)
{
public
CacheDataSink
(
Cache
cache
,
long
maxCacheFileSize
)
{
this
(
cache
,
maxCacheFileSize
,
DEFAULT_BUFFER_SIZE
,
syncFileDescriptor
);
this
(
cache
,
maxCacheFileSize
,
DEFAULT_BUFFER_SIZE
);
}
}
/**
/**
...
@@ -97,23 +84,21 @@ public final class CacheDataSink implements DataSink {
...
@@ -97,23 +84,21 @@ public final class CacheDataSink implements DataSink {
* value disables buffering.
* value disables buffering.
*/
*/
public
CacheDataSink
(
Cache
cache
,
long
maxCacheFileSize
,
int
bufferSize
)
{
public
CacheDataSink
(
Cache
cache
,
long
maxCacheFileSize
,
int
bufferSize
)
{
this
(
cache
,
maxCacheFileSize
,
bufferSize
,
true
);
this
.
cache
=
Assertions
.
checkNotNull
(
cache
);
this
.
maxCacheFileSize
=
maxCacheFileSize
;
this
.
bufferSize
=
bufferSize
;
syncFileDescriptor
=
true
;
}
}
/**
/**
* @param cache The cache into which data should be written.
* Sets whether file descriptors are synced when closing output streams.
* @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
* <p>This method is experimental, and will be renamed or removed in a future release. It should
* multiple cache files.
* only be called before the renderer is used.
* @param bufferSize The buffer size in bytes for writing to a cache file. A zero or negative
*
* value disables buffering.
* @param syncFileDescriptor Whether file descriptors are synced when closing output streams.
* @param syncFileDescriptor Whether file descriptors are sync'd when closing output streams.
*/
*/
public
CacheDataSink
(
public
void
experimental_setSyncFileDescriptor
(
boolean
syncFileDescriptor
)
{
Cache
cache
,
long
maxCacheFileSize
,
int
bufferSize
,
boolean
syncFileDescriptor
)
{
this
.
cache
=
Assertions
.
checkNotNull
(
cache
);
this
.
maxCacheFileSize
=
maxCacheFileSize
;
this
.
bufferSize
=
bufferSize
;
this
.
syncFileDescriptor
=
syncFileDescriptor
;
this
.
syncFileDescriptor
=
syncFileDescriptor
;
}
}
...
...
library/core/src/main/java/com/google/android/exoplayer2/util/AtomicFile.java
View file @
ae65bcec
...
@@ -29,7 +29,7 @@ import java.io.OutputStream;
...
@@ -29,7 +29,7 @@ import java.io.OutputStream;
* has successfully completed.
* has successfully completed.
*
*
* <p>Atomic file guarantees file integrity by ensuring that a file has been completely written and
* <p>Atomic file guarantees file integrity by ensuring that a file has been completely written and
* sync
'
d to disk before removing its backup. As long as the backup file exists, the original file
* sync
e
d to disk before removing its backup. As long as the backup file exists, the original file
* is considered to be invalid (left over from a previous attempt to write the file).
* is considered to be invalid (left over from a previous attempt to write the file).
*
*
* <p>Atomic file does not confer any file locking semantics. Do not use this class when the file
* <p>Atomic file does not confer any file locking semantics. Do not use this class when the file
...
...
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