LoopingAudioStream.java
net.minecraft.client.sounds.LoopingAudioStream
信息
- 全限定名:net.minecraft.client.sounds.LoopingAudioStream
- 类型:public class
- 包:net.minecraft.client.sounds
- 源码路径:src/main/java/net/minecraft/client/sounds/LoopingAudioStream.java
- 起始行号:L13
- 实现:AudioStream
- 职责:
TODO
字段/常量
-
provider- 类型:
LoopingAudioStream.AudioStreamProvider - 修饰符:
private final - 源码定位:
L14 - 说明:
TODO
- 类型:
-
stream- 类型:
AudioStream - 修饰符:
private - 源码定位:
L15 - 说明:
TODO
- 类型:
-
bufferedInputStream- 类型:
BufferedInputStream - 修饰符:
private final - 源码定位:
L16 - 说明:
TODO
- 类型:
内部类/嵌套类型
-
net.minecraft.client.sounds.LoopingAudioStream.AudioStreamProvider- 类型:
interface - 修饰符:
public - 源码定位:
L51 - 说明:
TODO
- 类型:
-
net.minecraft.client.sounds.LoopingAudioStream.NoCloseBuffer- 类型:
class - 修饰符:
private static - 源码定位:
L56 - 说明:
TODO
- 类型:
构造器
public LoopingAudioStream(LoopingAudioStream.AudioStreamProvider provider, InputStream originalInputStream) @ L18
- 构造器名:LoopingAudioStream
- 源码定位:L18
- 修饰符:public
参数:
- provider: LoopingAudioStream.AudioStreamProvider
- originalInputStream: InputStream
说明:
TODO
方法
下面的方法块按源码顺序生成。
public AudioFormat getFormat() @ L25
- 方法名:getFormat
- 源码定位:L25
- 返回类型:AudioFormat
- 修饰符:public
参数:
- 无
说明:
TODO
public ByteBuffer read(int expectedSize) @ L30
- 方法名:read
- 源码定位:L30
- 返回类型:ByteBuffer
- 修饰符:public
参数:
- expectedSize: int
说明:
TODO
public void close() @ L43
- 方法名:close
- 源码定位:L43
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class LoopingAudioStream implements AudioStream {
private final LoopingAudioStream.AudioStreamProvider provider;
private AudioStream stream;
private final BufferedInputStream bufferedInputStream;
public LoopingAudioStream(LoopingAudioStream.AudioStreamProvider provider, InputStream originalInputStream) throws IOException {
this.provider = provider;
this.bufferedInputStream = new BufferedInputStream(originalInputStream);
this.bufferedInputStream.mark(Integer.MAX_VALUE);
this.stream = provider.create(new LoopingAudioStream.NoCloseBuffer(this.bufferedInputStream));
}
@Override
public AudioFormat getFormat() {
return this.stream.getFormat();
}
@Override
public ByteBuffer read(int expectedSize) throws IOException {
ByteBuffer result = this.stream.read(expectedSize);
if (!result.hasRemaining()) {
this.stream.close();
this.bufferedInputStream.reset();
this.stream = this.provider.create(new LoopingAudioStream.NoCloseBuffer(this.bufferedInputStream));
result = this.stream.read(expectedSize);
}
return result;
}
@Override
public void close() throws IOException {
this.stream.close();
this.bufferedInputStream.close();
}
@FunctionalInterface
@OnlyIn(Dist.CLIENT)
public interface AudioStreamProvider {
AudioStream create(final InputStream inputStream) throws IOException;
}
@OnlyIn(Dist.CLIENT)
private static class NoCloseBuffer extends FilterInputStream {
private NoCloseBuffer(InputStream in) {
super(in);
}
@Override
public void close() {
}
}
}引用的其他类
- AudioStream
- 引用位置:
字段/实现
- 引用位置: