JOAL v2.6.0-rc-20250712
JOAL, OpenAL® API Binding for Java™ (public API).
ALDebugExtTest.java
Go to the documentation of this file.
1/**
2 * Copyright 2023 JogAmp Community. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without modification, are
5 * permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice, this list of
8 * conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 * The views and conclusions contained in the software and documentation are those of the
25 * authors and should not be interpreted as representing official policies, either expressed
26 * or implied, of JogAmp Community.
27 */
28package com.jogamp.openal.test.junit;
29
30import java.io.IOException;
31import java.util.concurrent.atomic.AtomicInteger;
32import java.util.concurrent.atomic.AtomicReference;
33
34import org.junit.FixMethodOrder;
35import org.junit.Test;
36import org.junit.After;
37import org.junit.Assert;
38import org.junit.runners.MethodSorters;
39
40import com.jogamp.openal.AL;
41import com.jogamp.openal.ALC;
42import com.jogamp.openal.ALCcontext;
43import com.jogamp.openal.ALCdevice;
44import com.jogamp.openal.ALExt;
45import com.jogamp.openal.ALExtConstants;
46import com.jogamp.openal.ALFactory;
47import com.jogamp.openal.sound3d.AudioSystem3D;
48import com.jogamp.openal.test.util.UITestCase;
49import com.jogamp.openal.util.ALHelpers;
50
51/**
52 * Testing the OpenAL-Soft Debug Extension.
53 */
54@FixMethodOrder(MethodSorters.NAME_ASCENDING)
55public class ALDebugExtTest extends UITestCase {
56
57 @Test
58 public void test01DebugExt() {
59 final ALC alc = ALFactory.getALC();
60 final ALCdevice device = alc.alcOpenDevice(null);
61
63 System.err.println("ALCdevice has no "+ALHelpers.ALC_EXT_debug+" extension");
64 return;
65 }
66 final int[] attributes = new int[] { ALExtConstants.ALC_CONTEXT_FLAGS_EXT, ALExtConstants.ALC_CONTEXT_DEBUG_BIT_EXT };
67 final ALCcontext context = alc.alcCreateContext(device, attributes, 0);
68 if( !alc.alcMakeContextCurrent(context) ) {
69 System.err.println("makeCurrent() failed");
70 return;
71 }
72 // final JoalVersion jv = JoalVersion.getInstance();
73 // System.err.println(jv.toString(alc));
74 System.err.println("-----------------------------------------------------------------------------------------------------");
75
76 final AL al = ALFactory.getAL();
78 System.err.println("Current context has no "+ALHelpers.AL_EXT_debug+" extension");
79 return;
80 }
81 final AtomicInteger dbg_counter = new AtomicInteger(0);
82 final AtomicReference<String> dbg_msg = new AtomicReference<String>();
83 final ALExt.ALDEBUGPROCEXT debug_cb = new ALExt.ALDEBUGPROCEXT() {
84 @Override
85 public void callback(final int source, final int type, final int id, final int severity, final String message, final ALCcontext userParam) {
86 final int count = dbg_counter.incrementAndGet();
87 if( 1 == count ) {
88 dbg_msg.set(message);
89 }
90 System.err.println("AL-Debug["+count+"]: src 0x"+Integer.toHexString(source)+
91 ", type 0x"+Integer.toHexString(type)+
92 ", id "+id+
93 ", severity 0x"+Integer.toHexString(severity)+", msg '"+message+"', ctx "+userParam);
94 }
95 };
96 final String expMessage = "Test Message";
101 0, null, 0,
102 true);
105 0,
107 Assert.assertEquals(1, dbg_counter.get());
108 Assert.assertEquals(expMessage, dbg_msg.get());
109 alc.alcDestroyContext(context);
110 alc.alcCloseDevice(device);
111 }
112
113 @After
114 @Override
115 public void tearDown() {
116 super.tearDown();
117 final ALC alc = ALFactory.getALC();
118 final ALCcontext context = alc.alcGetCurrentContext();
119 if(null != context) {
120 alc.alcDestroyContext(context);
121 final ALCdevice device = alc.alcGetContextsDevice(context);
122 if(null != device) {
123 alc.alcCloseDevice(device);
124 }
125 }
126 }
127
128 public static void main(final String args[]) throws IOException {
129 org.junit.runner.JUnitCore.main(ALDebugExtTest.class.getName());
130 }
131}
This class provides factory methods for generating AL and ALC objects.
Definition: ALFactory.java:62
static AL getAL()
Get the default AL object.
Definition: ALFactory.java:122
static ALC getALC()
Get the default ALC object.
Definition: ALFactory.java:136
The AudioSystem3D class provides a set of methods for creating and manipulating a 3D audio environmen...
static final ALExt getALExt()
Return OpenAL global ALExt.
Testing the OpenAL-Soft Debug Extension.
static void main(final String args[])
static final String ALC_EXT_debug
Definition: ALHelpers.java:58
static final String AL_EXT_debug
Definition: ALHelpers.java:59
void alcDestroyContext(ALCcontext context)
Entry point (through function pointer) to C language function: void alcDestroyContext(ALCcontext * ...
boolean alcMakeContextCurrent(ALCcontext context)
Entry point (through function pointer) to C language function: ALCboolean alcMakeContextCurrent(ALC...
ALCcontext alcGetCurrentContext()
Entry point (through function pointer) to C language function: ALCcontext * alcGetCurrentContext()
boolean alcCloseDevice(ALCdevice device)
Entry point (through function pointer) to C language function: ALCboolean alcCloseDevice(ALCdevice ...
ALCdevice alcGetContextsDevice(ALCcontext context)
Entry point (through function pointer) to C language function: ALCdevice * alcGetContextsDevice(ALC...
boolean alcIsExtensionPresent(ALCdevice device, String extname)
Entry point (through function pointer) to C language function: ALCboolean alcIsExtensionPresent(ALC...
ALCdevice alcOpenDevice(String devicename)
Entry point (through function pointer) to C language function: ALCdevice * alcOpenDevice(const ALCc...
ALCcontext alcCreateContext(ALCdevice device, IntBuffer attrlist)
Entry point (through function pointer) to C language function: ALCcontext * alcCreateContext(ALCdev...
static final int AL_DEBUG_TYPE_OTHER_EXT
Define "AL_DEBUG_TYPE_OTHER_EXT" with expression '0x19C2', CType: int.
static final int AL_DEBUG_SOURCE_OTHER_EXT
Define "AL_DEBUG_SOURCE_OTHER_EXT" with expression '0x19B9', CType: int.
static final int ALC_CONTEXT_FLAGS_EXT
Define "ALC_CONTEXT_FLAGS_EXT" with expression '0x19CF', CType: int.
static final int AL_DEBUG_SOURCE_APPLICATION_EXT
Define "AL_DEBUG_SOURCE_APPLICATION_EXT" with expression '0x19B8', CType: int.
static final int AL_DEBUG_SEVERITY_NOTIFICATION_EXT
Define "AL_DEBUG_SEVERITY_NOTIFICATION_EXT" with expression '0x19C6', CType: int.
JavaCallback interface: ALDEBUGPROCEXT -> void (*ALDEBUGPROCEXT)(ALenum source, ALenum type,...
Definition: ALExt.java:47
void alDebugMessageCallbackEXT(ALDEBUGPROCEXT callback, ALCcontext userParam)
Entry point (through function pointer) to C language function: void alDebugMessageCallbackEXT(ALDEB...
void alDebugMessageControlEXT(int source, int type, int severity, int count, IntBuffer ids, boolean enable)
Entry point (through function pointer) to C language function: void alDebugMessageControlEXT(ALenum...
void alDebugMessageInsertEXT(int source, int type, int id, int severity, String message)
Entry point (through function pointer) to C language function: void alDebugMessageInsertEXT(ALenum ...
boolean alIsExtensionPresent(String extname)
Entry point (through function pointer) to C language function: ALboolean alIsExtensionPresent(const...