本文整理汇总了Java中java.nio.ShortBuffer.clear方法的典型用法代码示例。如果您正苦于以下问题:Java ShortBuffer.clear方法的具体用法?Java ShortBuffer.clear怎么用?Java ShortBuffer.clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.nio.ShortBuffer
的用法示例。
在下文中一共展示了ShortBuffer.clear方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drainOverflow
import java.nio.ShortBuffer; //导入方法依赖的package包/类
private long drainOverflow(final ShortBuffer outBuff) {
final ShortBuffer overflowBuff = mOverflowBuffer.data;
final int overflowLimit = overflowBuff.limit();
final int overflowSize = overflowBuff.remaining();
final long beginPresentationTimeUs = mOverflowBuffer.presentationTimeUs +
sampleCountToDurationUs(overflowBuff.position(), mInputSampleRate, mOutputChannelCount);
outBuff.clear();
// Limit overflowBuff to outBuff's capacity
overflowBuff.limit(outBuff.capacity());
// Load overflowBuff onto outBuff
outBuff.put(overflowBuff);
if (overflowSize >= outBuff.capacity()) {
// Overflow fully consumed - Reset
overflowBuff.clear().limit(0);
} else {
// Only partially consumed - Keep position & restore previous limit
overflowBuff.limit(overflowLimit);
}
return beginPresentationTimeUs;
}
示例2: drainOverflow
import java.nio.ShortBuffer; //导入方法依赖的package包/类
private long drainOverflow(final ShortBuffer outBuff) {
final ShortBuffer overflowBuff = mOverflowBuffer.data;
final int overflowLimit = overflowBuff.limit();
final int overflowSize = overflowBuff.remaining();
final long beginPresentationTimeUs = mOverflowBuffer.presentationTimeUs + sampleCountToDurationUs(overflowBuff.position(), mInputSampleRate,
mOutputChannelCount);
outBuff.clear();
// Limit overflowBuff to outBuff's capacity
overflowBuff.limit(outBuff.capacity());
// Load overflowBuff onto outBuff
outBuff.put(overflowBuff);
if (overflowSize >= outBuff.capacity()) {
// Overflow fully consumed - Reset
overflowBuff.clear().limit(0);
} else {
// Only partially consumed - Keep position & restore previous limit
overflowBuff.limit(overflowLimit);
}
return beginPresentationTimeUs;
}
示例3: queueInput
import java.nio.ShortBuffer; //导入方法依赖的package包/类
@Override
public void queueInput(ByteBuffer inputBuffer) {
if (inputBuffer.hasRemaining()) {
ShortBuffer shortBuffer = inputBuffer.asShortBuffer();
int inputSize = inputBuffer.remaining();
inputBytes += inputSize;
sonic.queueInput(shortBuffer);
inputBuffer.position(inputBuffer.position() + inputSize);
}
int outputSize = sonic.getSamplesAvailable() * channelCount * 2;
if (outputSize > 0) {
if (buffer.capacity() < outputSize) {
buffer = ByteBuffer.allocateDirect(outputSize).order(ByteOrder.nativeOrder());
shortBuffer = buffer.asShortBuffer();
} else {
buffer.clear();
shortBuffer.clear();
}
sonic.getOutput(shortBuffer);
outputBytes += outputSize;
buffer.limit(outputSize);
outputBuffer = buffer;
}
}
示例4: remixAndMaybeFillOverflow
import java.nio.ShortBuffer; //导入方法依赖的package包/类
private long remixAndMaybeFillOverflow(final AudioBuffer input,
final ShortBuffer outBuff) {
final ShortBuffer inBuff = input.data;
final ShortBuffer overflowBuff = mOverflowBuffer.data;
outBuff.clear();
// Reset position to 0, and set limit to capacity (Since MediaCodec doesn't do that for us)
inBuff.clear();
if (inBuff.remaining() > outBuff.remaining()) {
// Overflow
// Limit inBuff to outBuff's capacity
inBuff.limit(outBuff.capacity());
mRemixer.remix(inBuff, outBuff);
// Reset limit to its own capacity & Keep position
inBuff.limit(inBuff.capacity());
// Remix the rest onto overflowBuffer
// NOTE: We should only reach this point when overflow buffer is empty
final long consumedDurationUs =
sampleCountToDurationUs(inBuff.position(), mInputSampleRate, mInputChannelCount);
mRemixer.remix(inBuff, overflowBuff);
// Seal off overflowBuff & mark limit
overflowBuff.flip();
mOverflowBuffer.presentationTimeUs = input.presentationTimeUs + consumedDurationUs;
} else {
// No overflow
mRemixer.remix(inBuff, outBuff);
}
return input.presentationTimeUs;
}
示例5: remixAndMaybeFillOverflow
import java.nio.ShortBuffer; //导入方法依赖的package包/类
private long remixAndMaybeFillOverflow(final AudioBuffer input, final ShortBuffer outBuff) {
final ShortBuffer inBuff = input.data;
final ShortBuffer overflowBuff = mOverflowBuffer.data;
outBuff.clear();
// Reset position to 0, and set limit to capacity (Since MediaCodec doesn't do that for us)
inBuff.clear();
if (inBuff.remaining() > outBuff.remaining()) {
// Overflow
// Limit inBuff to outBuff's capacity
inBuff.limit(outBuff.capacity());
mRemixer.remix(inBuff, outBuff);
// Reset limit to its own capacity & Keep position
inBuff.limit(inBuff.capacity());
// Remix the rest onto overflowBuffer
// NOTE: We should only reach this point when overflow buffer is empty
final long consumedDurationUs = sampleCountToDurationUs(inBuff.position(), mInputSampleRate, mInputChannelCount);
mRemixer.remix(inBuff, overflowBuff);
// Seal off overflowBuff & mark limit
overflowBuff.flip();
mOverflowBuffer.presentationTimeUs = input.presentationTimeUs + consumedDurationUs;
} else {
// No overflow
mRemixer.remix(inBuff, outBuff);
}
return input.presentationTimeUs;
}
示例6: createShortBuffer
import java.nio.ShortBuffer; //导入方法依赖的package包/类
public static ShortBuffer createShortBuffer(short... data) {
if (data == null) {
return null;
}
ShortBuffer buff = createShortBuffer(data.length);
buff.clear();
buff.put(data);
buff.flip();
return buff;
}
示例7: createShortBufferFromArray
import java.nio.ShortBuffer; //导入方法依赖的package包/类
public static ShortBuffer createShortBufferFromArray(short[] data) {
if (data == null) {
return null;
}
ShortBuffer buff = createShortBuffer(data.length);
buff.clear();
buff.put(data);
buff.flip();
return buff;
}