當前位置: 首頁>>代碼示例>>Java>>正文


Java AL10.alSourceQueueBuffers方法代碼示例

本文整理匯總了Java中org.lwjgl.openal.AL10.alSourceQueueBuffers方法的典型用法代碼示例。如果您正苦於以下問題:Java AL10.alSourceQueueBuffers方法的具體用法?Java AL10.alSourceQueueBuffers怎麽用?Java AL10.alSourceQueueBuffers使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.lwjgl.openal.AL10的用法示例。


在下文中一共展示了AL10.alSourceQueueBuffers方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: update

import org.lwjgl.openal.AL10; //導入方法依賴的package包/類
public synchronized void update() {
    if (sourceID == -1) return;
    boolean end = false;
    int buffers = AL10.alGetSourcei(sourceID, AL10.AL_BUFFERS_PROCESSED);
    while (buffers-- > 0) {
        int bufferID = AL10.alSourceUnqueueBuffers(sourceID);
        if (bufferID == AL10.AL_INVALID_VALUE) break;
        renderedSeconds += secondsPerBuffer;
        if (end) continue;
        if (fill(bufferID)) {
            AL10.alSourceQueueBuffers(sourceID, bufferID);
        } else {
            end = true;
        }
    }
    if (end && AL10.alGetSourcei(sourceID, AL10.AL_BUFFERS_QUEUED) == 0) {
        stop();
    }
    if (isPlaying && AL10.alGetSourcei(sourceID, AL10.AL_SOURCE_STATE) != AL10.AL_PLAYING)
        AL10.alSourcePlay(sourceID);
}
 
開發者ID:dmitrykolesnikovich,項目名稱:featurea,代碼行數:22,代碼來源:MusicControllerImpl.java

示例2: startPlayback

import org.lwjgl.openal.AL10; //導入方法依賴的package包/類
/**
 * Starts the streaming.
 */
