Java Code Examples for org.lwjgl.openal.AL10#AL_PLAYING

The following examples show how to use org.lwjgl.openal.AL10#AL_PLAYING . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OpenALStreamPlayer.java    From opsu-dance with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Poll the bufferNames - check if we need to fill the bufferNames with another
 * section. 
 * 
 * Most of the time this should be reasonably quick
 */
public synchronized void update() {
	if (done) {
		return;
	}

	int processed = AL10.alGetSourcei(source, AL10.AL_BUFFERS_PROCESSED);
	while (processed > 0) {
		unqueued.clear();
		AL10.alSourceUnqueueBuffers(source, unqueued);
		
		int bufferIndex = unqueued.get(0);

		int bufferLength = AL10.alGetBufferi(bufferIndex, AL10.AL_SIZE);

		playedPos += bufferLength;

		if (musicLength > 0 && playedPos > musicLength)
			playedPos -= musicLength;

		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);
	}
}
 
Example 2
Source File: SoundStore.java    From opsu-dance with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Find a free sound source
 * 
 * @return The index of the free sound source
 */
private int findFreeSource() {
	for (int i=1;i<sourceCount-1;i++) {
		int state = AL10.alGetSourcei(sources.get(i), AL10.AL_SOURCE_STATE);
		
		if ((state != AL10.AL_PLAYING) && (state != AL10.AL_PAUSED)) {
			return i;
		}
	}
	
	return -1;
}
 
Example 3
Source File: SoundStore.java    From opsu-dance with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Check if the music is currently playing
 * 
 * @return True if the music is playing
 */
public boolean isMusicPlaying() 
{
	if (!soundWorks) {
		return false;
	}
	
	int state = AL10.alGetSourcei(sources.get(0), AL10.AL_SOURCE_STATE);
	return ((state == AL10.AL_PLAYING) || (state == AL10.AL_PAUSED));
}
 
Example 4
Source File: OpenALStreamPlayer.java    From opsu with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Poll the bufferNames - check if we need to fill the bufferNames with another
 * section. 
 * 
 * Most of the time this should be reasonably quick
 */
public synchronized void update() {
	if (done) {
		return;
	}

	int processed = AL10.alGetSourcei(source, AL10.AL_BUFFERS_PROCESSED);
	while (processed > 0) {
		unqueued.clear();
		AL10.alSourceUnqueueBuffers(source, unqueued);
		
		int bufferIndex = unqueued.get(0);

		int bufferLength = AL10.alGetBufferi(bufferIndex, AL10.AL_SIZE);

		playedPos += bufferLength;

		if (musicLength > 0 && playedPos > musicLength)
			playedPos -= musicLength;

		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);
	}
}
 
Example 5
Source File: SoundStore.java    From opsu with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Find a free sound source
 * 
 * @return The index of the free sound source
 */
private int findFreeSource() {
	for (int i=1;i<sourceCount-1;i++) {
		int state = AL10.alGetSourcei(sources.get(i), AL10.AL_SOURCE_STATE);
		
		if ((state != AL10.AL_PLAYING) && (state != AL10.AL_PAUSED)) {
			return i;
		}
	}
	
	return -1;
}
 
Example 6
Source File: SoundStore.java    From opsu with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Check if the music is currently playing
 * 
 * @return True if the music is playing
 */
public boolean isMusicPlaying() 
{
	if (!soundWorks) {
		return false;
	}
	
	int state = AL10.alGetSourcei(sources.get(0), AL10.AL_SOURCE_STATE);
	return ((state == AL10.AL_PLAYING) || (state == AL10.AL_PAUSED));
}
 
Example 7
Source File: SoundStore.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Find a free sound source
 * 
 * @return The index of the free sound source
 */
private int findFreeSource() {
	for (int i=1;i<sourceCount-1;i++) {
		int state = AL10.alGetSourcei(sources.get(i), AL10.AL_SOURCE_STATE);
		
		if ((state != AL10.AL_PLAYING) && (state != AL10.AL_PAUSED)) {
			return i;
		}
	}
	
	return -1;
}
 
Example 8
Source File: SoundStore.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Check if the music is currently playing
 * 
 * @return True if the music is playing
 */
public boolean isMusicPlaying() 
{
	if (!soundWorks) {
		return false;
	}
	
	int state = AL10.alGetSourcei(sources.get(0), AL10.AL_SOURCE_STATE);
	return ((state == AL10.AL_PLAYING) || (state == AL10.AL_PAUSED));
}
 
Example 9
Source File: OpenALMODPlayer.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example 10
Source File: Mini2DxOpenALAudio.java    From mini2Dx with Apache License 2.0 5 votes vote down vote up
public boolean isSoundPlaying(long soundId) {
	if (!soundIdToSource.containsKey(soundId)) {
		return false;
	}
	int sourceId = soundIdToSource.get(soundId);
	int soundState = AL10.alGetSourcei(sourceId, AL10.AL_SOURCE_STATE);

	switch (soundState) {
	case AL10.AL_PLAYING:
		return true;
	default:
		return false;
	}
}
 
Example 11
Source File: Mini2DxOpenALAudio.java    From mini2Dx with Apache License 2.0 5 votes vote down vote up
public boolean isSoundPlaying(long soundId) {
	if (!soundIdToSource.containsKey(soundId)) {
		return false;
	}
	int sourceId = soundIdToSource.get(soundId);
	int soundState = AL10.alGetSourcei(sourceId, AL10.AL_SOURCE_STATE);

	switch (soundState) {
	case AL10.AL_PLAYING:
		return true;
	default:
		return false;
	}
}
 
Example 12
Source File: OpenALStreamPlayer.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * 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);
    }
}
 
Example 13
Source File: SoundStore.java    From opsu-dance with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Check if a particular source is playing
 * 
 * @param index The index of the source to check
 * @return True if the source is playing
 */
boolean isPlaying(int index) {
	int state = AL10.alGetSourcei(sources.get(index), AL10.AL_SOURCE_STATE);
	
	return (state == AL10.AL_PLAYING);
}
 
Example 14
Source File: SoundStore.java    From opsu with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Check if a particular source is playing
 * 
 * @param index The index of the source to check
 * @return True if the source is playing
 */
boolean isPlaying(int index) {
	int state = AL10.alGetSourcei(sources.get(index), AL10.AL_SOURCE_STATE);
	
	return (state == AL10.AL_PLAYING);
}
 
Example 15
Source File: SoundStore.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 2 votes vote down vote up
/**
 * Check if a particular source is playing
 * 
 * @param index The index of the source to check
 * @return True if the source is playing
 */
boolean isPlaying(int index) {
	int state = AL10.alGetSourcei(sources.get(index), AL10.AL_SOURCE_STATE);
	
	return (state == AL10.AL_PLAYING);
}