@@ -228,11 +228,9 @@ private void initEfx() {
228228
229229 // 3. Configure effect type
230230 efx .alEffecti (reverbFx , EFX .AL_EFFECT_TYPE , EFX .AL_EFFECT_REVERB );
231- checkAlError ("setting reverb effect type" );
232231
233232 // 4. attach reverb effect to effect slot
234233 efx .alAuxiliaryEffectSloti (reverbFxSlot , EFX .AL_EFFECTSLOT_EFFECT , reverbFx );
235- checkAlError ("attaching reverb effect to slot" );
236234
237235 } else {
238236 logger .log (Level .WARNING , "OpenAL EFX not available! Audio effects won't work." );
@@ -259,7 +257,6 @@ private void destroyOpenAL() {
259257 ib .put (channels );
260258 ib .flip ();
261259 al .alDeleteSources (channels .length , ib );
262- checkAlError ("deleting sources" );
263260
264261 // Delete audio buffers and filters managed by NativeObjectManager
265262 objManager .deleteAllObjects (this );
@@ -270,15 +267,13 @@ private void destroyOpenAL() {
270267 ib .clear ().limit (1 );
271268 ib .put (0 , reverbFx );
272269 efx .alDeleteEffects (1 , ib );
273- checkAlError ("deleting reverbFx effect " + reverbFx );
274270 reverbFx = -1 ;
275271 }
276272
277273 if (reverbFxSlot != -1 ) {
278274 ib .clear ().limit (1 );
279275 ib .put (0 , reverbFxSlot );
280276 efx .alDeleteAuxiliaryEffectSlots (1 , ib );
281- checkAlError ("deleting effect reverbFxSlot " + reverbFxSlot );
282277 reverbFxSlot = -1 ;
283278 }
284279 }
@@ -408,15 +403,8 @@ private void updateFilter(Filter f) {
408403 efx .alFilteri (id , EFX .AL_FILTER_TYPE , EFX .AL_FILTER_LOWPASS );
409404 efx .alFilterf (id , EFX .AL_LOWPASS_GAIN , lowPass .getVolume ());
410405 efx .alFilterf (id , EFX .AL_LOWPASS_GAINHF , lowPass .getHighFreqVolume ());
411-
412- if (checkAlError ("updating filter " + id )) {
413- deleteFilter (f ); // Try to clean up
414- } else {
415- f .clearUpdateNeeded (); // Mark as updated in AL
416- }
417- }
418- // ** Add other filter types (HighPass, BandPass) here if implemented **
419- else {
406+ f .clearUpdateNeeded ();
407+ } else {
420408 throw new UnsupportedOperationException ("Unsupported filter type: " + f .getClass ().getName ());
421409 }
422410 }
@@ -455,9 +443,6 @@ public float getSourcePlaybackTime(AudioSource src) {
455443
456444 // Add byte offset from source (for both streams and buffers)
457445 int byteOffset = al .alGetSourcei (sourceId , AL_BYTE_OFFSET );
458- if (checkAlError ("getting source byte offset for " + sourceId )) {
459- return 0 ; // Error getting offset
460- }
461446 playbackOffsetBytes += byteOffset ;
462447
463448 // Compute time value from bytes
@@ -631,7 +616,6 @@ private void applySourceDryFilter(int sourceId, AudioSource src) {
631616 }
632617 // NOTE: must re-attach filter for changes to apply.
633618 al .alSourcei (sourceId , EFX .AL_DIRECT_FILTER , filterId );
634- checkAlError ("setting source direct filter for " + sourceId );
635619 }
636620 }
637621
@@ -646,7 +630,6 @@ private void applySourceReverbFilter(int sourceId, AudioSource src) {
646630 filterId = f .getId ();
647631 }
648632 al .alSource3i (sourceId , EFX .AL_AUXILIARY_SEND_FILTER , reverbFxSlot , 0 , filterId );
649- checkAlError ("setting source reverb send for " + sourceId );
650633 }
651634 }
652635
@@ -657,7 +640,6 @@ private void applySourceLooping(int sourceId, AudioSource src, boolean forceNonL
657640 looping = false ;
658641 }
659642 al .alSourcei (sourceId , AL_LOOPING , looping ? AL_TRUE : AL_FALSE );
660- checkAlError ("setting source looping for " + sourceId );
661643 }
662644
663645 /** Sets AL_SOURCE_RELATIVE and applies position/velocity/distance accordingly */
@@ -690,7 +672,6 @@ private void applySourcePositionalState(int sourceId, AudioSource src) {
690672 al .alSource3i (sourceId , EFX .AL_AUXILIARY_SEND_FILTER , 0 , 0 , EFX .AL_FILTER_NULL );
691673 }
692674 }
693- checkAlError ("setting source positional state for " + sourceId );
694675 }
695676
696677 /** Sets cone angles/gain based on whether the source is directional */
@@ -707,7 +688,6 @@ private void applySourceDirectionalState(int sourceId, AudioSource src) {
707688 al .alSourcef (sourceId , AL_CONE_OUTER_ANGLE , 360f );
708689 al .alSourcef (sourceId , AL_CONE_OUTER_GAIN , 1f );
709690 }
710- checkAlError ("setting source directional state for " + sourceId );
711691 }
712692
713693 /**
@@ -766,7 +746,6 @@ private void setListenerParams(Listener listener) {
766746 private void applyListenerPosition (Listener listener ) {
767747 Vector3f pos = listener .getLocation ();
768748 al .alListener3f (AL_POSITION , pos .x , pos .y , pos .z );
769- checkAlError ("setting listener position" );
770749 }
771750
772751 private void applyListenerRotation (Listener listener ) {
@@ -778,18 +757,15 @@ private void applyListenerRotation(Listener listener) {
778757 fb .put (up .x ).put (up .y ).put (up .z );
779758 fb .flip ();
780759 al .alListener (AL_ORIENTATION , fb );
781- checkAlError ("setting listener orientation" );
782760 }
783761
784762 private void applyListenerVelocity (Listener listener ) {
785763 Vector3f vel = listener .getVelocity ();
786764 al .alListener3f (AL_VELOCITY , vel .x , vel .y , vel .z );
787- checkAlError ("setting listener velocity" );
788765 }
789766
790767 private void applyListenerVolume (Listener listener ) {
791768 al .alListenerf (AL_GAIN , listener .getVolume ());
792- checkAlError ("setting listener volume" );
793769 }
794770
795771 private int newChannel () {
@@ -836,14 +812,8 @@ public void setEnvironment(Environment env) {
836812 efx .alEffectf (reverbFx , EFX .AL_REVERB_AIR_ABSORPTION_GAINHF , env .getAirAbsorbGainHf ());
837813 efx .alEffectf (reverbFx , EFX .AL_REVERB_ROOM_ROLLOFF_FACTOR , env .getRoomRolloffFactor ());
838814
839- if (checkAlError ("setting reverb effect parameters" )) {
840- return ;
841- }
842-
843815 // (Re)attach the configured reverb effect to the slot
844816 efx .alAuxiliaryEffectSloti (reverbFxSlot , EFX .AL_EFFECTSLOT_EFFECT , reverbFx );
845- checkAlError ("attaching reverb effect to slot" );
846-
847817 this .environment = env ;
848818 }
849819 }
@@ -884,9 +854,6 @@ private boolean fillBuffer(AudioStream stream, int bufferId) {
884854 int sampleRate = stream .getSampleRate ();
885855 al .alBufferData (bufferId , format , nativeBuf , totalBytesRead , sampleRate );
886856
887- if (checkAlError ("filling buffer " + bufferId + " for stream" )) {
888- return false ;
889- }
890857 return true ;
891858 }
892859
@@ -1015,23 +982,19 @@ private void clearChannel(int index) {
1015982
1016983 int sourceId = channels [index ];
1017984 al .alSourceStop (sourceId );
1018- checkAlError ("stopping source " + sourceId + " on clearChannel" );
1019985
1020986 // For streaming sources, this will clear all queued buffers.
1021987 al .alSourcei (sourceId , AL_BUFFER , 0 );
1022- checkAlError ("detaching buffer from source " + sourceId );
1023988
1024989 if (supportEfx ) {
1025990 if (src .getDryFilter () != null ) {
1026991 // detach direct filter
1027992 al .alSourcei (sourceId , EFX .AL_DIRECT_FILTER , EFX .AL_FILTER_NULL );
1028- checkAlError ("detaching direct filter from source " + sourceId );
1029993 }
1030994
1031995 if (src .isPositional () && src .isReverbEnabled ()) {
1032996 // Detach auxiliary send filter (reverb)
1033997 al .alSource3i (sourceId , EFX .AL_AUXILIARY_SEND_FILTER , 0 , 0 , EFX .AL_FILTER_NULL );
1034- checkAlError ("detaching aux filter from source " + sourceId );
1035998 }
1036999 }
10371000
@@ -1264,7 +1227,6 @@ public void updateInDecoderThread(float tpf) {
12641227 // Start it again.
12651228 logger .log (Level .WARNING , "Buffer starvation detected for stream on channel {0}. Restarting playback." , i );
12661229 al .alSourcePlay (sourceId );
1267- checkAlError ("restarting starved source " + sourceId );
12681230 }
12691231 }
12701232
@@ -1375,7 +1337,6 @@ public void playSourceInstance(AudioSource src) {
13751337
13761338 // play the channel
13771339 al .alSourcePlay (sourceId );
1378- checkAlError ("playing source instance " + sourceId );
13791340 }
13801341 }
13811342
@@ -1430,9 +1391,7 @@ public void playSource(AudioSource src) {
14301391 // play the channel
14311392 int sourceId = channels [src .getChannel ()];
14321393 al .alSourcePlay (sourceId );
1433- if (!checkAlError ("playing source " + sourceId )) {
1434- src .setStatus (Status .Playing ); // Update JME status on success
1435- }
1394+ src .setStatus (Status .Playing ); // Update JME status
14361395 }
14371396 }
14381397
@@ -1459,9 +1418,7 @@ public void pauseSource(AudioSource src) {
14591418
14601419 int sourceId = channels [src .getChannel ()];
14611420 al .alSourcePause (sourceId );
1462- if (!checkAlError ("pausing source " + sourceId )) {
1463- src .setStatus (Status .Paused ); // Update JME status on success
1464- }
1421+ src .setStatus (Status .Paused ); // Update JME status
14651422 }
14661423 }
14671424 }
@@ -1532,7 +1489,6 @@ private int getOpenALFormat(AudioData audioData) {
15321489 }
15331490 }
15341491
1535- // Format not supported
15361492 throw new UnsupportedOperationException ("Unsupported audio format: "
15371493 + channels + " channels, " + bitsPerSample + " bits per sample." );
15381494 }
@@ -1546,7 +1502,6 @@ private void updateAudioBuffer(AudioBuffer ab) {
15461502 if (ab .getId () == -1 ) {
15471503 ib .clear ().limit (1 );
15481504 al .alGenBuffers (1 , ib );
1549- checkAlError ("generating bufferId" );
15501505 id = ib .get (0 );
15511506 ab .setId (id );
15521507
@@ -1561,9 +1516,7 @@ private void updateAudioBuffer(AudioBuffer ab) {
15611516 int sampleRate = ab .getSampleRate ();
15621517
15631518 al .alBufferData (id , format , data , data .capacity (), sampleRate );
1564- if (!checkAlError ("uploading buffer data for ID " + id )) {
1565- ab .clearUpdateNeeded ();
1566- }
1519+ ab .clearUpdateNeeded ();
15671520 }
15681521
15691522 /**
@@ -1581,7 +1534,6 @@ private void updateAudioStream(AudioStream as) {
15811534 ib .clear ().limit (STREAMING_BUFFER_COUNT );
15821535
15831536 al .alGenBuffers (STREAMING_BUFFER_COUNT , ib );
1584- checkAlError ("generating stream buffers ids" );
15851537
15861538 ib .rewind ();
15871539 ib .get (ids );
@@ -1611,7 +1563,6 @@ public void deleteFilter(Filter filter) {
16111563 ib .clear ().limit (1 );
16121564 ib .put (id ).flip ();
16131565 efx .alDeleteFilters (1 , ib );
1614- checkAlError ("deleting filter " + id );
16151566 filter .resetObject ();
16161567 }
16171568 }
@@ -1634,7 +1585,6 @@ public void deleteAudioData(AudioData audioData) {
16341585 ib .put (0 , id );
16351586 ib .clear ().limit (1 );
16361587 al .alDeleteBuffers (1 , ib );
1637- checkAlError ("deleting buffer " + id );
16381588 ab .resetObject (); // Mark as deleted on JME side
16391589 }
16401590 } else if (audioData instanceof AudioStream ) {
@@ -1644,45 +1594,10 @@ public void deleteAudioData(AudioData audioData) {
16441594 ib .clear ();
16451595 ib .put (ids ).flip ();
16461596 al .alDeleteBuffers (ids .length , ib );
1647- checkAlError ("deleting " + ids .length + " buffers" );
16481597 as .resetObject (); // Mark as deleted on JME side
16491598 }
16501599 }
16511600 }
16521601 }
16531602
1654- /**
1655- * Checks for OpenAL errors and logs a warning if an error occurred.
1656- * @param location A string describing where the check is occurring (for logging).
1657- * @return True if an error occurred, false otherwise.
1658- */
1659- private boolean checkAlError (String location ) {
1660- int error = al .alGetError ();
1661- if (error != AL_NO_ERROR ) {
1662- String errorString ;
1663- switch (error ) {
1664- case AL_INVALID_NAME :
1665- errorString = "AL_INVALID_NAME" ;
1666- break ;
1667- case AL_INVALID_ENUM :
1668- errorString = "AL_INVALID_ENUM" ;
1669- break ;
1670- case AL_INVALID_VALUE :
1671- errorString = "AL_INVALID_VALUE" ;
1672- break ;
1673- case AL_INVALID_OPERATION :
1674- errorString = "AL_INVALID_OPERATION" ;
1675- break ;
1676- case AL_OUT_OF_MEMORY :
1677- errorString = "AL_OUT_OF_MEMORY" ;
1678- break ;
1679- default :
1680- errorString = "Unknown AL error code: " + error ;
1681- break ;
1682- }
1683- logger .log (Level .WARNING , "OpenAL Error ({0}) at {1}" , new Object []{errorString , location });
1684- return true ;
1685- }
1686- return false ;
1687- }
16881603}
0 commit comments