Class FailOnCloseDataSink
- java.lang.Object
-
- com.google.android.exoplayer2.testutil.FailOnCloseDataSink
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFailOnCloseDataSink.FactoryFactory to create aFailOnCloseDataSink.
-
Constructor Summary
Constructors Constructor Description FailOnCloseDataSink(Cache cache, AtomicBoolean failOnClose)Creates an instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the sink.voidopen(DataSpec dataSpec)Opens the sink to consume the specified data.voidwrite(byte[] buffer, int offset, int length)Consumes the provided data.
-
-
-
Constructor Detail
-
FailOnCloseDataSink
public FailOnCloseDataSink(Cache cache, AtomicBoolean failOnClose)
Creates an instance.- Parameters:
cache- The cache to write to when not in fail-on-close mode.failOnClose- AnAtomicBooleanwhose value is read in each call toopen(com.google.android.exoplayer2.upstream.DataSpec)to determine whether to enable fail-on-close for the read that's being started.
-
-
Method Detail
-
open
public void open(DataSpec dataSpec) throws IOException
Description copied from interface:DataSinkOpens the sink to consume the specified data.Note: If an
IOExceptionis thrown, callers must still callDataSink.close()to ensure that any partial effects of the invocation are cleaned up.- Specified by:
openin interfaceDataSink- Parameters:
dataSpec- Defines the data to be consumed.- Throws:
IOException- If an error occurs opening the sink.
-
write
public void write(byte[] buffer, int offset, int length) throws IOExceptionDescription copied from interface:DataSinkConsumes the provided data.- Specified by:
writein interfaceDataSink- Parameters:
buffer- The buffer from which data should be consumed.offset- The offset of the data to consume inbuffer.length- The length of the data to consume, in bytes.- Throws:
IOException- If an error occurs writing to the sink.
-
close
public void close() throws IOExceptionDescription copied from interface:DataSinkCloses the sink.Note: This method must be called even if the corresponding call to
DataSink.open(DataSpec)threw anIOException. SeeDataSink.open(DataSpec)for more details.- Specified by:
closein interfaceDataSink- Throws:
IOException- If an error occurs closing the sink.
-
-