private void startPlayback() {
	AL10.alSourcei(source, AL10.AL_LOOPING, AL10.AL_FALSE);
	AL10.alSourcef(source, AL10.AL_PITCH, pitch);

	remainingBufferCount = BUFFER_COUNT;

	for (int i = 0; i < BUFFER_COUNT; i++) {
		stream(bufferNames.get(i));
	}

	AL10.alSourceQueueBuffers(source, bufferNames);
	AL10.alSourcePlay(source);
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:17,代碼來源:OpenALStreamPlayer.java

示例3: QueueSound

import org.lwjgl.openal.AL10; //導入方法依賴的package包/類
private void QueueSound(int sound)
{
	if (game.gameOptions.soundEnable == false)
		return;

	intBuffer.clear();
	intBuffer.put(sounds[sound]);
	intBuffer.flip();
	AL10.alSourceQueueBuffers(sources.get(0), intBuffer);

	int state = AL10.alGetSourcei(sources.get(0), AL10.AL_SOURCE_STATE);

	if (state != AL10.AL_PLAYING)
	{
		sourcePos.clear();
		sourcePos.put(0).put(0).put(0);
		sourcePos.flip();

		int Source = sources.get(0);

		AL10.alSourceStop(Source);

		AL10.alSourcef(Source, AL10.AL_PITCH, 1.0f);
		AL10.alSourcef(Source, AL10.AL_GAIN, 1.0f);

		AL10.alSource(Source, AL10.AL_POSITION, sourcePos);
		AL10.alSourcePlay(Source);
	}
}
 
開發者ID:TheRemote,項目名稱:Spark,代碼行數:30,代碼來源:Sounds.java

示例4: update

import org.lwjgl.openal.AL10; //導入方法依賴的package包/類
public boolean update(int source, boolean loop){
	if(dead)
		return false;
	
	int processed = AL10.alGetSourcei(source, AL10.AL_BUFFERS_PROCESSED);
	
	for(int i=0;i<processed;i++){
		int buffer = AL10.alSourceUnqueueBuffers(source);
		if(!stream(buffer)){
			boolean close = true;
			if(loop){
				rewind();
				close = !stream(buffer);
			}
			
			if(close)
				return false;
		}
		AL10.alSourceQueueBuffers(source, buffer);
	}
	
	if(processed == buffers.limit()){
		AL10.alSourcePlay(source);
	}
	
	return true;
}
 
開發者ID:tek256,項目名稱:LD38,代碼行數:28,代碼來源:Music.java

示例5: play

import org.lwjgl.openal.AL10; //導入方法依賴的package包/類
/**
    * Play a mod or xm track streamed from the specified location
    * 
    * @param module The moudle to play back
    * @param source The OpenAL source to play the music on
    * @param start True if the music should be started
    * @param loop True if the track should be looped
    */
public void play(Module module, int source, boolean loop, boolean start) {
	this.source = source;
	this.loop = loop;
	this.module = module;
	done = false;
	
	ibxm = new IBXM(48000);
	ibxm.set_module(module);
	songDuration = ibxm.calculate_song_duration();

	if (bufferNames != null) {
		AL10.alSourceStop(source);
		bufferNames.flip();
		AL10.alDeleteBuffers(bufferNames);
	}
	
	bufferNames = BufferUtils.createIntBuffer(2);
	AL10.alGenBuffers(bufferNames);
	remainingBufferCount = 2;
	
	for (int i=0;i<2;i++) {
        stream(bufferNames.get(i));
	}
       AL10.alSourceQueueBuffers(source, bufferNames);
	AL10.alSourcef(source, AL10.AL_PITCH, 1.0f);
	AL10.alSourcef(source, AL10.AL_GAIN, 1.0f); 
	
	if (start) {
		AL10.alSourcePlay(source);
	}
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:40,代碼來源:OpenALMODPlayer.java

示例6: update

import org.lwjgl.openal.AL10; //導入方法依賴的package包/類
/**
 * Poll the bufferNames - check if we need to fill the bufferNames with another
 * section. 
 * 
 * Most of the time this should be reasonably quick
 */
public void update() {
	if (done) {
		return;
	}
	
	int processed = AL10.alGetSourcei(source, AL10.AL_BUFFERS_PROCESSED);
	
	while (processed > 0) {
		unqueued.clear();
		
		AL10.alSourceUnqueueBuffers(source, unqueued);
        if (stream(unqueued.get(0))) {
        	AL10.alSourceQueueBuffers(source, unqueued);
        } else {
        	remainingBufferCount--;
        	if (remainingBufferCount == 0) {
        		done = true;
        	}
        }
        processed--;
	}
	
	int state = AL10.alGetSourcei(source, AL10.AL_SOURCE_STATE);
    
    if (state != AL10.AL_PLAYING) {
    	AL10.alSourcePlay(source);
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:35,代碼來源:OpenALMODPlayer.java

示例7: play

import org.lwjgl.openal.AL10; //導入方法依賴的package包/類
@Override
public void play() {
    if (sourceID == -1) {
        sourceID = player.obtainSource(true);
        if (sourceID == -1) return;
        if (buffers == null) {
            buffers = BufferUtils.createIntBuffer(bufferCount);
            AL10.alGenBuffers(buffers);
            if (AL10.alGetError() != AL10.AL_NO_ERROR)
                throw new RuntimeException("Unable to allocate audio buffers.");
        }
        AL10.alSourcei(sourceID, AL10.AL_LOOPING, AL10.AL_FALSE);
        int filled = 0;
        for (int i = 0; i < bufferCount; i++) {
            int bufferID = buffers.get(i);
            if (!fill(bufferID)) break;
            filled++;
            AL10.alSourceQueueBuffers(sourceID, bufferID);
        }
        if (filled == 0) {
        }
        if (AL10.alGetError() != AL10.AL_NO_ERROR) {
            System.err.println("alGetError = " + AL10.alGetError());
        }
    }
    AL10.alSourcePlay(sourceID);
    isPlaying = true;
    player.reload();
}
 
開發者ID:dmitrykolesnikovich,項目名稱:featurea,代碼行數:30,代碼來源:MusicControllerImpl.java

示例8: update

import org.lwjgl.openal.AL10; //導入方法依賴的package包/類
/**
 * Poll the bufferNames - check if we need to fill the bufferNames with another
 * section. 
 * 
 * Most of the time this should be reasonably quick
 */
public void update() {
	if (done) {
		return;
	}

	float sampleRate = audio.getRate();
	float sampleSize;
	if (audio.getChannels() > 1) {
		sampleSize = 4; // AL10.AL_FORMAT_STEREO16
	} else {
		sampleSize = 2; // AL10.AL_FORMAT_MONO16
	}
	
	int processed = AL10.alGetSourcei(source, AL10.AL_BUFFERS_PROCESSED);
	while (processed > 0) {
		unqueued.clear();
		AL10.alSourceUnqueueBuffers(source, unqueued);
		
		int bufferIndex = unqueued.get(0);

		float bufferLength = (AL10.alGetBufferi(bufferIndex, AL10.AL_SIZE) / sampleSize) / sampleRate;
		positionOffset += bufferLength;
		
        if (stream(bufferIndex)) {			
        	AL10.alSourceQueueBuffers(source, unqueued);
        } else {
        	remainingBufferCount--;
        	if (remainingBufferCount == 0) {
        		done = true;
        	}
        }
        processed--;
	}
	
	int state = AL10.alGetSourcei(source, AL10.AL_SOURCE_STATE);
    
    if (state != AL10.AL_PLAYING) {
    	AL10.alSourcePlay(source);
    }
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:47,代碼來源:OpenALStreamPlayer.java


注:本文中的org.lwjgl.openal.AL10.alSourceQueueBuffers方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。