当前位置: 首页>>代码示例>>Java>>正文


Java ShortBuffer.limit方法代码示例

本文整理汇总了Java中java.nio.ShortBuffer.limit方法的典型用法代码示例。如果您正苦于以下问题:Java ShortBuffer.limit方法的具体用法?Java ShortBuffer.limit怎么用?Java ShortBuffer.limit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.nio.ShortBuffer的用法示例。


在下文中一共展示了ShortBuffer.limit方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:25,代码来源:AudioChannel.java

示例2: allocate

import java.nio.ShortBuffer; //导入方法依赖的package包/类
private void allocate(){
	ByteBuffer buffer = ResourceLoader.getBytes(path);
	IntBuffer error = BufferUtils.createIntBuffer(1);
	long decoder = stb_vorbis_open_memory(buffer, error, null);
	if(decoder == 0L){
		Application.error("Unable to open STB Vorbis");
		return;
	}
	
	STBVorbisInfo info = STBVorbisInfo.malloc();
	
	stb_vorbis_get_info(decoder, info);
	
	int channels = info.channels();
	int lengthSamples = stb_vorbis_stream_length_in_samples(decoder);
	ShortBuffer pcm = BufferUtils.createShortBuffer(lengthSamples);
	pcm.limit(stb_vorbis_get_samples_short_interleaved(decoder, channels, pcm) * channels);
	stb_vorbis_close(decoder);
	
	AL10.alBufferData(id, info.channels() == 1? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16, pcm, info.sample_rate());
}
 
开发者ID:tek256,项目名称:LD38,代码行数:22,代码来源:Sound.java

示例3: 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;
}
 
开发者ID:uestccokey,项目名称:EZFilter,代码行数:25,代码来源:AudioChannel.java

示例4: testShortGet

import java.nio.ShortBuffer; //导入方法依赖的package包/类
@Test(dataProvider = "shortViewProvider")
public void testShortGet(String desc, IntFunction<ByteBuffer> fbb,
                         Function<ByteBuffer, ShortBuffer> fbi) {
    ByteBuffer bb = allocate(fbb);
    ShortBuffer vb = fbi.apply(bb);
    int o = bb.position();

    for (int i = 0; i < vb.limit(); i++) {
        short fromBytes = getShortFromBytes(bb, o + i * 2);
        short fromMethodView = bb.getShort(o + i * 2);
        assertValues(i, fromBytes, fromMethodView, bb);

        short fromBufferView = vb.get(i);
        assertValues(i, fromMethodView, fromBufferView, bb, vb);
    }

    for (int i = 0; i < vb.limit(); i++) {
        short v = getShortFromBytes(bb, o + i * 2);
        short a = bb.getShort();
        assertValues(i, v, a, bb);

        short b = vb.get();
        assertValues(i, a, b, bb, vb);
    }

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:ByteBufferViews.java

示例5: ensureLargeEnough

import java.nio.ShortBuffer; //导入方法依赖的package包/类
public static ShortBuffer ensureLargeEnough(ShortBuffer buffer, int required) {
    if (buffer != null) {
        buffer.limit(buffer.capacity());
    }
    if (buffer == null || (buffer.remaining() < required)) {
        int position = (buffer != null ? buffer.position() : 0);
        ShortBuffer newVerts = createShortBuffer(position + required);
        if (buffer != null) {
            buffer.flip();
            newVerts.put(buffer);
            newVerts.position(position);
        }
        buffer = newVerts;
    }
    return buffer;
}
 
开发者ID:asiermarzo,项目名称:Ultraino,代码行数:17,代码来源:BufferUtils.java

示例6: 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;
}
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:36,代码来源:AudioChannel.java

示例7: record

import java.nio.ShortBuffer; //导入方法依赖的package包/类
/**
 * shortBuffer包含了音频的数据和起始位置
 *
 * @param shortBuffer
 */
private void record(ShortBuffer shortBuffer) {
    try {
        if (videoRecorder != null) {
            this.mCount += shortBuffer.limit();
            videoRecorder.record(0, new Buffer[]{shortBuffer});
        }
    } catch (FrameRecorder.Exception localException) {

    }
    return;
}
 
开发者ID:feigxj,项目名称:VideoRecorder-master,代码行数:17,代码来源:FFmpegRecorderActivity.java

示例8: 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;
}
 
开发者ID:uestccokey,项目名称:EZFilter,代码行数:34,代码来源:AudioChannel.java

示例9: createShortBuffer

import java.nio.ShortBuffer; //导入方法依赖的package包/类
/**
 * Create a new ShortBuffer of an appropriate size to hold the specified
 * number of shorts only if the given buffer if not already the right size.
 * 
 * @param buf
 *            the buffer to first check and rewind
 * @param size
 *            number of shorts that need to be held by the newly created
 *            buffer
 * @return the requested new ShortBuffer
 */
public static ShortBuffer createShortBuffer(ShortBuffer buf, int size) {
    if (buf != null && buf.limit() == size) {
        buf.rewind();
        return buf;
    }

    buf = createShortBuffer(size);
    return buf;
}
 
开发者ID:asiermarzo,项目名称:Ultraino,代码行数:21,代码来源:BufferUtils.java


注:本文中的java.nio.ShortBuffer.limit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。