├── .github ├── FUNDING.yml └── workflows │ └── main.yml ├── alTrace.png ├── alTrace.icns ├── .gitignore ├── make-app-bundle.sh ├── LICENSE.txt ├── altrace_wx_cocoa.mm ├── CMakeLists.txt ├── alTrace-Mac-Info.plist ├── README.md ├── altrace_playback.h ├── messageboxex.h ├── altrace_common.h ├── AL ├── alc.h └── al.h ├── altrace_common.c ├── messageboxex.cpp ├── altrace_entrypoints.h ├── phamt.h └── altrace_cli.c /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [icculus] 2 | patreon: icculus 3 | -------------------------------------------------------------------------------- /alTrace.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icculus/altrace/HEAD/alTrace.png -------------------------------------------------------------------------------- /alTrace.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icculus/altrace/HEAD/alTrace.icns -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | cmake-build 3 | .DS_Store 4 | libopenal.1.dylib 5 | libopenal.so.1 6 | OpenAL32.dll 7 | 8 | 9 | -------------------------------------------------------------------------------- /make-app-bundle.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | rm -rf alTrace.app 4 | mkdir alTrace.app 5 | cd alTrace.app 6 | mkdir Contents 7 | mkdir Contents/MacOS 8 | mkdir Contents/Resources 9 | cp ../../alTrace.icns Contents/Resources/ 10 | cp ../../alTrace-Mac-Info.plist Contents/Info.plist 11 | cp -a ../altrace_wx Contents/MacOS/ 12 | 13 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | Build: 7 | name: ${{ matrix.platform.name }} 8 | runs-on: ${{ matrix.platform.os }} 9 | strategy: 10 | matrix: 11 | platform: 12 | - { name: Linux, os: ubuntu-20.04, flags: -GNinja } 13 | #- { name: Windows, os: windows-latest } 14 | - { name: MacOS, os: macos-latest } 15 | steps: 16 | - name: Setup Linux dependencies 17 | if: runner.os == 'Linux' 18 | run: | 19 | sudo apt-get update 20 | sudo apt-get install cmake ninja-build libwxgtk3.0-gtk3 libopenal-dev 21 | - name: Get alTrace sources 22 | uses: actions/checkout@v2 23 | - name: Configure CMake 24 | run: cmake -B build ${{ matrix.platform.flags }} 25 | - name: Build 26 | run: cmake --build build/ 27 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2019-2021 Ryan C. Gordon . 2 | 3 | This software is provided 'as-is', without any express or implied 4 | warranty. In no event will the authors be held liable for any damages 5 | arising from the use of this software. 6 | 7 | Permission is granted to anyone to use this software for any purpose, 8 | including commercial applications, and to alter it and redistribute it 9 | freely, subject to the following restrictions: 10 | 11 | 1. The origin of this software must not be misrepresented; you must not 12 | claim that you wrote the original software. If you use this software 13 | in a product, an acknowledgment in the product documentation would be 14 | appreciated but is not required. 15 | 2. Altered source versions must be plainly marked as such, and must not be 16 | misrepresented as being the original software. 17 | 3. This notice may not be removed or altered from any source distribution. 18 | -------------------------------------------------------------------------------- /altrace_wx_cocoa.mm: -------------------------------------------------------------------------------- 1 | /** 2 | * alTrace; a debugging tool for OpenAL. 3 | * 4 | * Please see the file LICENSE.txt in the source's root directory. 5 | * 6 | * This file written by Ryan C. Gordon. 7 | */ 8 | 9 | #include 10 | 11 | #pragma clang diagnostic push 12 | #pragma clang diagnostic ignored "-Wdeprecated-declarations" // ignore OpenGL deprecations. 13 | #include 14 | #pragma clang diagnostic pop 15 | 16 | typedef unsigned char uchar; 17 | 18 | void cocoaGetGridColors(wxColour *even, wxColor *odd) 19 | { 20 | @autoreleasepool { 21 | CGFloat r, g, b, a; 22 | NSArray *colors = NSColor.controlAlternatingRowBackgroundColors; 23 | [[[colors objectAtIndex:0] colorUsingColorSpace:[NSColorSpace deviceRGBColorSpace]] getRed:&r green:&g blue:&b alpha:&a]; 24 | *even = wxColour((uchar) (r * 255.0f), (uchar) (g * 255.0f), (uchar) (b * 255.0f), (uchar) (a * 255.0f)); 25 | [[[colors objectAtIndex:1] colorUsingColorSpace:[NSColorSpace deviceRGBColorSpace]] getRed:&r green:&g blue:&b alpha:&a]; 26 | *odd = wxColour((uchar) (r * 255.0f), (uchar) (g * 255.0f), (uchar) (b * 255.0f), (uchar) (a * 255.0f)); 27 | } 28 | } 29 | 30 | // end of altrace_wx_cocoa.mm ... 31 | 32 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # alTrace; a debugging tool for OpenAL. 2 | # 3 | # Please see the file LICENSE.txt in the source's root directory. 4 | # 5 | # This file written by Ryan C. Gordon. 6 | 7 | cmake_minimum_required(VERSION 2.8) 8 | project(alTrace) 9 | 10 | include_directories(.) 11 | 12 | add_library(altrace_record SHARED 13 | altrace_record.c 14 | altrace_common.c 15 | ) 16 | set_target_properties(altrace_record PROPERTIES C_VISIBILITY_PRESET hidden) 17 | target_link_libraries(altrace_record dl) 18 | install(TARGETS altrace_record LIBRARY DESTINATION lib) 19 | 20 | add_executable(altrace_cli 21 | altrace_cli.c 22 | altrace_playback.c 23 | altrace_common.c 24 | ) 25 | target_link_libraries(altrace_cli dl) 26 | install(TARGETS altrace_cli RUNTIME DESTINATION bin) 27 | 28 | option(ALTRACE_WX "Build wxWidgets-based GUI" TRUE) 29 | if(ALTRACE_WX) 30 | set(wxWidgets_USE_LIBS base core adv html) 31 | set(wxWidgets_INCLUDE_DIRS_NO_SYSTEM 1) 32 | find_package(wxWidgets) 33 | if(wxWidgets_FOUND) 34 | if(APPLE) 35 | set(ALTRACE_WX_COCOA_SRCS altrace_wx_cocoa.mm) 36 | endif() 37 | add_executable(altrace_wx 38 | altrace_wx.cpp 39 | altrace_playback.c 40 | altrace_common.c 41 | messageboxex.cpp 42 | ${ALTRACE_WX_COCOA_SRCS} 43 | ) 44 | include(${wxWidgets_USE_FILE}) 45 | target_link_libraries(altrace_wx "dl;${wxWidgets_LIBRARIES}") 46 | install(TARGETS altrace_wx RUNTIME DESTINATION bin) 47 | else() 48 | MESSAGE(STATUS "wxWidgets not found. GUI support is disabled.") 49 | endif() 50 | endif() 51 | 52 | # End of CMakeLists.txt ... 53 | 54 | -------------------------------------------------------------------------------- /alTrace-Mac-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleDisplayName 8 | alTrace 9 | CFBundleExecutable 10 | altrace_wx 11 | CFBundleIconFile 12 | alTrace.icns 13 | CFBundleIdentifier 14 | org.icculus.altrace 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | alTrace 19 | CFBundlePackageType 20 | APPL 21 | CFBundleShortVersionString 22 | 0.1 23 | CFBundleSignature 24 | ALtr 25 | CFBundleSupportedPlatforms 26 | 27 | MacOSX 28 | 29 | NSHighResolutionCapable 30 | 31 | NSSupportsAutomaticGraphicsSwitching 32 | 33 | CFBundleDocumentTypes 34 | 35 | 36 | CFBundleTypeExtensions 37 | 38 | altrace 39 | 40 | LSIsAppleDefaultForType 41 | 42 | LSTypeIsPackage 43 | 44 | CFBundleTypeName 45 | alTrace tracefile 46 | CFBundleTypeIconFile 47 | alTrace 48 | LSItemContentTypes 49 | 50 | org.icculus.altrace.tracefile 51 | 52 | CFBundleTypeRole 53 | Viewer 54 | NSDocumentClass 55 | AlTraceTracefileDocument 56 | 57 | 58 | UTExportedTypeDeclarations 59 | 60 | 61 | UTTypeIdentifier 62 | org.icculus.altrace.tracefile 63 | UTTypeConformsTo 64 | 65 | public.data 66 | 67 | UTTypeReferenceURL 68 | https://icculus.org/altrace/ 69 | UTTypeTagSpecification 70 | 71 | public.filename-extension 72 | 73 | altrace 74 | 75 | 76 | 77 | 78 | NSRequiresAquaSystemAppearance 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # alTrace 2 | 3 | This is a tool for debugging OpenAL applications and implementations. It 4 | lets you record, playback, and visualize an OpenAL call stream. 5 | 6 | 7 | # Quick start: 8 | 9 | - This work is funded by my Patreon! If you like it, 10 | [throw in a buck](https://patreon.com/icculus/)! 11 | - This is all brand new code, if something looks obviously broken it probably 12 | is. At this time, it definitely works on my computer, so feel free to 13 | come by and try it at my house if you have problems. 14 | - This works on macOS and Linux (and other Unix systems, probably). Windows 15 | is currently unsupported (but can be in the future!). 16 | - You'll need [CMake](https://cmake.org/) to build. If you want the GUI, 17 | you'll need [wxWidgets](https://wxwidgets.org/). The command line tools 18 | and trace recorder does not need wxWidgets. I built this with wxWidgets 3.0; 19 | if you're on macOS, you'll want to use at least 3.1 or Mojave's Dark Mode 20 | won't work. 21 | - Build the thing with CMake: 22 | ```sh 23 | cd altrace 24 | mkdir cmake-build 25 | cd cmake-build 26 | cmake -DCMAKE_BUILD_TYPE=Release .. 27 | make 28 | ``` 29 | - You'll end up with a libaltrace_record.so (or .dylib) file. Take that and 30 | make your game use it. It's a drop-in replacement for your usual OpenAL 31 | library, so either link against it directly, or dlopen it, or force it 32 | to load over the usual OpenAL with LD_PRELOAD. 33 | - When your game runs, alTrace will write out a tracefile (something like 34 | `MyExecutableName.altrace`, or `*.1.altrace`, `*.2.altrace`, etc). Any 35 | time your game talks to OpenAL, the details are logged to the tracefile. 36 | - When you're done, quit your game. 37 | - You can see the list of OpenAL calls made by your game and their results 38 | with the command line tool: 39 | ```sh 40 | altrace_cli MyGameName.altrace 41 | ``` 42 | - Want to see _everything_ we recorded, including state changes and OpenAL 43 | errors and such? Try --dump-all ... 44 | ```sh 45 | altrace_cli --dump-all MyGameName.altrace 46 | ``` 47 | - (there are other command lines to make this less of a firehose, if you only 48 | want some specific pieces of information. Run altrace_cli with no arguments 49 | to see the list.) 50 | - Want to _replay_ the tracefile? This will run the same function calls back 51 | through OpenAL (possibly a different OpenAL implementation, if you're into 52 | that sort of thing). This is useful if you want to debug OpenAL itself and 53 | want to ditch all the game logic and get a reproduction case: just run 54 | altrace_cli under a debugger. :) Otherwise, someone can send you a 55 | tracefile when your game, unrelated to the OpenAL implementation, got into 56 | a weird state and you want to hear what happened. 57 | ```sh 58 | altrace_cli --run MyGameName.altrace 59 | ``` 60 | - If you built altrace_wx, you can run that for a GUI that lets you visualize 61 | the data: 62 | ```sh 63 | altrace_wx MyGameName.altrace 64 | ``` 65 | - Need more clarity into the data? alTrace exposes an OpenAL extension that 66 | lets you label objects, annotate the stream of function calls, and group 67 | sections of calls together, so your app can cooperate to make the 68 | information more user-friendly. 69 | - Future plans: support for more OpenAL extensions (mostly this is just core 70 | OpenAL 1.1 right now), Windows support, more features in the GUI, more 71 | help on tracking down problems, etc. 72 | - Questions? Bug reports? Hit me up: icculus@icculus.org 73 | 74 | Thanks! 75 | 76 | --ryan. 77 | 78 | -------------------------------------------------------------------------------- /altrace_playback.h: -------------------------------------------------------------------------------- 1 | /** 2 | * alTrace; a debugging tool for OpenAL. 3 | * 4 | * Please see the file LICENSE.txt in the source's root directory. 5 | * 6 | * This file written by Ryan C. Gordon. 7 | */ 8 | 9 | #ifndef _INCL_ALTRACE_PLAYBACK_H_ 10 | #define _INCL_ALTRACE_PLAYBACK_H_ 11 | 12 | #include "altrace_common.h" 13 | 14 | // We assume we can cast the 64-bit values in the tracefile into pointers. 15 | // It's my (untested) belief that you can record on a 32-bit platform and 16 | // play it back on a 64-bit system, but not the other way around. 17 | #ifndef __LP64__ 18 | #error This currently expects a 64-bit target. 32-bits unsupported. 19 | #endif 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | typedef struct CallstackFrame 26 | { 27 | void *frame; 28 | const char *sym; 29 | } CallstackFrame; 30 | 31 | typedef struct CallerInfo 32 | { 33 | CallstackFrame callstack[MAX_CALLSTACKS]; 34 | int num_callstack_frames; 35 | int numargs; 36 | uint32 threadid; 37 | uint32 trace_scope; 38 | uint32 wait_until; 39 | off_t fdoffset; 40 | void *userdata; 41 | } CallerInfo; 42 | 43 | MAP_DECL(device, ALCdevice *, ALCdevice *); 44 | MAP_DECL(context, ALCcontext *, ALCcontext *); 45 | MAP_DECL(devicelabel, ALCdevice *, char *); 46 | MAP_DECL(contextlabel, ALCcontext *, char *); 47 | MAP_DECL(source, ALuint, ALuint); 48 | MAP_DECL(buffer, ALuint, ALuint); 49 | MAP_DECL(sourcelabel, ALuint, char *); 50 | MAP_DECL(bufferlabel, ALuint, char *); 51 | MAP_DECL(stackframe, void *, char *); 52 | MAP_DECL(threadid, uint64, uint32); 53 | 54 | #define ENTRYPOINT(ret,name,params,args,numargs,visitparams,visitargs) void visit_##name visitparams; 55 | #include "altrace_entrypoints.h" 56 | 57 | void visit_al_error_event(void *userdata, const ALenum err); 58 | void visit_alc_error_event(void *userdata, ALCdevice *device, const ALCenum err); 59 | void visit_device_state_changed_int(void *userdata, ALCdevice *dev, const ALCenum param, const ALCint newval); 60 | void visit_context_state_changed_enum(void *userdata, ALCcontext *ctx, const ALenum param, const ALenum newval); 61 | void visit_context_state_changed_float(void *userdata, ALCcontext *ctx, const ALenum param, const ALfloat newval); 62 | void visit_context_state_changed_string(void *userdata, ALCcontext *ctx, const ALenum param, const ALchar *str); 63 | void visit_listener_state_changed_floatv(void *userdata, ALCcontext *ctx, const ALenum param, const uint32 numfloats, const ALfloat *values); 64 | void visit_source_state_changed_bool(void *userdata, const ALuint name, const ALenum param, const ALboolean newval); 65 | void visit_source_state_changed_enum(void *userdata, const ALuint name, const ALenum param, const ALenum newval); 66 | void visit_source_state_changed_int(void *userdata, const ALuint name, const ALenum param, const ALint newval); 67 | void visit_source_state_changed_uint(void *userdata, const ALuint name, const ALenum param, const ALuint newval); 68 | void visit_source_state_changed_float(void *userdata, const ALuint name, const ALenum param, const ALfloat newval); 69 | void visit_source_state_changed_float3(void *userdata, const ALuint name, const ALenum param, const ALfloat newval1, const ALfloat newval2, const ALfloat newval3); 70 | void visit_buffer_state_changed_int(void *userdata, const ALuint name, const ALenum param, const ALint newval); 71 | void visit_eos(void *userdata, const ALboolean okay, const uint32 wait_until); 72 | int visit_progress(void *userdata, const off_t current, const off_t total); 73 | 74 | const char *alcboolString(const ALCboolean x); 75 | const char *alboolString(const ALCboolean x); 76 | const char *alcenumString(const ALCenum x); 77 | const char *alenumString(const ALCenum x); 78 | const char *litString(const char *str); 79 | const char *ptrString(const void *ptr); 80 | const char *ctxString(ALCcontext *ctx); 81 | const char *deviceString(ALCdevice *device); 82 | const char *sourceString(const ALuint name); 83 | const char *bufferString(const ALuint name); 84 | 85 | int process_tracelog(const char *filename, void *userdata); 86 | 87 | #ifdef __cplusplus 88 | } 89 | #endif 90 | 91 | #endif 92 | 93 | // end of altrace_playback.h ... 94 | 95 | -------------------------------------------------------------------------------- /messageboxex.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////// 2 | // Name: messageboxex.h 3 | // Purpose: 4 | // Author: Julian Smart 5 | // Modified by: 6 | // Created: 12/11/05 13:05:56 7 | // RCS-ID: 8 | // Copyright: (c) Julian Smart, Anthemion Software Ltd 9 | // Licence: 10 | ///////////////////////////////////////////////////////////////////////////// 11 | 12 | #ifndef _MESSAGEBOXEX_H_ 13 | #define _MESSAGEBOXEX_H_ 14 | 15 | #if defined(__GNUG__) && !defined(__APPLE__) 16 | #pragma interface "messageboxex.cpp" 17 | #endif 18 | 19 | /*! 20 | * Includes 21 | */ 22 | 23 | ////@begin includes 24 | #include "wx/valgen.h" 25 | ////@end includes 26 | 27 | /*! 28 | * Forward declarations 29 | */ 30 | 31 | ////@begin forward declarations 32 | ////@end forward declarations 33 | 34 | /*! 35 | * Control identifiers 36 | */ 37 | 38 | ////@begin control identifiers 39 | #define ID_MESSAGEDIALOGEX 24900 40 | #define SYMBOL_WXMESSAGEDIALOGEX_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX 41 | #define SYMBOL_WXMESSAGEDIALOGEX_TITLE _("Message") 42 | #define SYMBOL_WXMESSAGEDIALOGEX_IDNAME ID_MESSAGEDIALOGEX 43 | #define SYMBOL_WXMESSAGEDIALOGEX_SIZE wxSize(400, 300) 44 | #define SYMBOL_WXMESSAGEDIALOGEX_POSITION wxDefaultPosition 45 | #define ID_MESSAGEDIALOGEX_DISPLAY_NEXT_TIME 24901 46 | ////@end control identifiers 47 | 48 | #define wxYES_TO_ALL 0x00100000 49 | #define wxNO_TO_ALL 0x00200000 50 | #define wxDISPLAY_NEXT_TIME 0x00400000 51 | 52 | /*! 53 | * Compatibility 54 | */ 55 | 56 | #ifndef wxCLOSE_BOX 57 | #define wxCLOSE_BOX 0x1000 58 | #endif 59 | 60 | /*! 61 | * wxMessageDialogEx class declaration 62 | */ 63 | 64 | class wxMessageDialogEx: public wxDialog 65 | { 66 | DECLARE_DYNAMIC_CLASS( wxMessageDialogEx ) 67 | DECLARE_EVENT_TABLE() 68 | 69 | public: 70 | /// Constructors 71 | wxMessageDialogEx( ); 72 | wxMessageDialogEx( wxWindow* parent, const wxString& message, const wxString& caption = _("Message"), int style = wxOK, const wxPoint& pos = wxDefaultPosition ); 73 | 74 | /// Creation 75 | bool Create( wxWindow* parent, const wxString& message, const wxString& caption = _("Message"), int style = wxOK, const wxPoint& pos = wxDefaultPosition ); 76 | 77 | /// Creates the controls and sizers 78 | void CreateControls(); 79 | 80 | ////@begin wxMessageDialogEx event handler declarations 81 | 82 | /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_YES 83 | void OnYesClick( wxCommandEvent& event ); 84 | 85 | /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_YESTOALL 86 | void OnYestoallClick( wxCommandEvent& event ); 87 | 88 | /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_NO 89 | void OnNoClick( wxCommandEvent& event ); 90 | 91 | /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_NOTOALL 92 | void OnNotoallClick( wxCommandEvent& event ); 93 | 94 | /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK 95 | void OnOkClick( wxCommandEvent& event ); 96 | 97 | /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL 98 | void OnCancelClick( wxCommandEvent& event ); 99 | 100 | ////@end wxMessageDialogEx event handler declarations 101 | 102 | ////@begin wxMessageDialogEx member function declarations 103 | 104 | wxString GetMessage() const { return m_message ; } 105 | void SetMessage(wxString value) { m_message = value ; } 106 | 107 | int GetMessageDialogStyle() const { return m_messageDialogStyle ; } 108 | void SetMessageDialogStyle(int value) { m_messageDialogStyle = value ; } 109 | 110 | bool GetDisplayNextTime() const { return m_displayNextTime ; } 111 | void SetDisplayNextTime(bool value) { m_displayNextTime = value ; } 112 | 113 | /// Retrieves bitmap resources 114 | //wxBitmap GetBitmapResource( const wxString& name ); 115 | 116 | /// Retrieves icon resources 117 | wxIcon GetIconResource( const wxString& name ); 118 | ////@end wxMessageDialogEx member function declarations 119 | 120 | /// Should we show tooltips? 121 | static bool ShowToolTips(); 122 | 123 | ////@begin wxMessageDialogEx member variables 124 | //wxStaticBitmap* m_staticBitmap; 125 | wxString m_message; 126 | int m_messageDialogStyle; 127 | bool m_displayNextTime; 128 | ////@end wxMessageDialogEx member variables 129 | }; 130 | 131 | // Convenience dialog 132 | int wxMessageBoxEx(const wxString& msg, const wxString& caption = _("Message"), int style = wxOK, wxWindow* parent = NULL); 133 | 134 | #endif 135 | // _MESSAGEBOXEX_H_ 136 | -------------------------------------------------------------------------------- /altrace_common.h: -------------------------------------------------------------------------------- 1 | /** 2 | * alTrace; a debugging tool for OpenAL. 3 | * 4 | * Please see the file LICENSE.txt in the source's root directory. 5 | * 6 | * This file written by Ryan C. Gordon. 7 | */ 8 | 9 | #ifndef _INCL_ALTRACE_COMMON_H_ 10 | #define _INCL_ALTRACE_COMMON_H_ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include "AL/al.h" 29 | #include "AL/alc.h" 30 | 31 | #define ALTRACE_VERSION "0.0.1" 32 | 33 | #define ALTRACE_LOG_FILE_MAGIC 0x0104E5A1 34 | #define ALTRACE_LOG_FILE_FORMAT 1 35 | 36 | /* AL_EXT_FLOAT32 support... */ 37 | #ifndef AL_FORMAT_MONO_FLOAT32 38 | #define AL_FORMAT_MONO_FLOAT32 0x10010 39 | #endif 40 | 41 | #ifndef AL_FORMAT_STEREO_FLOAT32 42 | #define AL_FORMAT_STEREO_FLOAT32 0x10011 43 | #endif 44 | 45 | /* ALC_EXT_DISCONNECTED support... */ 46 | #ifndef ALC_CONNECTED 47 | #define ALC_CONNECTED 0x313 48 | #endif 49 | 50 | #ifdef __cplusplus 51 | extern "C" { 52 | #endif 53 | 54 | // to be filled in by apps. 55 | extern const char *GAppName; 56 | 57 | typedef uint8_t uint8; 58 | typedef int16_t int16; 59 | typedef int32_t int32; 60 | typedef uint32_t uint32; 61 | typedef uint64_t uint64; 62 | typedef unsigned int uint; 63 | 64 | #if defined(__clang__) || defined(__GNUC__) 65 | #define NORETURN __attribute__((noreturn)) 66 | #else 67 | #define NORETURN 68 | #endif 69 | 70 | #ifdef __linux__ 71 | # include 72 | # if __BYTE_ORDER == 4321 73 | # define BIGENDIAN 1 74 | # endif 75 | #elif defined(__hppa__) || defined(__m68k__) || defined(mc68000) || \ 76 | defined(_M_M68K) || (defined(__MIPS__) && defined(__MISPEB__)) || \ 77 | defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || \ 78 | defined(__sparc__) 79 | # define BIGENDIAN 1 80 | #endif 81 | 82 | #ifdef BIGENDIAN 83 | static uint32 swap32(const uint32 x) 84 | { 85 | return (uint32) ( (x << 24) | ((x << 8) & 0x00FF0000) | 86 | ((x >> 8) & 0x0000FF00) | (x >> 24) ); 87 | } 88 | 89 | static uint64 swap64(uint64 x) 90 | { 91 | uint32 hi, lo; 92 | lo = (Uint32) (x & 0xFFFFFFFF); 93 | x >>= 32; 94 | hi = (Uint32) (x & 0xFFFFFFFF); 95 | x = swap32(lo); 96 | x <<= 32; 97 | x |= swap32(hi); 98 | return x; 99 | } 100 | #else 101 | #define swap32(x) (x) 102 | #define swap64(x) (x) 103 | #endif 104 | 105 | #define MAX_CALLSTACKS 32 106 | 107 | typedef enum 108 | { 109 | ALEE_EOS, 110 | ALEE_ALERROR_TRIGGERED, 111 | ALEE_ALCERROR_TRIGGERED, 112 | ALEE_NEW_CALLSTACK_SYMS, 113 | ALEE_DEVICE_STATE_CHANGED_BOOL, 114 | ALEE_DEVICE_STATE_CHANGED_INT, 115 | ALEE_CONTEXT_STATE_CHANGED_ENUM, 116 | ALEE_CONTEXT_STATE_CHANGED_FLOAT, 117 | ALEE_CONTEXT_STATE_CHANGED_STRING, 118 | ALEE_LISTENER_STATE_CHANGED_FLOATV, 119 | ALEE_SOURCE_STATE_CHANGED_BOOL, 120 | ALEE_SOURCE_STATE_CHANGED_ENUM, 121 | ALEE_SOURCE_STATE_CHANGED_INT, 122 | ALEE_SOURCE_STATE_CHANGED_UINT, 123 | ALEE_SOURCE_STATE_CHANGED_FLOAT, 124 | ALEE_SOURCE_STATE_CHANGED_FLOAT3, 125 | ALEE_BUFFER_STATE_CHANGED_INT, 126 | #define ENTRYPOINT(ret,name,params,args,numargs,visitparams,visitargs) ALEE_##name, 127 | #include "altrace_entrypoints.h" 128 | ALEE_MAX 129 | } EventEnum; 130 | 131 | 132 | #define ENTRYPOINT(ret,name,params,args,numargs,visitparams,visitargs) extern ret (*REAL_##name) params; 133 | #include "altrace_entrypoints.h" 134 | 135 | void *get_ioblob(const size_t len); 136 | void free_ioblobs(void); 137 | __attribute__((noreturn)) void out_of_memory(void); 138 | char *sprintf_alloc(const char *fmt, ...); 139 | uint32 now(void); 140 | int init_clock(void); 141 | int load_real_openal(void); 142 | void close_real_openal(void); 143 | 144 | typedef struct StringCache StringCache; 145 | const char *stringcache(StringCache *cache, const char *str); 146 | StringCache *stringcache_create(void); 147 | void stringcache_destroy(StringCache *cache); 148 | 149 | #ifdef __cplusplus 150 | } 151 | #endif 152 | 153 | #define MAP_DECL(maptype, fromctype, toctype) \ 154 | void add_##maptype##_to_map(fromctype from, toctype to); \ 155 | toctype get_mapped_##maptype(fromctype from); \ 156 | void free_##maptype##_map(void) 157 | 158 | #define SIMPLE_MAP(maptype, fromctype, toctype) \ 159 | typedef struct SimpleMap_##maptype { \ 160 | fromctype from; \ 161 | toctype to; \ 162 | } SimpleMap_##maptype; \ 163 | static SimpleMap_##maptype *simplemap_##maptype = NULL; \ 164 | static uint32 simplemap_##maptype##_map_size = 0; \ 165 | void add_##maptype##_to_map(fromctype from, toctype to) { \ 166 | void *ptr; uint32 i; \ 167 | for (i = 0; i < simplemap_##maptype##_map_size; i++) { \ 168 | if (simplemap_##maptype[i].from == from) { \ 169 | free_hash_item_##maptype(simplemap_##maptype[i].from, simplemap_##maptype[i].to); \ 170 | simplemap_##maptype[i].from = from; \ 171 | simplemap_##maptype[i].to = to; \ 172 | return; \ 173 | } \ 174 | } \ 175 | ptr = realloc(simplemap_##maptype, (simplemap_##maptype##_map_size + 1) * sizeof (SimpleMap_##maptype)); \ 176 | if (!ptr) { \ 177 | out_of_memory(); \ 178 | } \ 179 | simplemap_##maptype = (SimpleMap_##maptype *) ptr; \ 180 | simplemap_##maptype[simplemap_##maptype##_map_size].from = from; \ 181 | simplemap_##maptype[simplemap_##maptype##_map_size].to = to; \ 182 | simplemap_##maptype##_map_size++; \ 183 | } \ 184 | toctype get_mapped_##maptype(fromctype from) { \ 185 | uint32 i; \ 186 | for (i = 0; i < simplemap_##maptype##_map_size; i++) { \ 187 | if (simplemap_##maptype[i].from == from) { \ 188 | return simplemap_##maptype[i].to; \ 189 | } \ 190 | } \ 191 | return (toctype) 0; \ 192 | } \ 193 | void free_##maptype##_map(void) { \ 194 | uint32 i; \ 195 | for (i = 0; i < simplemap_##maptype##_map_size; i++) { \ 196 | SimpleMap_##maptype *item = &simplemap_##maptype[i]; \ 197 | free_hash_item_##maptype(item->from, item->to); \ 198 | } \ 199 | free(simplemap_##maptype); \ 200 | simplemap_##maptype = NULL; \ 201 | simplemap_##maptype##_map_size = 0; \ 202 | } 203 | 204 | 205 | #define HASH_MAP(maptype, fromctype, toctype) \ 206 | typedef struct HashMap_##maptype { \ 207 | fromctype from; \ 208 | toctype to; \ 209 | struct HashMap_##maptype *next; \ 210 | } HashMap_##maptype; \ 211 | static HashMap_##maptype *hashmap_##maptype[256]; \ 212 | static HashMap_##maptype *get_hashitem_##maptype(fromctype from, uint8 *_hash) { \ 213 | const uint8 hash = hash_##maptype(from); \ 214 | HashMap_##maptype *prev = NULL; \ 215 | HashMap_##maptype *item = hashmap_##maptype[hash]; \ 216 | if (_hash) { *_hash = hash; } \ 217 | while (item) { \ 218 | if (item->from == from) { \ 219 | if (prev) { /* move to front of list */ \ 220 | prev->next = item->next; \ 221 | item->next = hashmap_##maptype[hash]; \ 222 | hashmap_##maptype[hash] = item; \ 223 | } \ 224 | return item; \ 225 | } \ 226 | prev = item; \ 227 | item = item->next; \ 228 | } \ 229 | return NULL; \ 230 | } \ 231 | void add_##maptype##_to_map(fromctype from, toctype to) { \ 232 | uint8 hash; HashMap_##maptype *item = get_hashitem_##maptype(from, &hash); \ 233 | if (item) { \ 234 | free_hash_item_##maptype(item->from, item->to); \ 235 | item->from = from; \ 236 | item->to = to; \ 237 | } else { \ 238 | item = (HashMap_##maptype *) calloc(1, sizeof (HashMap_##maptype)); \ 239 | if (!item) { \ 240 | out_of_memory(); \ 241 | } \ 242 | item->from = from; \ 243 | item->to = to; \ 244 | item->next = hashmap_##maptype[hash]; \ 245 | hashmap_##maptype[hash] = item; \ 246 | } \ 247 | } \ 248 | toctype get_mapped_##maptype(fromctype from) { \ 249 | HashMap_##maptype *item = get_hashitem_##maptype(from, NULL); \ 250 | return item ? item->to : (toctype) 0; \ 251 | } \ 252 | void free_##maptype##_map(void) { \ 253 | int i; \ 254 | for (i = 0; i < 256; i++) { \ 255 | HashMap_##maptype *item; HashMap_##maptype *next; \ 256 | for (item = hashmap_##maptype[i]; item; item = next) { \ 257 | free_hash_item_##maptype(item->from, item->to); \ 258 | next = item->next; \ 259 | free(item); \ 260 | } \ 261 | hashmap_##maptype[i] = NULL; \ 262 | } \ 263 | } 264 | 265 | #endif 266 | 267 | // end of altrace_common.h ... 268 | 269 | -------------------------------------------------------------------------------- /AL/alc.h: -------------------------------------------------------------------------------- 1 | #ifndef AL_ALC_H 2 | #define AL_ALC_H 3 | 4 | #if defined(__cplusplus) 5 | extern "C" { 6 | #endif 7 | 8 | #ifndef ALC_API 9 | #if defined(AL_LIBTYPE_STATIC) 10 | #define ALC_API 11 | #elif defined(_WIN32) 12 | #define ALC_API __declspec(dllimport) 13 | #else 14 | #define ALC_API extern 15 | #endif 16 | #endif 17 | 18 | #if defined(_WIN32) 19 | #define ALC_APIENTRY __cdecl 20 | #else 21 | #define ALC_APIENTRY 22 | #endif 23 | 24 | 25 | /** Deprecated macro. */ 26 | #define ALCAPI ALC_API 27 | #define ALCAPIENTRY ALC_APIENTRY 28 | #define ALC_INVALID 0 29 | 30 | /** Supported ALC version? */ 31 | #define ALC_VERSION_0_1 1 32 | 33 | /** Opaque device handle */ 34 | typedef struct ALCdevice_struct ALCdevice; 35 | /** Opaque context handle */ 36 | typedef struct ALCcontext_struct ALCcontext; 37 | 38 | /** 8-bit boolean */ 39 | typedef char ALCboolean; 40 | 41 | /** character */ 42 | typedef char ALCchar; 43 | 44 | /** signed 8-bit 2's complement integer */ 45 | typedef signed char ALCbyte; 46 | 47 | /** unsigned 8-bit integer */ 48 | typedef unsigned char ALCubyte; 49 | 50 | /** signed 16-bit 2's complement integer */ 51 | typedef short ALCshort; 52 | 53 | /** unsigned 16-bit integer */ 54 | typedef unsigned short ALCushort; 55 | 56 | /** signed 32-bit 2's complement integer */ 57 | typedef int ALCint; 58 | 59 | /** unsigned 32-bit integer */ 60 | typedef unsigned int ALCuint; 61 | 62 | /** non-negative 32-bit binary integer size */ 63 | typedef int ALCsizei; 64 | 65 | /** enumerated 32-bit value */ 66 | typedef int ALCenum; 67 | 68 | /** 32-bit IEEE754 floating-point */ 69 | typedef float ALCfloat; 70 | 71 | /** 64-bit IEEE754 floating-point */ 72 | typedef double ALCdouble; 73 | 74 | /** void type (for opaque pointers only) */ 75 | typedef void ALCvoid; 76 | 77 | 78 | /* Enumerant values begin at column 50. No tabs. */ 79 | 80 | /** Boolean False. */ 81 | #define ALC_FALSE 0 82 | 83 | /** Boolean True. */ 84 | #define ALC_TRUE 1 85 | 86 | /** Context attribute: Hz. */ 87 | #define ALC_FREQUENCY 0x1007 88 | 89 | /** Context attribute: Hz. */ 90 | #define ALC_REFRESH 0x1008 91 | 92 | /** Context attribute: AL_TRUE or AL_FALSE. */ 93 | #define ALC_SYNC 0x1009 94 | 95 | /** Context attribute: requested Mono (3D) Sources. */ 96 | #define ALC_MONO_SOURCES 0x1010 97 | 98 | /** Context attribute: requested Stereo Sources. */ 99 | #define ALC_STEREO_SOURCES 0x1011 100 | 101 | /** No error. */ 102 | #define ALC_NO_ERROR 0 103 | 104 | /** Invalid device handle. */ 105 | #define ALC_INVALID_DEVICE 0xA001 106 | 107 | /** Invalid context handle. */ 108 | #define ALC_INVALID_CONTEXT 0xA002 109 | 110 | /** Invalid enum parameter passed to an ALC call. */ 111 | #define ALC_INVALID_ENUM 0xA003 112 | 113 | /** Invalid value parameter passed to an ALC call. */ 114 | #define ALC_INVALID_VALUE 0xA004 115 | 116 | /** Out of memory. */ 117 | #define ALC_OUT_OF_MEMORY 0xA005 118 | 119 | 120 | /** Runtime ALC version. */ 121 | #define ALC_MAJOR_VERSION 0x1000 122 | #define ALC_MINOR_VERSION 0x1001 123 | 124 | /** Context attribute list properties. */ 125 | #define ALC_ATTRIBUTES_SIZE 0x1002 126 | #define ALC_ALL_ATTRIBUTES 0x1003 127 | 128 | /** String for the default device specifier. */ 129 | #define ALC_DEFAULT_DEVICE_SPECIFIER 0x1004 130 | /** 131 | * String for the given device's specifier. 132 | * 133 | * If device handle is NULL, it is instead a null-char separated list of 134 | * strings of known device specifiers (list ends with an empty string). 135 | */ 136 | #define ALC_DEVICE_SPECIFIER 0x1005 137 | /** String for space-separated list of ALC extensions. */ 138 | #define ALC_EXTENSIONS 0x1006 139 | 140 | 141 | /** Capture extension */ 142 | #define ALC_EXT_CAPTURE 1 143 | /** 144 | * String for the given capture device's specifier. 145 | * 146 | * If device handle is NULL, it is instead a null-char separated list of 147 | * strings of known capture device specifiers (list ends with an empty string). 148 | */ 149 | #define ALC_CAPTURE_DEVICE_SPECIFIER 0x310 150 | /** String for the default capture device specifier. */ 151 | #define ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER 0x311 152 | /** Number of sample frames available for capture. */ 153 | #define ALC_CAPTURE_SAMPLES 0x312 154 | 155 | 156 | /** Enumerate All extension */ 157 | #define ALC_ENUMERATE_ALL_EXT 1 158 | /** String for the default extended device specifier. */ 159 | #define ALC_DEFAULT_ALL_DEVICES_SPECIFIER 0x1012 160 | /** 161 | * String for the given extended device's specifier. 162 | * 163 | * If device handle is NULL, it is instead a null-char separated list of 164 | * strings of known extended device specifiers (list ends with an empty string). 165 | */ 166 | #define ALC_ALL_DEVICES_SPECIFIER 0x1013 167 | 168 | 169 | /** Context management. */ 170 | ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCint* attrlist); 171 | ALC_API ALCboolean ALC_APIENTRY alcMakeContextCurrent(ALCcontext *context); 172 | ALC_API void ALC_APIENTRY alcProcessContext(ALCcontext *context); 173 | ALC_API void ALC_APIENTRY alcSuspendContext(ALCcontext *context); 174 | ALC_API void ALC_APIENTRY alcDestroyContext(ALCcontext *context); 175 | ALC_API ALCcontext* ALC_APIENTRY alcGetCurrentContext(void); 176 | ALC_API ALCdevice* ALC_APIENTRY alcGetContextsDevice(ALCcontext *context); 177 | 178 | /** Device management. */ 179 | ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *devicename); 180 | ALC_API ALCboolean ALC_APIENTRY alcCloseDevice(ALCdevice *device); 181 | 182 | 183 | /** 184 | * Error support. 185 | * 186 | * Obtain the most recent Device error. 187 | */ 188 | ALC_API ALCenum ALC_APIENTRY alcGetError(ALCdevice *device); 189 | 190 | /** 191 | * Extension support. 192 | * 193 | * Query for the presence of an extension, and obtain any appropriate 194 | * function pointers and enum values. 195 | */ 196 | ALC_API ALCboolean ALC_APIENTRY alcIsExtensionPresent(ALCdevice *device, const ALCchar *extname); 197 | ALC_API void* ALC_APIENTRY alcGetProcAddress(ALCdevice *device, const ALCchar *funcname); 198 | ALC_API ALCenum ALC_APIENTRY alcGetEnumValue(ALCdevice *device, const ALCchar *enumname); 199 | 200 | /** Query function. */ 201 | ALC_API const ALCchar* ALC_APIENTRY alcGetString(ALCdevice *device, ALCenum param); 202 | ALC_API void ALC_APIENTRY alcGetIntegerv(ALCdevice *device, ALCenum param, ALCsizei size, ALCint *values); 203 | 204 | /** Capture function. */ 205 | ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize); 206 | ALC_API ALCboolean ALC_APIENTRY alcCaptureCloseDevice(ALCdevice *device); 207 | ALC_API void ALC_APIENTRY alcCaptureStart(ALCdevice *device); 208 | ALC_API void ALC_APIENTRY alcCaptureStop(ALCdevice *device); 209 | ALC_API void ALC_APIENTRY alcCaptureSamples(ALCdevice *device, ALCvoid *buffer, ALCsizei samples); 210 | 211 | /** Pointer-to-function type, useful for dynamically getting ALC entry points. */ 212 | typedef ALCcontext* (ALC_APIENTRY *LPALCCREATECONTEXT)(ALCdevice *device, const ALCint *attrlist); 213 | typedef ALCboolean (ALC_APIENTRY *LPALCMAKECONTEXTCURRENT)(ALCcontext *context); 214 | typedef void (ALC_APIENTRY *LPALCPROCESSCONTEXT)(ALCcontext *context); 215 | typedef void (ALC_APIENTRY *LPALCSUSPENDCONTEXT)(ALCcontext *context); 216 | typedef void (ALC_APIENTRY *LPALCDESTROYCONTEXT)(ALCcontext *context); 217 | typedef ALCcontext* (ALC_APIENTRY *LPALCGETCURRENTCONTEXT)(void); 218 | typedef ALCdevice* (ALC_APIENTRY *LPALCGETCONTEXTSDEVICE)(ALCcontext *context); 219 | typedef ALCdevice* (ALC_APIENTRY *LPALCOPENDEVICE)(const ALCchar *devicename); 220 | typedef ALCboolean (ALC_APIENTRY *LPALCCLOSEDEVICE)(ALCdevice *device); 221 | typedef ALCenum (ALC_APIENTRY *LPALCGETERROR)(ALCdevice *device); 222 | typedef ALCboolean (ALC_APIENTRY *LPALCISEXTENSIONPRESENT)(ALCdevice *device, const ALCchar *extname); 223 | typedef void* (ALC_APIENTRY *LPALCGETPROCADDRESS)(ALCdevice *device, const ALCchar *funcname); 224 | typedef ALCenum (ALC_APIENTRY *LPALCGETENUMVALUE)(ALCdevice *device, const ALCchar *enumname); 225 | typedef const ALCchar* (ALC_APIENTRY *LPALCGETSTRING)(ALCdevice *device, ALCenum param); 226 | typedef void (ALC_APIENTRY *LPALCGETINTEGERV)(ALCdevice *device, ALCenum param, ALCsizei size, ALCint *values); 227 | typedef ALCdevice* (ALC_APIENTRY *LPALCCAPTUREOPENDEVICE)(const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize); 228 | typedef ALCboolean (ALC_APIENTRY *LPALCCAPTURECLOSEDEVICE)(ALCdevice *device); 229 | typedef void (ALC_APIENTRY *LPALCCAPTURESTART)(ALCdevice *device); 230 | typedef void (ALC_APIENTRY *LPALCCAPTURESTOP)(ALCdevice *device); 231 | typedef void (ALC_APIENTRY *LPALCCAPTURESAMPLES)(ALCdevice *device, ALCvoid *buffer, ALCsizei samples); 232 | 233 | #define ALC_EXT_TRACE_INFO 1 234 | typedef void (AL_APIENTRY *LPALCTRACEDEVICELABEL)(ALCdevice *device, const ALCchar *str); 235 | typedef void (AL_APIENTRY *LPALCTRACECONTEXTLABEL)(ALCcontext *ctx, const ALCchar *str); 236 | 237 | #if defined(__cplusplus) 238 | } 239 | #endif 240 | 241 | #endif /* AL_ALC_H */ 242 | -------------------------------------------------------------------------------- /altrace_common.c: -------------------------------------------------------------------------------- 1 | /** 2 | * alTrace; a debugging tool for OpenAL. 3 | * 4 | * Please see the file LICENSE.txt in the source's root directory. 5 | * 6 | * This file written by Ryan C. Gordon. 7 | */ 8 | 9 | #include "altrace_common.h" 10 | 11 | #define ENTRYPOINT(ret,name,params,args,numargs,visitparams,visitargs) ret (*REAL_##name) params = NULL; 12 | #include "altrace_entrypoints.h" 13 | 14 | 15 | #define MAX_IOBLOBS 256 16 | static uint8 *ioblobs[MAX_IOBLOBS]; 17 | static size_t ioblobs_len[MAX_IOBLOBS]; 18 | static int next_ioblob = 0; 19 | 20 | void *get_ioblob(const size_t len) 21 | { 22 | void *ptr = ioblobs[next_ioblob]; 23 | if (len > ioblobs_len[next_ioblob]) { 24 | //printf("allocating ioblob of %llu bytes...\n", (unsigned long long) len); 25 | ptr = realloc(ptr, len); 26 | if (!ptr) { 27 | out_of_memory(); 28 | } 29 | ioblobs[next_ioblob] = (uint8 *) ptr; 30 | ioblobs_len[next_ioblob] = len; 31 | } 32 | next_ioblob++; 33 | if (next_ioblob >= ((sizeof (ioblobs) / sizeof (ioblobs[0])))) { 34 | next_ioblob = 0; 35 | } 36 | return ptr; 37 | } 38 | 39 | void free_ioblobs(void) 40 | { 41 | size_t i; 42 | for (i = 0; i < (sizeof (ioblobs) / sizeof (ioblobs[0])); i++) { 43 | free(ioblobs[i]); 44 | ioblobs[i] = NULL; 45 | ioblobs_len[i] = 0; 46 | } 47 | next_ioblob = 0; 48 | } 49 | 50 | char *sprintf_alloc(const char *fmt, ...) 51 | { 52 | va_list ap; 53 | va_start(ap, fmt); 54 | const size_t len = vsnprintf(NULL, 0, fmt, ap); 55 | va_end(ap); 56 | 57 | char *retval = (char *) get_ioblob(len + 1); 58 | va_start(ap, fmt); 59 | if (vsnprintf(retval, len + 1, fmt, ap) != len) { 60 | retval = NULL; 61 | } 62 | va_end(ap); 63 | 64 | return retval; 65 | } 66 | 67 | 68 | static uint64 starttime = 0; 69 | 70 | uint32 now(void) 71 | { 72 | #ifdef __APPLE__ 73 | if (clock_gettime == NULL) { // not available until 10.12, use gettimeofday if necessary. 74 | struct timeval tv; 75 | if (gettimeofday(&tv, NULL) == -1) { 76 | fprintf(stderr, "%s: Failed to get current clock time: %s\n", GAppName, strerror(errno)); 77 | return 0; 78 | } 79 | return (uint32) ( ( (((uint64) tv.tv_sec) * 1000) + (((uint64) tv.tv_usec) / 1000) ) - starttime ); 80 | } 81 | #endif 82 | 83 | struct timespec ts; 84 | if (clock_gettime(CLOCK_MONOTONIC_RAW, &ts) == -1) { 85 | fprintf(stderr, "%s: Failed to get current clock time: %s\n", GAppName, strerror(errno)); 86 | return 0; 87 | } 88 | 89 | return (uint32) ( ( (((uint64) ts.tv_sec) * 1000) + (((uint64) ts.tv_nsec) / 1000000) ) - starttime ); 90 | } 91 | 92 | int init_clock(void) 93 | { 94 | #ifdef __APPLE__ 95 | if (clock_gettime == NULL) { // not available until 10.12, use gettimeofday if necessary. 96 | struct timeval tv; 97 | if (gettimeofday(&tv, NULL) == -1) { 98 | fprintf(stderr, "%s: Failed to get current clock time: %s\n", GAppName, strerror(errno)); 99 | return 0; 100 | } 101 | usleep(1000); // just so now() is (hopefully) never 0 102 | starttime = (((uint64) tv.tv_sec) * 1000) + (((uint64) tv.tv_usec) / 1000); 103 | return 1; 104 | } 105 | #endif 106 | 107 | struct timespec ts; 108 | if (clock_gettime(CLOCK_MONOTONIC_RAW, &ts) == -1) { 109 | fprintf(stderr, "%s: Failed to get current clock time: %s\n", GAppName, strerror(errno)); 110 | return 0; 111 | } 112 | usleep(1000); // just so now() is (hopefully) never 0 113 | 114 | starttime = (((uint64) ts.tv_sec) * 1000) + (((uint64) ts.tv_nsec) / 1000000); 115 | 116 | return 1; 117 | } 118 | 119 | static void *realdll = NULL; 120 | 121 | // !!! FIXME: we should use al[c]GetProcAddress() and do it _per device_ and 122 | // !!! FIXME: _per context_. 123 | static void *loadEntryPoint(void *dll, const char *fnname, const int extension, int *okay) 124 | { 125 | void *fn = dlsym(dll, fnname); 126 | if (!fn && !extension) { 127 | fprintf(stderr, "%s: Real OpenAL library doesn't have entry point '%s'!\n", GAppName, fnname); 128 | *okay = 0; 129 | } 130 | return fn; 131 | } 132 | 133 | int load_real_openal(void) 134 | { 135 | int extensions = 0; 136 | int okay = 1; 137 | #ifdef __APPLE__ 138 | const char *dllname = "libopenal.1.dylib"; 139 | #elif defined(_WIN32) 140 | const char *dllname = "openal32.dll"; 141 | #else 142 | const char *dllname = "libopenal.so.1"; 143 | #endif 144 | 145 | realdll = dlopen(dllname, RTLD_NOW | RTLD_LOCAL); 146 | if (!realdll) { 147 | fprintf(stderr, "%s: Failed to load %s: %s\n", GAppName, dllname, dlerror()); 148 | fflush(stderr); 149 | } 150 | 151 | if (!realdll) { 152 | // Not in the libpath? See if we can find it in the cwd. 153 | char *cwd = getcwd(NULL, 0); 154 | if (cwd) { 155 | const size_t fulllen = strlen(cwd) + strlen(dllname) + 2; 156 | char *fullpath = (char *) malloc(fulllen); 157 | if (fullpath) { 158 | snprintf(fullpath, fulllen, "%s/%s", cwd, dllname); 159 | realdll = dlopen(dllname, RTLD_NOW | RTLD_LOCAL); 160 | if (!realdll) { 161 | fprintf(stderr, "%s: Failed to load %s: %s\n", GAppName, fullpath, dlerror()); 162 | fflush(stderr); 163 | } 164 | free(fullpath); 165 | } 166 | free(cwd); 167 | } 168 | } 169 | 170 | if (!realdll) { 171 | fprintf(stderr, "%s: Couldn't load OpenAL from anywhere obvious. Giving up.\n", GAppName); 172 | fflush(stderr); 173 | return 0; 174 | } 175 | 176 | #define ENTRYPOINT_EXTENSIONS_BEGIN() extensions = 1; 177 | #define ENTRYPOINT(ret,name,params,args,numargs,visitparams,visitargs) REAL_##name = (ret (*)params) loadEntryPoint(realdll, #name, extensions, &okay); 178 | #include "altrace_entrypoints.h" 179 | return okay; 180 | } 181 | 182 | void close_real_openal(void) 183 | { 184 | void *dll = realdll; 185 | 186 | realdll = NULL; 187 | 188 | #define ENTRYPOINT(ret,name,params,args,numargs,visitparams,visitargs) REAL_##name = NULL; 189 | #include "altrace_entrypoints.h" 190 | 191 | if (dll) { 192 | dlclose(dll); 193 | } 194 | } 195 | 196 | 197 | // stole this from MojoShader: https://icculus.org/mojoshader 198 | // (I wrote this code, and it's zlib-licensed even if I didn't. --ryan.) 199 | typedef struct StringBucket 200 | { 201 | char *string; 202 | struct StringBucket *next; 203 | } StringBucket; 204 | 205 | struct StringCache 206 | { 207 | StringBucket **hashtable; 208 | uint32 table_size; 209 | void *d; 210 | }; 211 | 212 | static inline uint32 hash_string(const char *str, size_t len) 213 | { 214 | register uint32 hash = 5381; 215 | while (len--) 216 | hash = ((hash << 5) + hash) ^ *(str++); 217 | return hash; 218 | } // hash_string 219 | 220 | static const char *stringcache_len_internal(StringCache *cache, 221 | const char *str, 222 | const unsigned int len, 223 | const int addmissing) 224 | { 225 | const uint8 hash = hash_string(str, len) & (cache->table_size-1); 226 | StringBucket *bucket = cache->hashtable[hash]; 227 | StringBucket *prev = NULL; 228 | while (bucket) 229 | { 230 | const char *bstr = bucket->string; 231 | if ((strncmp(bstr, str, len) == 0) && (bstr[len] == 0)) 232 | { 233 | // Matched! Move this to the front of the list. 234 | if (prev != NULL) 235 | { 236 | assert(prev->next == bucket); 237 | prev->next = bucket->next; 238 | bucket->next = cache->hashtable[hash]; 239 | cache->hashtable[hash] = bucket; 240 | } // if 241 | return bstr; // already cached 242 | } // if 243 | prev = bucket; 244 | bucket = bucket->next; 245 | } // while 246 | 247 | // no match! 248 | if (!addmissing) 249 | return NULL; 250 | 251 | // add to the table. 252 | bucket = (StringBucket *) malloc(sizeof (StringBucket) + len + 1); 253 | if (bucket == NULL) 254 | return NULL; 255 | bucket->string = (char *)(bucket + 1); 256 | memcpy(bucket->string, str, len); 257 | bucket->string[len] = '\0'; 258 | bucket->next = cache->hashtable[hash]; 259 | cache->hashtable[hash] = bucket; 260 | return bucket->string; 261 | } // stringcache_len_internal 262 | 263 | static const char *stringcache_len(StringCache *cache, const char *str, const unsigned int len) 264 | { 265 | return stringcache_len_internal(cache, str, len, 1); 266 | } // stringcache_len 267 | 268 | const char *stringcache(StringCache *cache, const char *str) 269 | { 270 | return stringcache_len(cache, str, strlen(str)); 271 | } // stringcache 272 | 273 | StringCache *stringcache_create(void) 274 | { 275 | const uint32 initial_table_size = 256; 276 | const size_t tablelen = sizeof (StringBucket *) * initial_table_size; 277 | StringCache *cache = (StringCache *) malloc(sizeof (StringCache)); 278 | if (!cache) { 279 | return NULL; 280 | } 281 | memset(cache, '\0', sizeof (StringCache)); 282 | 283 | cache->hashtable = (StringBucket **) malloc(tablelen); 284 | if (!cache->hashtable) 285 | { 286 | free(cache); 287 | return NULL; 288 | } 289 | memset(cache->hashtable, '\0', tablelen); 290 | 291 | cache->table_size = initial_table_size; 292 | return cache; 293 | } // stringcache_create 294 | 295 | void stringcache_destroy(StringCache *cache) 296 | { 297 | size_t i; 298 | 299 | if (cache == NULL) 300 | return; 301 | 302 | for (i = 0; i < cache->table_size; i++) 303 | { 304 | StringBucket *bucket = cache->hashtable[i]; 305 | cache->hashtable[i] = NULL; 306 | while (bucket) 307 | { 308 | StringBucket *next = bucket->next; 309 | free(bucket); 310 | bucket = next; 311 | } // while 312 | } // for 313 | 314 | free(cache->hashtable); 315 | free(cache); 316 | } // stringcache_destroy 317 | 318 | // end of altrace_common.c ... 319 | 320 | -------------------------------------------------------------------------------- /messageboxex.cpp: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////// 2 | // Name: messageboxex.cpp 3 | // Purpose: 4 | // Author: Julian Smart 5 | // Modified by: 6 | // Created: 12/10/05 18:55:50 7 | // RCS-ID: 8 | // Copyright: (c) Julian Smart, Anthemion Software Ltd 9 | // Licence: 10 | ///////////////////////////////////////////////////////////////////////////// 11 | 12 | #if defined(__GNUG__) && !defined(__APPLE__) 13 | #pragma implementation "messageboxex.h" 14 | #endif 15 | 16 | // For compilers that support precompilation, includes "wx/wx.h". 17 | #include "wx/wxprec.h" 18 | 19 | #ifdef __BORLANDC__ 20 | #pragma hdrstop 21 | #endif 22 | 23 | #ifndef WX_PRECOMP 24 | #include "wx/wx.h" 25 | #endif 26 | 27 | ////@begin includes 28 | ////@end includes 29 | 30 | #include "messageboxex.h" 31 | 32 | #if 0 33 | #if defined(__WXMSW__) 34 | #include "bitmaps/exclamation_msw.xpm" 35 | #include "bitmaps/question_msw.xpm" 36 | #include "bitmaps/info_msw.xpm" 37 | #elif defined(__WXGTK__) 38 | #include "bitmaps/exclamation_gtk.xpm" 39 | #include "bitmaps/question_gtk.xpm" 40 | #include "bitmaps/info_gtk.xpm" 41 | #elif defined(__WXMAC__) 42 | #include "bitmaps/exclamation_generic.xpm" 43 | #include "bitmaps/question_generic.xpm" 44 | #include "bitmaps/info_generic.xpm" 45 | #endif 46 | #endif 47 | 48 | /*! 49 | * wxMessageDialogEx type definition 50 | */ 51 | 52 | IMPLEMENT_DYNAMIC_CLASS( wxMessageDialogEx, wxDialog ) 53 | 54 | /*! 55 | * wxMessageDialogEx event table definition 56 | */ 57 | 58 | BEGIN_EVENT_TABLE( wxMessageDialogEx, wxDialog ) 59 | 60 | ////@begin wxMessageDialogEx event table entries 61 | EVT_BUTTON( wxID_YES, wxMessageDialogEx::OnYesClick ) 62 | 63 | EVT_BUTTON( wxID_YESTOALL, wxMessageDialogEx::OnYestoallClick ) 64 | 65 | EVT_BUTTON( wxID_NO, wxMessageDialogEx::OnNoClick ) 66 | 67 | EVT_BUTTON( wxID_NOTOALL, wxMessageDialogEx::OnNotoallClick ) 68 | 69 | EVT_BUTTON( wxID_OK, wxMessageDialogEx::OnOkClick ) 70 | 71 | EVT_BUTTON( wxID_CANCEL, wxMessageDialogEx::OnCancelClick ) 72 | 73 | ////@end wxMessageDialogEx event table entries 74 | 75 | END_EVENT_TABLE() 76 | 77 | /*! 78 | * wxMessageDialogEx constructors 79 | */ 80 | 81 | wxMessageDialogEx::wxMessageDialogEx( ) 82 | { 83 | m_messageDialogStyle = wxOK; 84 | m_displayNextTime = true; 85 | //m_staticBitmap = NULL; 86 | } 87 | 88 | wxMessageDialogEx::wxMessageDialogEx( wxWindow* parent, const wxString& message, const wxString& caption, int style, const wxPoint& pos ) 89 | { 90 | m_messageDialogStyle = wxOK; 91 | m_displayNextTime = true; 92 | //m_staticBitmap = NULL; 93 | 94 | Create(parent, message, caption, style, pos); 95 | } 96 | 97 | /*! 98 | * wxMessageBoxEx creator 99 | */ 100 | 101 | bool wxMessageDialogEx::Create( wxWindow* parent, const wxString& message, const wxString& caption, int style, const wxPoint& pos ) 102 | { 103 | m_messageDialogStyle = style; 104 | m_message = message; 105 | 106 | SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); 107 | wxDialog::Create( parent, wxID_ANY, caption, pos, wxDefaultSize, wxDEFAULT_DIALOG_STYLE ); 108 | 109 | CreateControls(); 110 | GetSizer()->Fit(this); 111 | GetSizer()->SetSizeHints(this); 112 | Centre(); 113 | 114 | return true; 115 | } 116 | 117 | /*! 118 | * Control creation for wxMessageBoxEx 119 | */ 120 | 121 | void wxMessageDialogEx::CreateControls() 122 | { 123 | //// @begin wxMessageDialogEx content construction 124 | wxMessageDialogEx* itemDialog1 = this; 125 | 126 | wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL); 127 | itemDialog1->SetSizer(itemBoxSizer2); 128 | 129 | wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL); 130 | itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); 131 | 132 | wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxHORIZONTAL); 133 | itemBoxSizer3->Add(itemBoxSizer4, 0, wxGROW, 5); 134 | 135 | #if 0 136 | wxBitmap m_staticBitmapBitmap; 137 | if (m_messageDialogStyle & wxICON_QUESTION) 138 | m_staticBitmapBitmap = itemDialog1->GetBitmapResource(wxT("question.xpm")); 139 | else if (m_messageDialogStyle & (wxICON_EXCLAMATION|wxICON_ERROR)) 140 | m_staticBitmapBitmap = itemDialog1->GetBitmapResource(wxT("exclamation.xpm")); 141 | else 142 | m_staticBitmapBitmap = itemDialog1->GetBitmapResource(wxT("info.xpm")); 143 | 144 | m_staticBitmap = new wxStaticBitmap( itemDialog1, wxID_STATIC, m_staticBitmapBitmap, wxDefaultPosition, wxSize(32, 32), 0 ); 145 | itemBoxSizer4->Add(m_staticBitmap, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); 146 | itemBoxSizer4->AddSpacer(10); 147 | #endif 148 | 149 | wxStaticText* itemStaticText6 = new wxStaticText( itemDialog1, wxID_STATIC, m_message, wxDefaultPosition, wxDefaultSize, 0 ); 150 | itemBoxSizer4->Add(itemStaticText6, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); 151 | 152 | itemBoxSizer3->AddSpacer(10); 153 | 154 | wxBoxSizer* itemBoxSizer7 = new wxBoxSizer(wxHORIZONTAL); 155 | itemBoxSizer3->Add(itemBoxSizer7, 0, wxALIGN_CENTER_HORIZONTAL, 5); 156 | 157 | if (m_messageDialogStyle & wxDISPLAY_NEXT_TIME) 158 | { 159 | wxCheckBox* displayNextTime = new wxCheckBox( itemDialog1, wxID_ANY, _("&Display next time"), wxDefaultPosition, wxDefaultSize, 0 ); 160 | displayNextTime->SetValidator(wxGenericValidator(& m_displayNextTime)); 161 | itemBoxSizer7->Add(displayNextTime, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); 162 | itemBoxSizer7->AddStretchSpacer(); 163 | } 164 | 165 | if (m_messageDialogStyle & wxYES) 166 | { 167 | wxButton* itemButton8 = new wxButton( itemDialog1, wxID_YES, _("&Yes"), wxDefaultPosition, wxDefaultSize, 0 ); 168 | itemBoxSizer7->Add(itemButton8, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); 169 | } 170 | 171 | if (m_messageDialogStyle & wxYES_TO_ALL) 172 | { 173 | wxButton* itemButton9 = new wxButton( itemDialog1, wxID_YESTOALL, _("Yes to &All"), wxDefaultPosition, wxDefaultSize, 0 ); 174 | itemBoxSizer7->Add(itemButton9, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); 175 | } 176 | 177 | if (m_messageDialogStyle & wxNO) 178 | { 179 | wxButton* itemButton10 = new wxButton( itemDialog1, wxID_NO, _("&No"), wxDefaultPosition, wxDefaultSize, 0 ); 180 | itemBoxSizer7->Add(itemButton10, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); 181 | } 182 | 183 | if (m_messageDialogStyle & wxNO_TO_ALL) 184 | { 185 | wxButton* itemButton11 = new wxButton( itemDialog1, wxID_NOTOALL, _("No &to All"), wxDefaultPosition, wxDefaultSize, 0 ); 186 | itemBoxSizer7->Add(itemButton11, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); 187 | } 188 | 189 | if (m_messageDialogStyle & wxOK) 190 | { 191 | wxButton* itemButton12 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 ); 192 | itemBoxSizer7->Add(itemButton12, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); 193 | } 194 | 195 | if (m_messageDialogStyle & wxCANCEL) 196 | { 197 | wxButton* itemButton13 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); 198 | itemBoxSizer7->Add(itemButton13, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); 199 | } 200 | 201 | //// @end wxMessageDialogEx content construction 202 | } 203 | 204 | /*! 205 | * Should we show tooltips? 206 | */ 207 | 208 | bool wxMessageDialogEx::ShowToolTips() 209 | { 210 | return true; 211 | } 212 | 213 | #if 0 214 | /*! 215 | * Get bitmap resources 216 | */ 217 | 218 | wxBitmap wxMessageDialogEx::GetBitmapResource( const wxString& name ) 219 | { 220 | // Bitmap retrieval 221 | wxUnusedVar(name); 222 | if (name == _T("info.xpm")) 223 | { 224 | wxBitmap bitmap(info_xpm); 225 | return bitmap; 226 | } 227 | else if (name == _T("question.xpm")) 228 | { 229 | wxBitmap bitmap(question_xpm); 230 | return bitmap; 231 | } 232 | else if (name == _T("exclamation.xpm")) 233 | { 234 | wxBitmap bitmap(exclamation_xpm); 235 | return bitmap; 236 | } 237 | return wxNullBitmap; 238 | } 239 | #endif 240 | 241 | /*! 242 | * Get icon resources 243 | */ 244 | 245 | wxIcon wxMessageDialogEx::GetIconResource( const wxString& name ) 246 | { 247 | // Icon retrieval 248 | ////@begin wxMessageDialogEx icon retrieval 249 | wxUnusedVar(name); 250 | return wxNullIcon; 251 | ////@end wxMessageDialogEx icon retrieval 252 | } 253 | /*! 254 | * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_YES 255 | */ 256 | 257 | void wxMessageDialogEx::OnYesClick( wxCommandEvent& WXUNUSED(event) ) 258 | { 259 | TransferDataFromWindow(); 260 | EndModal(wxID_YES); 261 | } 262 | 263 | 264 | /*! 265 | * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_YESTOALL 266 | */ 267 | 268 | void wxMessageDialogEx::OnYestoallClick( wxCommandEvent& WXUNUSED(event) ) 269 | { 270 | TransferDataFromWindow(); 271 | EndModal(wxID_YESTOALL); 272 | } 273 | 274 | 275 | /*! 276 | * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_NO 277 | */ 278 | 279 | void wxMessageDialogEx::OnNoClick( wxCommandEvent& WXUNUSED(event) ) 280 | { 281 | TransferDataFromWindow(); 282 | EndModal(wxID_NO); 283 | } 284 | 285 | 286 | /*! 287 | * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_NOTOALL 288 | */ 289 | 290 | void wxMessageDialogEx::OnNotoallClick( wxCommandEvent& WXUNUSED(event) ) 291 | { 292 | TransferDataFromWindow(); 293 | EndModal(wxID_NOTOALL); 294 | } 295 | 296 | 297 | /*! 298 | * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK 299 | */ 300 | 301 | void wxMessageDialogEx::OnOkClick( wxCommandEvent& WXUNUSED(event) ) 302 | { 303 | TransferDataFromWindow(); 304 | EndModal(wxID_OK); 305 | } 306 | 307 | 308 | /*! 309 | * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL 310 | */ 311 | 312 | void wxMessageDialogEx::OnCancelClick( wxCommandEvent& WXUNUSED(event) ) 313 | { 314 | EndModal(wxID_CANCEL); 315 | } 316 | 317 | // Convenience dialog 318 | int wxMessageBoxEx(const wxString& msg, const wxString& caption, int style, wxWindow* parent) 319 | { 320 | wxMessageDialogEx dialog(parent, msg, caption, style); 321 | int id = dialog.ShowModal(); 322 | if (id == wxID_YES) 323 | return wxYES; 324 | else if (id == wxID_NO) 325 | return wxNO; 326 | else if (id == wxID_YESTOALL) 327 | return wxYES_TO_ALL; 328 | else if (id == wxID_NOTOALL) 329 | return wxNO_TO_ALL; 330 | else if (id == wxID_OK) 331 | return wxOK; 332 | else if (id == wxID_CANCEL) 333 | return wxCANCEL; 334 | 335 | return wxCANCEL; 336 | } 337 | -------------------------------------------------------------------------------- /altrace_entrypoints.h: -------------------------------------------------------------------------------- 1 | /** 2 | * alTrace; a debugging tool for OpenAL. 3 | * 4 | * Please see the file LICENSE.txt in the source's root directory. 5 | * 6 | * This file written by Ryan C. Gordon. 7 | */ 8 | 9 | #ifndef ENTRYPOINTVOID 10 | #define ENTRYPOINTVOID(name,params,args,numargs,visitparams,visitargs) ENTRYPOINT(void,name,params,args,numargs,visitparams,visitargs) 11 | #endif 12 | #ifndef ENTRYPOINT_EXTENSIONS_BEGIN 13 | #define ENTRYPOINT_EXTENSIONS_BEGIN() 14 | #endif 15 | 16 | ENTRYPOINT(ALCcontext *,alcGetCurrentContext,(void),(),0,(CallerInfo *callerinfo, ALCcontext *retval),(callerinfo,retval)) 17 | ENTRYPOINT(ALCdevice *,alcGetContextsDevice,(ALCcontext *context),(context),1,(CallerInfo *callerinfo, ALCdevice *retval, ALCcontext *context),(callerinfo,retval,context)) 18 | ENTRYPOINT(ALCboolean,alcIsExtensionPresent,(ALCdevice *device, const ALCchar *extname),(device,extname),2,(CallerInfo *callerinfo, ALCboolean retval, ALCdevice *device, const ALCchar *extname),(callerinfo,retval,device,extname)) 19 | ENTRYPOINT(void *,alcGetProcAddress,(ALCdevice *device, const ALCchar *funcname),(device,funcname),2,(CallerInfo *callerinfo, void *retval, ALCdevice *device, const ALCchar *funcname),(callerinfo,retval,device,funcname)) 20 | ENTRYPOINT(ALCenum,alcGetEnumValue,(ALCdevice *device, const ALCchar *enumname),(device,enumname),2,(CallerInfo *callerinfo, ALCenum retval, ALCdevice *device, const ALCchar *enumname),(callerinfo,retval,device,enumname)) 21 | ENTRYPOINT(const ALCchar *,alcGetString,(ALCdevice *device, ALCenum param),(device,param),2,(CallerInfo *callerinfo, const ALCchar *retval, ALCdevice *device, ALCenum param),(callerinfo,retval,device,param)) 22 | ENTRYPOINT(ALCdevice *,alcCaptureOpenDevice,(const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize),(devicename,frequency,format,buffersize),4,(CallerInfo *callerinfo, ALCdevice *retval, const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize, ALint major_version, ALint minor_version, const ALCchar *devspec, const ALCchar *extensions),(callerinfo,retval,devicename,frequency,format,buffersize,major_version,minor_version,devspec,extensions)) 23 | ENTRYPOINT(ALCboolean,alcCaptureCloseDevice,(ALCdevice *device),(device),1,(CallerInfo *callerinfo, ALCboolean retval, ALCdevice *device),(callerinfo,retval,device)) 24 | ENTRYPOINT(ALCdevice *,alcOpenDevice,(const ALCchar *devicename),(devicename),1,(CallerInfo *callerinfo, ALCdevice *retval, const ALCchar *devicename, ALint major_version, ALint minor_version, const ALCchar *devspec, const ALCchar *extensions),(callerinfo,retval,devicename,major_version,minor_version,devspec,extensions)) 25 | ENTRYPOINT(ALCboolean,alcCloseDevice,(ALCdevice *device),(device),1,(CallerInfo *callerinfo, ALCboolean retval, ALCdevice *device),(callerinfo,retval,device)) 26 | ENTRYPOINT(ALCcontext *,alcCreateContext,(ALCdevice *device, const ALCint *attrlist),(device,attrlist),2,(CallerInfo *callerinfo, ALCcontext *retval, ALCdevice *device, const ALCint *origattrlist, uint32 attrcount, const ALCint *attrlist),(callerinfo,retval,device,origattrlist,attrcount,attrlist)) 27 | ENTRYPOINT(ALCboolean,alcMakeContextCurrent,(ALCcontext *ctx),(ctx),1,(CallerInfo *callerinfo, ALCboolean retval, ALCcontext *ctx),(callerinfo,retval,ctx)) 28 | ENTRYPOINTVOID(alcProcessContext,(ALCcontext *ctx),(ctx),1,(CallerInfo *callerinfo, ALCcontext *ctx),(callerinfo,ctx)) 29 | ENTRYPOINTVOID(alcSuspendContext,(ALCcontext *ctx),(ctx),1,(CallerInfo *callerinfo, ALCcontext *ctx),(callerinfo,ctx)) 30 | ENTRYPOINTVOID(alcDestroyContext,(ALCcontext *ctx),(ctx),1,(CallerInfo *callerinfo, ALCcontext *ctx),(callerinfo,ctx)) 31 | ENTRYPOINT(ALCenum,alcGetError,(ALCdevice *device),(device),1,(CallerInfo *callerinfo, ALCenum retval, ALCdevice *device),(callerinfo,retval,device)) 32 | ENTRYPOINTVOID(alcGetIntegerv,(ALCdevice *device, ALCenum param, ALCsizei size, ALCint *values),(device,param,size,values),4,(CallerInfo *callerinfo, ALCdevice *device, ALCenum param, ALCsizei size, ALCint *origvalues, ALCboolean isbool, ALCint *values),(callerinfo,device,param,size,origvalues,isbool,values)) 33 | ENTRYPOINTVOID(alcCaptureStart,(ALCdevice *device),(device),1,(CallerInfo *callerinfo, ALCdevice *device),(callerinfo,device)) 34 | ENTRYPOINTVOID(alcCaptureStop,(ALCdevice *device),(device),1,(CallerInfo *callerinfo, ALCdevice *device),(callerinfo,device)) 35 | ENTRYPOINTVOID(alcCaptureSamples,(ALCdevice *device, ALCvoid *buffer, ALCsizei samples),(device,buffer,samples),3,(CallerInfo *callerinfo, ALCdevice *device, ALCvoid *origbuffer, ALCvoid *buffer, ALCsizei bufferlen, ALCsizei samples),(callerinfo,device,origbuffer,buffer,bufferlen,samples)) 36 | ENTRYPOINTVOID(alDopplerFactor,(ALfloat value),(value),1,(CallerInfo *callerinfo, ALfloat value),(callerinfo,value)) 37 | ENTRYPOINTVOID(alDopplerVelocity,(ALfloat value),(value),1,(CallerInfo *callerinfo, ALfloat value),(callerinfo,value)) 38 | ENTRYPOINTVOID(alSpeedOfSound,(ALfloat value),(value),1,(CallerInfo *callerinfo, ALfloat value),(callerinfo,value)) 39 | ENTRYPOINTVOID(alDistanceModel,(ALenum model),(model),1,(CallerInfo *callerinfo, ALenum model),(callerinfo,model)) 40 | ENTRYPOINTVOID(alEnable,(ALenum capability),(capability),1,(CallerInfo *callerinfo, ALenum capability),(callerinfo,capability)) 41 | ENTRYPOINTVOID(alDisable,(ALenum capability),(capability),1,(CallerInfo *callerinfo, ALenum capability),(callerinfo,capability)) 42 | ENTRYPOINT(ALboolean,alIsEnabled,(ALenum capability),1,(capability),(CallerInfo *callerinfo, ALboolean retval, ALenum capability),(callerinfo,retval,capability)) 43 | ENTRYPOINT(const ALchar *,alGetString,(const ALenum param),(param),1,(CallerInfo *callerinfo, const ALchar *retval, const ALenum param),(callerinfo,retval,param)) 44 | ENTRYPOINTVOID(alGetBooleanv,(ALenum param, ALboolean *values),(param,values),2,(CallerInfo *callerinfo, ALenum param, ALboolean *origvalues, uint32 numvals, ALboolean *values),(callerinfo,param,origvalues,numvals,values)) 45 | ENTRYPOINTVOID(alGetIntegerv,(ALenum param, ALint *values),(param,values),2,(CallerInfo *callerinfo, ALenum param, ALint *origvalues, uint32 numvals, ALboolean isenum, ALint *values),(callerinfo,param,origvalues,numvals,isenum,values)) 46 | ENTRYPOINTVOID(alGetFloatv,(ALenum param, ALfloat *values),(param,values),2,(CallerInfo *callerinfo, ALenum param, ALfloat *origvalues, uint32 numvals, ALfloat *values),(callerinfo,param,origvalues,numvals,values)) 47 | ENTRYPOINTVOID(alGetDoublev,(ALenum param, ALdouble *values),(param,values),2,(CallerInfo *callerinfo, ALenum param, ALdouble *origvalues, uint32 numvals, ALdouble *values),(callerinfo,param,origvalues,numvals,values)) 48 | ENTRYPOINT(ALboolean,alGetBoolean,(ALenum param),(param),1,(CallerInfo *callerinfo, ALboolean retval, ALenum param),(callerinfo,retval,param)) 49 | ENTRYPOINT(ALint,alGetInteger,(ALenum param),(param),1,(CallerInfo *callerinfo, ALint retval, ALenum param),(callerinfo,retval,param)) 50 | ENTRYPOINT(ALfloat,alGetFloat,(ALenum param),(param),1,(CallerInfo *callerinfo, ALfloat retval, ALenum param),(callerinfo,retval,param)) 51 | ENTRYPOINT(ALdouble,alGetDouble,(ALenum param),(param),1,(CallerInfo *callerinfo, ALdouble retval, ALenum param),(callerinfo,retval,param)) 52 | ENTRYPOINT(ALboolean,alIsExtensionPresent,(const ALchar *extname),(extname),1,(CallerInfo *callerinfo, ALboolean retval, const ALchar *extname),(callerinfo,retval,extname)) 53 | ENTRYPOINT(ALenum,alGetError,(void),(),0,(CallerInfo *callerinfo, ALenum retval),(callerinfo,retval)) 54 | ENTRYPOINT(void *,alGetProcAddress,(const ALchar *funcname),(funcname),1,(CallerInfo *callerinfo, void *retval, const ALchar *funcname),(callerinfo,retval,funcname)) 55 | ENTRYPOINT(ALenum,alGetEnumValue,(const ALchar *enumname),(enumname),1,(CallerInfo *callerinfo, ALenum retval, const ALchar *enumname),(callerinfo,retval,enumname)) 56 | ENTRYPOINTVOID(alListenerfv,(ALenum param, const ALfloat *values),(param,values),2,(CallerInfo *callerinfo, ALenum param, const ALfloat *origvalues, uint32 numvals, const ALfloat *values),(callerinfo,param,origvalues,numvals,values)) 57 | ENTRYPOINTVOID(alListenerf,(ALenum param, ALfloat value),(param,value),2,(CallerInfo *callerinfo, ALenum param, ALfloat value),(callerinfo,param,value)) 58 | ENTRYPOINTVOID(alListener3f,(ALenum param, ALfloat value1, ALfloat value2, ALfloat value3),(param,value1,value2,value3),4,(CallerInfo *callerinfo, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3),(callerinfo,param,value1,value2,value3)) 59 | ENTRYPOINTVOID(alListeneriv,(ALenum param, const ALint *values),(param,values),2,(CallerInfo *callerinfo, ALenum param, const ALint *origvalues, uint32 numvals, const ALint *values),(callerinfo,param,origvalues,numvals,values)) 60 | ENTRYPOINTVOID(alListeneri,(ALenum param, ALint value),(param,value),2,(CallerInfo *callerinfo, ALenum param, ALint value),(callerinfo,param,value)) 61 | ENTRYPOINTVOID(alListener3i,(ALenum param, ALint value1, ALint value2, ALint value3),(param,value1,value2,value3),4,(CallerInfo *callerinfo, ALenum param, ALint value1, ALint value2, ALint value3),(callerinfo,param,value1,value2,value3)) 62 | ENTRYPOINTVOID(alGetListenerfv,(ALenum param, ALfloat *values),(param,values),2,(CallerInfo *callerinfo, ALenum param, ALfloat *origvalues, uint32 numvals, ALfloat *values),(callerinfo,param,origvalues,numvals,values)) 63 | ENTRYPOINTVOID(alGetListenerf,(ALenum param, ALfloat *value),(param,value),2,(CallerInfo *callerinfo, ALenum param, ALfloat *origvalue, ALfloat value),(callerinfo,param,origvalue,value)) 64 | ENTRYPOINTVOID(alGetListener3f,(ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3),(param,value1,value2,value3),4,(CallerInfo *callerinfo, ALenum param, ALfloat *origvalue1, ALfloat *origvalue2, ALfloat *origvalue3, ALfloat value1, ALfloat value2, ALfloat value3),(callerinfo,param,origvalue1,origvalue2,origvalue3,value1,value2,value3)) 65 | ENTRYPOINTVOID(alGetListeneri,(ALenum param, ALint *value),(param,value),2,(CallerInfo *callerinfo, ALenum param, ALint *origvalue, ALint value),(callerinfo,param,origvalue,value)) 66 | ENTRYPOINTVOID(alGetListeneriv,(ALenum param, ALint *values),(param,values),2,(CallerInfo *callerinfo, ALenum param, ALint *origvalues, uint32 numvals, ALint *values),(callerinfo,param,origvalues,numvals,values)) 67 | ENTRYPOINTVOID(alGetListener3i,(ALenum param, ALint *value1, ALint *value2, ALint *value3),(param,value1,value2,value3),4,(CallerInfo *callerinfo, ALenum param, ALint *origvalue1, ALint *origvalue2, ALint *origvalue3, ALint value1, ALint value2, ALint value3),(callerinfo,param,origvalue1,origvalue2,origvalue3,value1,value2,value3)) 68 | ENTRYPOINTVOID(alGenSources,(ALsizei n, ALuint *names),(n,names),2,(CallerInfo *callerinfo, ALsizei n, ALuint *orignames, ALuint *names),(callerinfo,n,orignames,names)) 69 | ENTRYPOINTVOID(alDeleteSources,(ALsizei n, const ALuint *names),(n,names),2,(CallerInfo *callerinfo, ALsizei n, const ALuint *orignames, const ALuint *names),(callerinfo,n,orignames,names)) 70 | ENTRYPOINT(ALboolean,alIsSource,(ALuint name),(name),1,(CallerInfo *callerinfo, ALboolean retval, ALuint name),(callerinfo,retval,name)) 71 | ENTRYPOINTVOID(alSourcefv,(ALuint name, ALenum param, const ALfloat *values),(name,param,values),3,(CallerInfo *callerinfo, ALuint name, ALenum param, const ALfloat *origvalues, uint32 numvals, const ALfloat *values),(callerinfo,name,param,origvalues,numvals,values)) 72 | ENTRYPOINTVOID(alSourcef,(ALuint name, ALenum param, ALfloat value),(name,param,value),3,(CallerInfo *callerinfo, ALuint name, ALenum param, ALfloat value),(callerinfo,name,param,value)) 73 | ENTRYPOINTVOID(alSource3f,(ALuint name, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3),(name,param,value1,value2,value3),5,(CallerInfo *callerinfo, ALuint name, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3),(callerinfo,name,param,value1,value2,value3)) 74 | ENTRYPOINTVOID(alSourceiv,(ALuint name, ALenum param, const ALint *values),(name,param,values),3,(CallerInfo *callerinfo, ALuint name, ALenum param, const ALint *origvalues, uint32 numvals, const ALint *values),(callerinfo,name,param,origvalues,numvals,values)) 75 | ENTRYPOINTVOID(alSourcei,(ALuint name, ALenum param, ALint value),(name,param,value),3,(CallerInfo *callerinfo, ALuint name, ALenum param, ALint value),(callerinfo,name,param,value)) 76 | ENTRYPOINTVOID(alSource3i,(ALuint name, ALenum param, ALint value1, ALint value2, ALint value3),(name,param,value1,value2,value3),5,(CallerInfo *callerinfo, ALuint name, ALenum param, ALint value1, ALint value2, ALint value3),(callerinfo,name,param,value1,value2,value3)) 77 | ENTRYPOINTVOID(alGetSourcefv,(ALuint name, ALenum param, ALfloat *values),(name,param,values),3,(CallerInfo *callerinfo, ALuint name, ALenum param, ALfloat *origvalues, uint32 numvals, ALfloat *values),(callerinfo,name,param,origvalues,numvals,values)) 78 | ENTRYPOINTVOID(alGetSourcef,(ALuint name, ALenum param, ALfloat *value),(name,param,value),3,(CallerInfo *callerinfo, ALuint name, ALenum param, ALfloat *origvalue, ALfloat value),(callerinfo,name,param,origvalue,value)) 79 | ENTRYPOINTVOID(alGetSource3f,(ALuint name, ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3),(name,param,value1,value2,value3),5,(CallerInfo *callerinfo, ALuint name, ALenum param, ALfloat *origvalue1, ALfloat *origvalue2, ALfloat *origvalue3, ALfloat value1, ALfloat value2, ALfloat value3),(callerinfo,name,param,origvalue1,origvalue2,origvalue3,value1,value2,value3)) 80 | ENTRYPOINTVOID(alGetSourceiv,(ALuint name, ALenum param, ALint *values),(name,param,values),3,(CallerInfo *callerinfo, ALuint name, ALenum param, ALboolean isenum, ALint *origvalues, uint32 numvals, ALint *values),(callerinfo,name,param,isenum,origvalues,numvals,values)) 81 | ENTRYPOINTVOID(alGetSourcei,(ALuint name, ALenum param, ALint *value),(name,param,value),3,(CallerInfo *callerinfo, ALuint name, ALenum param, ALboolean isenum, ALint *origvalue, ALint value),(callerinfo,name,param,isenum,origvalue,value)) 82 | ENTRYPOINTVOID(alGetSource3i,(ALuint name, ALenum param, ALint *value1, ALint *value2, ALint *value3),(name,param,value1,value2,value3),5,(CallerInfo *callerinfo, ALuint name, ALenum param, ALint *origvalue1, ALint *origvalue2, ALint *origvalue3, ALint value1, ALint value2, ALint value3),(callerinfo,name,param,origvalue1,origvalue2,origvalue3,value1,value2,value3)) 83 | ENTRYPOINTVOID(alSourcePlay,(ALuint name),(name),1,(CallerInfo *callerinfo, ALuint name),(callerinfo,name)) 84 | ENTRYPOINTVOID(alSourcePlayv,(ALsizei n, const ALuint *names),(n, names),2,(CallerInfo *callerinfo, ALsizei n, const ALuint *orignames, const ALuint *names),(callerinfo,n,orignames,names)) 85 | ENTRYPOINTVOID(alSourcePause,(ALuint name),(name),1,(CallerInfo *callerinfo, ALuint name),(callerinfo,name)) 86 | ENTRYPOINTVOID(alSourcePausev,(ALsizei n, const ALuint *names),(n, names),2,(CallerInfo *callerinfo, ALsizei n, const ALuint *orignames, const ALuint *names),(callerinfo,n,orignames,names)) 87 | ENTRYPOINTVOID(alSourceRewind,(ALuint name),(name),1,(CallerInfo *callerinfo, ALuint name),(callerinfo,name)) 88 | ENTRYPOINTVOID(alSourceRewindv,(ALsizei n, const ALuint *names),(n, names),2,(CallerInfo *callerinfo, ALsizei n, const ALuint *orignames, const ALuint *names),(callerinfo,n,orignames,names)) 89 | ENTRYPOINTVOID(alSourceStop,(ALuint name),(name),1,(CallerInfo *callerinfo, ALuint name),(callerinfo,name)) 90 | ENTRYPOINTVOID(alSourceStopv,(ALsizei n, const ALuint *names),(n, names),2,(CallerInfo *callerinfo, ALsizei n, const ALuint *orignames, const ALuint *names),(callerinfo,n,orignames,names)) 91 | ENTRYPOINTVOID(alSourceQueueBuffers,(ALuint name, ALsizei nb, const ALuint *bufnames),(name,nb,bufnames),3,(CallerInfo *callerinfo, ALuint name, ALsizei nb, const ALuint *origbufnames, const ALuint *bufnames),(callerinfo,name,nb,origbufnames,bufnames)) 92 | ENTRYPOINTVOID(alSourceUnqueueBuffers,(ALuint name, ALsizei nb, ALuint *bufnames),(name,nb,bufnames),3,(CallerInfo *callerinfo, ALuint name, ALsizei nb, ALuint *origbufnames, ALuint *bufnames),(callerinfo,name,nb,origbufnames,bufnames)) 93 | ENTRYPOINTVOID(alGenBuffers,(ALsizei n, ALuint *names),(n,names),2,(CallerInfo *callerinfo, ALsizei n, ALuint *orignames, ALuint *names),(callerinfo,n,orignames,names)) 94 | ENTRYPOINTVOID(alDeleteBuffers,(ALsizei n, const ALuint *names),(n,names),2,(CallerInfo *callerinfo, ALsizei n, const ALuint *orignames, const ALuint *names),(callerinfo,n,orignames,names)) 95 | ENTRYPOINT(ALboolean,alIsBuffer,(ALuint name),(name),1,(CallerInfo *callerinfo, ALboolean retval, ALuint name),(callerinfo,retval,name)) 96 | ENTRYPOINTVOID(alBufferData,(ALuint name, ALenum alfmt, const ALvoid *data, ALsizei size, ALsizei freq),(name,alfmt,data,size,freq),5,(CallerInfo *callerinfo, ALuint name, ALenum alfmt, const ALvoid *origdata, const ALvoid *data, ALsizei size, ALsizei freq),(callerinfo,name,alfmt,origdata,data,size,freq)) 97 | ENTRYPOINTVOID(alBufferfv,(ALuint name, ALenum param, const ALfloat *values),(name,param,values),3,(CallerInfo *callerinfo, ALuint name, ALenum param, const ALfloat *origvalues, uint32 numvals, const ALfloat *values),(callerinfo,name,param,origvalues,numvals,values)) 98 | ENTRYPOINTVOID(alBufferf,(ALuint name, ALenum param, ALfloat value),(name,param,value),3,(CallerInfo *callerinfo, ALuint name, ALenum param, ALfloat value),(callerinfo,name,param,value)) 99 | ENTRYPOINTVOID(alBuffer3f,(ALuint name, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3),(name,param,value1,value2,value3),5,(CallerInfo *callerinfo, ALuint name, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3),(callerinfo,name,param,value1,value2,value3)) 100 | ENTRYPOINTVOID(alBufferiv,(ALuint name, ALenum param, const ALint *values),(name,param,values),3,(CallerInfo *callerinfo, ALuint name, ALenum param, const ALint *origvalues, uint32 numvals, const ALint *values),(callerinfo,name,param,origvalues,numvals,values)) 101 | ENTRYPOINTVOID(alBufferi,(ALuint name, ALenum param, ALint value),(name,param,value),3,(CallerInfo *callerinfo, ALuint name, ALenum param, ALint value),(callerinfo,name,param,value)) 102 | ENTRYPOINTVOID(alBuffer3i,(ALuint name, ALenum param, ALint value1, ALint value2, ALint value3),(name,param,value1,value2,value3),5,(CallerInfo *callerinfo, ALuint name, ALenum param, ALint value1, ALint value2, ALint value3),(callerinfo,name,param,value1,value2,value3)) 103 | ENTRYPOINTVOID(alGetBufferfv,(ALuint name, ALenum param, ALfloat *values),(name,param,values),3,(CallerInfo *callerinfo, ALuint name, ALenum param, ALfloat *origvalues, uint32 numvals, ALfloat *values),(callerinfo,name,param,origvalues,numvals,values)) 104 | ENTRYPOINTVOID(alGetBufferf,(ALuint name, ALenum param, ALfloat *value),(name,param,value),3,(CallerInfo *callerinfo, ALuint name, ALenum param, ALfloat *origvalue, ALfloat value),(callerinfo,name,param,origvalue,value)) 105 | ENTRYPOINTVOID(alGetBuffer3f,(ALuint name, ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3),(name,param,value1,value2,value3),5,(CallerInfo *callerinfo, ALuint name, ALenum param, ALfloat *origvalue1, ALfloat *origvalue2, ALfloat *origvalue3, ALfloat value1, ALfloat value2, ALfloat value3),(callerinfo,name,param,origvalue1,origvalue2,origvalue3,value1,value2,value3)) 106 | ENTRYPOINTVOID(alGetBufferi,(ALuint name, ALenum param, ALint *value),(name,param,value),3,(CallerInfo *callerinfo, ALuint name, ALenum param, ALint *origvalue, ALint value),(callerinfo,name,param,origvalue,value)) 107 | ENTRYPOINTVOID(alGetBuffer3i,(ALuint name, ALenum param, ALint *value1, ALint *value2, ALint *value3),(name,param,value1,value2,value3),5,(CallerInfo *callerinfo, ALuint name, ALenum param, ALint *origvalue1, ALint *origvalue2, ALint *origvalue3, ALint value1, ALint value2, ALint value3),(callerinfo,name,param,origvalue1,origvalue2,origvalue3,value1,value2,value3)) 108 | ENTRYPOINTVOID(alGetBufferiv,(ALuint name, ALenum param, ALint *values),(name,param,values),3,(CallerInfo *callerinfo, ALuint name, ALenum param, ALint *origvalues, uint32 numvals, ALint *values),(callerinfo,name,param,origvalues,numvals,values)) 109 | 110 | ENTRYPOINT_EXTENSIONS_BEGIN() 111 | ENTRYPOINTVOID(alTracePushScope,(const ALchar *str),(str),1,(CallerInfo *callerinfo, const ALchar *str),(callerinfo,str)) 112 | ENTRYPOINTVOID(alTracePopScope,(void),(),0,(CallerInfo *callerinfo),(callerinfo)) 113 | ENTRYPOINTVOID(alTraceMessage,(const ALchar *str),(str),1,(CallerInfo *callerinfo, const ALchar *str),(callerinfo,str)) 114 | ENTRYPOINTVOID(alTraceBufferLabel,(ALuint name, const ALchar *str),(name,str),2,(CallerInfo *callerinfo, ALuint name, const ALchar *str),(callerinfo,name,str)) 115 | ENTRYPOINTVOID(alTraceSourceLabel,(ALuint name, const ALchar *str),(name,str),2,(CallerInfo *callerinfo, ALuint name, const ALchar *str),(callerinfo,name,str)) 116 | ENTRYPOINTVOID(alcTraceDeviceLabel,(ALCdevice *device, const ALchar *str),(device,str),2,(CallerInfo *callerinfo, ALCdevice *device, const ALCchar *str),(callerinfo,device,str)) 117 | ENTRYPOINTVOID(alcTraceContextLabel,(ALCcontext *ctx, const ALchar *str),(ctx,str),2,(CallerInfo *callerinfo, ALCcontext *ctx, const ALCchar *str),(callerinfo,ctx,str)) 118 | 119 | #undef ENTRYPOINT 120 | #undef ENTRYPOINTVOID 121 | #undef ENTRYPOINT_EXTENSIONS_BEGIN 122 | 123 | -------------------------------------------------------------------------------- /AL/al.h: -------------------------------------------------------------------------------- 1 | #ifndef AL_AL_H 2 | #define AL_AL_H 3 | 4 | #if defined(__cplusplus) 5 | extern "C" { 6 | #endif 7 | 8 | #ifndef AL_API 9 | #if defined(AL_LIBTYPE_STATIC) 10 | #define AL_API 11 | #elif defined(_WIN32) 12 | #define AL_API __declspec(dllimport) 13 | #else 14 | #define AL_API extern 15 | #endif 16 | #endif 17 | 18 | #if defined(_WIN32) 19 | #define AL_APIENTRY __cdecl 20 | #else 21 | #define AL_APIENTRY 22 | #endif 23 | 24 | 25 | /** Deprecated macro. */ 26 | #define OPENAL 27 | #define ALAPI AL_API 28 | #define ALAPIENTRY AL_APIENTRY 29 | #define AL_INVALID (-1) 30 | #define AL_ILLEGAL_ENUM AL_INVALID_ENUM 31 | #define AL_ILLEGAL_COMMAND AL_INVALID_OPERATION 32 | 33 | /** Supported AL version. */ 34 | #define AL_VERSION_1_0 35 | #define AL_VERSION_1_1 36 | 37 | /** 8-bit boolean */ 38 | typedef char ALboolean; 39 | 40 | /** character */ 41 | typedef char ALchar; 42 | 43 | /** signed 8-bit 2's complement integer */ 44 | typedef signed char ALbyte; 45 | 46 | /** unsigned 8-bit integer */ 47 | typedef unsigned char ALubyte; 48 | 49 | /** signed 16-bit 2's complement integer */ 50 | typedef short ALshort; 51 | 52 | /** unsigned 16-bit integer */ 53 | typedef unsigned short ALushort; 54 | 55 | /** signed 32-bit 2's complement integer */ 56 | typedef int ALint; 57 | 58 | /** unsigned 32-bit integer */ 59 | typedef unsigned int ALuint; 60 | 61 | /** non-negative 32-bit binary integer size */ 62 | typedef int ALsizei; 63 | 64 | /** enumerated 32-bit value */ 65 | typedef int ALenum; 66 | 67 | /** 32-bit IEEE754 floating-point */ 68 | typedef float ALfloat; 69 | 70 | /** 64-bit IEEE754 floating-point */ 71 | typedef double ALdouble; 72 | 73 | /** void type (for opaque pointers only) */ 74 | typedef void ALvoid; 75 | 76 | 77 | /* Enumerant values begin at column 50. No tabs. */ 78 | 79 | /** "no distance model" or "no buffer" */ 80 | #define AL_NONE 0 81 | 82 | /** Boolean False. */ 83 | #define AL_FALSE 0 84 | 85 | /** Boolean True. */ 86 | #define AL_TRUE 1 87 | 88 | 89 | /** 90 | * Relative source. 91 | * Type: ALboolean 92 | * Range: [AL_TRUE, AL_FALSE] 93 | * Default: AL_FALSE 94 | * 95 | * Specifies if the Source has relative coordinates. 96 | */ 97 | #define AL_SOURCE_RELATIVE 0x202 98 | 99 | 100 | /** 101 | * Inner cone angle, in degrees. 102 | * Type: ALint, ALfloat 103 | * Range: [0 - 360] 104 | * Default: 360 105 | * 106 | * The angle covered by the inner cone, where the source will not attenuate. 107 | */ 108 | #define AL_CONE_INNER_ANGLE 0x1001 109 | 110 | /** 111 | * Outer cone angle, in degrees. 112 | * Range: [0 - 360] 113 | * Default: 360 114 | * 115 | * The angle covered by the outer cone, where the source will be fully 116 | * attenuated. 117 | */ 118 | #define AL_CONE_OUTER_ANGLE 0x1002 119 | 120 | /** 121 | * Source pitch. 122 | * Type: ALfloat 123 | * Range: [0.5 - 2.0] 124 | * Default: 1.0 125 | * 126 | * A multiplier for the frequency (sample rate) of the source's buffer. 127 | */ 128 | #define AL_PITCH 0x1003 129 | 130 | /** 131 | * Source or listener position. 132 | * Type: ALfloat[3], ALint[3] 133 | * Default: {0, 0, 0} 134 | * 135 | * The source or listener location in three dimensional space. 136 | * 137 | * OpenAL, like OpenGL, uses a right handed coordinate system, where in a 138 | * frontal default view X (thumb) points right, Y points up (index finger), and 139 | * Z points towards the viewer/camera (middle finger). 140 | * 141 | * To switch from a left handed coordinate system, flip the sign on the Z 142 | * coordinate. 143 | */ 144 | #define AL_POSITION 0x1004 145 | 146 | /** 147 | * Source direction. 148 | * Type: ALfloat[3], ALint[3] 149 | * Default: {0, 0, 0} 150 | * 151 | * Specifies the current direction in local space. 152 | * A zero-length vector specifies an omni-directional source (cone is ignored). 153 | */ 154 | #define AL_DIRECTION 0x1005 155 | 156 | /** 157 | * Source or listener velocity. 158 | * Type: ALfloat[3], ALint[3] 159 | * Default: {0, 0, 0} 160 | * 161 | * Specifies the current velocity in local space. 162 | */ 163 | #define AL_VELOCITY 0x1006 164 | 165 | /** 166 | * Source looping. 167 | * Type: ALboolean 168 | * Range: [AL_TRUE, AL_FALSE] 169 | * Default: AL_FALSE 170 | * 171 | * Specifies whether source is looping. 172 | */ 173 | #define AL_LOOPING 0x1007 174 | 175 | /** 176 | * Source buffer. 177 | * Type: ALuint 178 | * Range: any valid Buffer. 179 | * 180 | * Specifies the buffer to provide sound samples. 181 | */ 182 | #define AL_BUFFER 0x1009 183 | 184 | /** 185 | * Source or listener gain. 186 | * Type: ALfloat 187 | * Range: [0.0 - ] 188 | * 189 | * A value of 1.0 means unattenuated. Each division by 2 equals an attenuation 190 | * of about -6dB. Each multiplicaton by 2 equals an amplification of about 191 | * +6dB. 192 | * 193 | * A value of 0.0 is meaningless with respect to a logarithmic scale; it is 194 | * silent. 195 | */ 196 | #define AL_GAIN 0x100A 197 | 198 | /** 199 | * Minimum source gain. 200 | * Type: ALfloat 201 | * Range: [0.0 - 1.0] 202 | * 203 | * The minimum gain allowed for a source, after distance and cone attenation is 204 | * applied (if applicable). 205 | */ 206 | #define AL_MIN_GAIN 0x100D 207 | 208 | /** 209 | * Maximum source gain. 210 | * Type: ALfloat 211 | * Range: [0.0 - 1.0] 212 | * 213 | * The maximum gain allowed for a source, after distance and cone attenation is 214 | * applied (if applicable). 215 | */ 216 | #define AL_MAX_GAIN 0x100E 217 | 218 | /** 219 | * Listener orientation. 220 | * Type: ALfloat[6] 221 | * Default: {0.0, 0.0, -1.0, 0.0, 1.0, 0.0} 222 | * 223 | * Effectively two three dimensional vectors. The first vector is the front (or 224 | * "at") and the second is the top (or "up"). 225 | * 226 | * Both vectors are in local space. 227 | */ 228 | #define AL_ORIENTATION 0x100F 229 | 230 | /** 231 | * Source state (query only). 232 | * Type: ALint 233 | * Range: [AL_INITIAL, AL_PLAYING, AL_PAUSED, AL_STOPPED] 234 | */ 235 | #define AL_SOURCE_STATE 0x1010 236 | 237 | /** Source state value. */ 238 | #define AL_INITIAL 0x1011 239 | #define AL_PLAYING 0x1012 240 | #define AL_PAUSED 0x1013 241 | #define AL_STOPPED 0x1014 242 | 243 | /** 244 | * Source Buffer Queue size (query only). 245 | * Type: ALint 246 | * 247 | * The number of buffers queued using alSourceQueueBuffers, minus the buffers 248 | * removed with alSourceUnqueueBuffers. 249 | */ 250 | #define AL_BUFFERS_QUEUED 0x1015 251 | 252 | /** 253 | * Source Buffer Queue processed count (query only). 254 | * Type: ALint 255 | * 256 | * The number of queued buffers that have been fully processed, and can be 257 | * removed with alSourceUnqueueBuffers. 258 | * 259 | * Looping sources will never fully process buffers because they will be set to 260 | * play again for when the source loops. 261 | */ 262 | #define AL_BUFFERS_PROCESSED 0x1016 263 | 264 | /** 265 | * Source reference distance. 266 | * Type: ALfloat 267 | * Range: [0.0 - ] 268 | * Default: 1.0 269 | * 270 | * The distance in units that no attenuation occurs. 271 | * 272 | * At 0.0, no distance attenuation ever occurs on non-linear attenuation models. 273 | */ 274 | #define AL_REFERENCE_DISTANCE 0x1020 275 | 276 | /** 277 | * Source rolloff factor. 278 | * Type: ALfloat 279 | * Range: [0.0 - ] 280 | * Default: 1.0 281 | * 282 | * Multiplier to exaggerate or diminish distance attenuation. 283 | * 284 | * At 0.0, no distance attenuation ever occurs. 285 | */ 286 | #define AL_ROLLOFF_FACTOR 0x1021 287 | 288 | /** 289 | * Outer cone gain. 290 | * Type: ALfloat 291 | * Range: [0.0 - 1.0] 292 | * Default: 0.0 293 | * 294 | * The gain attenuation applied when the listener is outside of the source's 295 | * outer cone. 296 | */ 297 | #define AL_CONE_OUTER_GAIN 0x1022 298 | 299 | /** 300 | * Source maximum distance. 301 | * Type: ALfloat 302 | * Range: [0.0 - ] 303 | * Default: +inf 304 | * 305 | * The distance above which the source is not attenuated any further with a 306 | * clamped distance model, or where attenuation reaches 0.0 gain for linear 307 | * distance models with a default rolloff factor. 308 | */ 309 | #define AL_MAX_DISTANCE 0x1023 310 | 311 | /** Source buffer position, in seconds */ 312 | #define AL_SEC_OFFSET 0x1024 313 | /** Source buffer position, in sample frames */ 314 | #define AL_SAMPLE_OFFSET 0x1025 315 | /** Source buffer position, in bytes */ 316 | #define AL_BYTE_OFFSET 0x1026 317 | 318 | /** 319 | * Source type (query only). 320 | * Type: ALint 321 | * Range: [AL_STATIC, AL_STREAMING, AL_UNDETERMINED] 322 | * 323 | * A Source is Static if a Buffer has been attached using AL_BUFFER. 324 | * 325 | * A Source is Streaming if one or more Buffers have been attached using 326 | * alSourceQueueBuffers. 327 | * 328 | * A Source is Undetermined when it has the NULL buffer attached using 329 | * AL_BUFFER. 330 | */ 331 | #define AL_SOURCE_TYPE 0x1027 332 | 333 | /** Source type value. */ 334 | #define AL_STATIC 0x1028 335 | #define AL_STREAMING 0x1029 336 | #define AL_UNDETERMINED 0x1030 337 | 338 | /** Buffer format specifier. */ 339 | #define AL_FORMAT_MONO8 0x1100 340 | #define AL_FORMAT_MONO16 0x1101 341 | #define AL_FORMAT_STEREO8 0x1102 342 | #define AL_FORMAT_STEREO16 0x1103 343 | 344 | /** Buffer frequency (query only). */ 345 | #define AL_FREQUENCY 0x2001 346 | /** Buffer bits per sample (query only). */ 347 | #define AL_BITS 0x2002 348 | /** Buffer channel count (query only). */ 349 | #define AL_CHANNELS 0x2003 350 | /** Buffer data size (query only). */ 351 | #define AL_SIZE 0x2004 352 | 353 | /** 354 | * Buffer state. 355 | * 356 | * Not for public use. 357 | */ 358 | #define AL_UNUSED 0x2010 359 | #define AL_PENDING 0x2011 360 | #define AL_PROCESSED 0x2012 361 | 362 | 363 | /** No error. */ 364 | #define AL_NO_ERROR 0 365 | 366 | /** Invalid name paramater passed to AL call. */ 367 | #define AL_INVALID_NAME 0xA001 368 | 369 | /** Invalid enum parameter passed to AL call. */ 370 | #define AL_INVALID_ENUM 0xA002 371 | 372 | /** Invalid value parameter passed to AL call. */ 373 | #define AL_INVALID_VALUE 0xA003 374 | 375 | /** Illegal AL call. */ 376 | #define AL_INVALID_OPERATION 0xA004 377 | 378 | /** Not enough memory. */ 379 | #define AL_OUT_OF_MEMORY 0xA005 380 | 381 | 382 | /** Context string: Vendor ID. */ 383 | #define AL_VENDOR 0xB001 384 | /** Context string: Version. */ 385 | #define AL_VERSION 0xB002 386 | /** Context string: Renderer ID. */ 387 | #define AL_RENDERER 0xB003 388 | /** Context string: Space-separated extension list. */ 389 | #define AL_EXTENSIONS 0xB004 390 | 391 | 392 | /** 393 | * Doppler scale. 394 | * Type: ALfloat 395 | * Range: [0.0 - ] 396 | * Default: 1.0 397 | * 398 | * Scale for source and listener velocities. 399 | */ 400 | #define AL_DOPPLER_FACTOR 0xC000 401 | AL_API void AL_APIENTRY alDopplerFactor(ALfloat value); 402 | 403 | /** 404 | * Doppler velocity (deprecated). 405 | * 406 | * A multiplier applied to the Speed of Sound. 407 | */ 408 | #define AL_DOPPLER_VELOCITY 0xC001 409 | AL_API void AL_APIENTRY alDopplerVelocity(ALfloat value); 410 | 411 | /** 412 | * Speed of Sound, in units per second. 413 | * Type: ALfloat 414 | * Range: [0.0001 - ] 415 | * Default: 343.3 416 | * 417 | * The speed at which sound waves are assumed to travel, when calculating the 418 | * doppler effect. 419 | */ 420 | #define AL_SPEED_OF_SOUND 0xC003 421 | AL_API void AL_APIENTRY alSpeedOfSound(ALfloat value); 422 | 423 | /** 424 | * Distance attenuation model. 425 | * Type: ALint 426 | * Range: [AL_NONE, AL_INVERSE_DISTANCE, AL_INVERSE_DISTANCE_CLAMPED, 427 | * AL_LINEAR_DISTANCE, AL_LINEAR_DISTANCE_CLAMPED, 428 | * AL_EXPONENT_DISTANCE, AL_EXPONENT_DISTANCE_CLAMPED] 429 | * Default: AL_INVERSE_DISTANCE_CLAMPED 430 | * 431 | * The model by which sources attenuate with distance. 432 | * 433 | * None - No distance attenuation. 434 | * Inverse - Doubling the distance halves the source gain. 435 | * Linear - Linear gain scaling between the reference and max distances. 436 | * Exponent - Exponential gain dropoff. 437 | * 438 | * Clamped variations work like the non-clamped counterparts, except the 439 | * distance calculated is clamped between the reference and max distances. 440 | */ 441 | #define AL_DISTANCE_MODEL 0xD000 442 | AL_API void AL_APIENTRY alDistanceModel(ALenum distanceModel); 443 | 444 | /** Distance model value. */ 445 | #define AL_INVERSE_DISTANCE 0xD001 446 | #define AL_INVERSE_DISTANCE_CLAMPED 0xD002 447 | #define AL_LINEAR_DISTANCE 0xD003 448 | #define AL_LINEAR_DISTANCE_CLAMPED 0xD004 449 | #define AL_EXPONENT_DISTANCE 0xD005 450 | #define AL_EXPONENT_DISTANCE_CLAMPED 0xD006 451 | 452 | /** Renderer State management. */ 453 | AL_API void AL_APIENTRY alEnable(ALenum capability); 454 | AL_API void AL_APIENTRY alDisable(ALenum capability); 455 | AL_API ALboolean AL_APIENTRY alIsEnabled(ALenum capability); 456 | 457 | /** State retrieval. */ 458 | AL_API const ALchar* AL_APIENTRY alGetString(ALenum param); 459 | AL_API void AL_APIENTRY alGetBooleanv(ALenum param, ALboolean *values); 460 | AL_API void AL_APIENTRY alGetIntegerv(ALenum param, ALint *values); 461 | AL_API void AL_APIENTRY alGetFloatv(ALenum param, ALfloat *values); 462 | AL_API void AL_APIENTRY alGetDoublev(ALenum param, ALdouble *values); 463 | AL_API ALboolean AL_APIENTRY alGetBoolean(ALenum param); 464 | AL_API ALint AL_APIENTRY alGetInteger(ALenum param); 465 | AL_API ALfloat AL_APIENTRY alGetFloat(ALenum param); 466 | AL_API ALdouble AL_APIENTRY alGetDouble(ALenum param); 467 | 468 | /** 469 | * Error retrieval. 470 | * 471 | * Obtain the first error generated in the AL context since the last check. 472 | */ 473 | AL_API ALenum AL_APIENTRY alGetError(void); 474 | 475 | /** 476 | * Extension support. 477 | * 478 | * Query for the presence of an extension, and obtain any appropriate function 479 | * pointers and enum values. 480 | */ 481 | AL_API ALboolean AL_APIENTRY alIsExtensionPresent(const ALchar *extname); 482 | AL_API void* AL_APIENTRY alGetProcAddress(const ALchar *fname); 483 | AL_API ALenum AL_APIENTRY alGetEnumValue(const ALchar *ename); 484 | 485 | 486 | /** Set Listener parameters */ 487 | AL_API void AL_APIENTRY alListenerf(ALenum param, ALfloat value); 488 | AL_API void AL_APIENTRY alListener3f(ALenum param, ALfloat value1, ALfloat value2, ALfloat value3); 489 | AL_API void AL_APIENTRY alListenerfv(ALenum param, const ALfloat *values); 490 | AL_API void AL_APIENTRY alListeneri(ALenum param, ALint value); 491 | AL_API void AL_APIENTRY alListener3i(ALenum param, ALint value1, ALint value2, ALint value3); 492 | AL_API void AL_APIENTRY alListeneriv(ALenum param, const ALint *values); 493 | 494 | /** Get Listener parameters */ 495 | AL_API void AL_APIENTRY alGetListenerf(ALenum param, ALfloat *value); 496 | AL_API void AL_APIENTRY alGetListener3f(ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3); 497 | AL_API void AL_APIENTRY alGetListenerfv(ALenum param, ALfloat *values); 498 | AL_API void AL_APIENTRY alGetListeneri(ALenum param, ALint *value); 499 | AL_API void AL_APIENTRY alGetListener3i(ALenum param, ALint *value1, ALint *value2, ALint *value3); 500 | AL_API void AL_APIENTRY alGetListeneriv(ALenum param, ALint *values); 501 | 502 | 503 | /** Create Source objects. */ 504 | AL_API void AL_APIENTRY alGenSources(ALsizei n, ALuint *sources); 505 | /** Delete Source objects. */ 506 | AL_API void AL_APIENTRY alDeleteSources(ALsizei n, const ALuint *sources); 507 | /** Verify a handle is a valid Source. */ 508 | AL_API ALboolean AL_APIENTRY alIsSource(ALuint source); 509 | 510 | /** Set Source parameters. */ 511 | AL_API void AL_APIENTRY alSourcef(ALuint source, ALenum param, ALfloat value); 512 | AL_API void AL_APIENTRY alSource3f(ALuint source, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3); 513 | AL_API void AL_APIENTRY alSourcefv(ALuint source, ALenum param, const ALfloat *values); 514 | AL_API void AL_APIENTRY alSourcei(ALuint source, ALenum param, ALint value); 515 | AL_API void AL_APIENTRY alSource3i(ALuint source, ALenum param, ALint value1, ALint value2, ALint value3); 516 | AL_API void AL_APIENTRY alSourceiv(ALuint source, ALenum param, const ALint *values); 517 | 518 | /** Get Source parameters. */ 519 | AL_API void AL_APIENTRY alGetSourcef(ALuint source, ALenum param, ALfloat *value); 520 | AL_API void AL_APIENTRY alGetSource3f(ALuint source, ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3); 521 | AL_API void AL_APIENTRY alGetSourcefv(ALuint source, ALenum param, ALfloat *values); 522 | AL_API void AL_APIENTRY alGetSourcei(ALuint source, ALenum param, ALint *value); 523 | AL_API void AL_APIENTRY alGetSource3i(ALuint source, ALenum param, ALint *value1, ALint *value2, ALint *value3); 524 | AL_API void AL_APIENTRY alGetSourceiv(ALuint source, ALenum param, ALint *values); 525 | 526 | 527 | /** Play, replay, or resume (if paused) a list of Sources */ 528 | AL_API void AL_APIENTRY alSourcePlayv(ALsizei n, const ALuint *sources); 529 | /** Stop a list of Sources */ 530 | AL_API void AL_APIENTRY alSourceStopv(ALsizei n, const ALuint *sources); 531 | /** Rewind a list of Sources */ 532 | AL_API void AL_APIENTRY alSourceRewindv(ALsizei n, const ALuint *sources); 533 | /** Pause a list of Sources */ 534 | AL_API void AL_APIENTRY alSourcePausev(ALsizei n, const ALuint *sources); 535 | 536 | /** Play, replay, or resume a Source */ 537 | AL_API void AL_APIENTRY alSourcePlay(ALuint source); 538 | /** Stop a Source */ 539 | AL_API void AL_APIENTRY alSourceStop(ALuint source); 540 | /** Rewind a Source (set playback postiton to beginning) */ 541 | AL_API void AL_APIENTRY alSourceRewind(ALuint source); 542 | /** Pause a Source */ 543 | AL_API void AL_APIENTRY alSourcePause(ALuint source); 544 | 545 | /** Queue buffers onto a source */ 546 | AL_API void AL_APIENTRY alSourceQueueBuffers(ALuint source, ALsizei nb, const ALuint *buffers); 547 | /** Unqueue processed buffers from a source */ 548 | AL_API void AL_APIENTRY alSourceUnqueueBuffers(ALuint source, ALsizei nb, ALuint *buffers); 549 | 550 | 551 | /** Create Buffer objects */ 552 | AL_API void AL_APIENTRY alGenBuffers(ALsizei n, ALuint *buffers); 553 | /** Delete Buffer objects */ 554 | AL_API void AL_APIENTRY alDeleteBuffers(ALsizei n, const ALuint *buffers); 555 | /** Verify a handle is a valid Buffer */ 556 | AL_API ALboolean AL_APIENTRY alIsBuffer(ALuint buffer); 557 | 558 | /** Specifies the data to be copied into a buffer */ 559 | AL_API void AL_APIENTRY alBufferData(ALuint buffer, ALenum format, const ALvoid *data, ALsizei size, ALsizei freq); 560 | 561 | /** Set Buffer parameters, */ 562 | AL_API void AL_APIENTRY alBufferf(ALuint buffer, ALenum param, ALfloat value); 563 | AL_API void AL_APIENTRY alBuffer3f(ALuint buffer, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3); 564 | AL_API void AL_APIENTRY alBufferfv(ALuint buffer, ALenum param, const ALfloat *values); 565 | AL_API void AL_APIENTRY alBufferi(ALuint buffer, ALenum param, ALint value); 566 | AL_API void AL_APIENTRY alBuffer3i(ALuint buffer, ALenum param, ALint value1, ALint value2, ALint value3); 567 | AL_API void AL_APIENTRY alBufferiv(ALuint buffer, ALenum param, const ALint *values); 568 | 569 | /** Get Buffer parameters. */ 570 | AL_API void AL_APIENTRY alGetBufferf(ALuint buffer, ALenum param, ALfloat *value); 571 | AL_API void AL_APIENTRY alGetBuffer3f(ALuint buffer, ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3); 572 | AL_API void AL_APIENTRY alGetBufferfv(ALuint buffer, ALenum param, ALfloat *values); 573 | AL_API void AL_APIENTRY alGetBufferi(ALuint buffer, ALenum param, ALint *value); 574 | AL_API void AL_APIENTRY alGetBuffer3i(ALuint buffer, ALenum param, ALint *value1, ALint *value2, ALint *value3); 575 | AL_API void AL_APIENTRY alGetBufferiv(ALuint buffer, ALenum param, ALint *values); 576 | 577 | /** Pointer-to-function type, useful for dynamically getting AL entry points. */ 578 | typedef void (AL_APIENTRY *LPALENABLE)(ALenum capability); 579 | typedef void (AL_APIENTRY *LPALDISABLE)(ALenum capability); 580 | typedef ALboolean (AL_APIENTRY *LPALISENABLED)(ALenum capability); 581 | typedef const ALchar* (AL_APIENTRY *LPALGETSTRING)(ALenum param); 582 | typedef void (AL_APIENTRY *LPALGETBOOLEANV)(ALenum param, ALboolean *values); 583 | typedef void (AL_APIENTRY *LPALGETINTEGERV)(ALenum param, ALint *values); 584 | typedef void (AL_APIENTRY *LPALGETFLOATV)(ALenum param, ALfloat *values); 585 | typedef void (AL_APIENTRY *LPALGETDOUBLEV)(ALenum param, ALdouble *values); 586 | typedef ALboolean (AL_APIENTRY *LPALGETBOOLEAN)(ALenum param); 587 | typedef ALint (AL_APIENTRY *LPALGETINTEGER)(ALenum param); 588 | typedef ALfloat (AL_APIENTRY *LPALGETFLOAT)(ALenum param); 589 | typedef ALdouble (AL_APIENTRY *LPALGETDOUBLE)(ALenum param); 590 | typedef ALenum (AL_APIENTRY *LPALGETERROR)(void); 591 | typedef ALboolean (AL_APIENTRY *LPALISEXTENSIONPRESENT)(const ALchar *extname); 592 | typedef void* (AL_APIENTRY *LPALGETPROCADDRESS)(const ALchar *fname); 593 | typedef ALenum (AL_APIENTRY *LPALGETENUMVALUE)(const ALchar *ename); 594 | typedef void (AL_APIENTRY *LPALLISTENERF)(ALenum param, ALfloat value); 595 | typedef void (AL_APIENTRY *LPALLISTENER3F)(ALenum param, ALfloat value1, ALfloat value2, ALfloat value3); 596 | typedef void (AL_APIENTRY *LPALLISTENERFV)(ALenum param, const ALfloat *values); 597 | typedef void (AL_APIENTRY *LPALLISTENERI)(ALenum param, ALint value); 598 | typedef void (AL_APIENTRY *LPALLISTENER3I)(ALenum param, ALint value1, ALint value2, ALint value3); 599 | typedef void (AL_APIENTRY *LPALLISTENERIV)(ALenum param, const ALint *values); 600 | typedef void (AL_APIENTRY *LPALGETLISTENERF)(ALenum param, ALfloat *value); 601 | typedef void (AL_APIENTRY *LPALGETLISTENER3F)(ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3); 602 | typedef void (AL_APIENTRY *LPALGETLISTENERFV)(ALenum param, ALfloat *values); 603 | typedef void (AL_APIENTRY *LPALGETLISTENERI)(ALenum param, ALint *value); 604 | typedef void (AL_APIENTRY *LPALGETLISTENER3I)(ALenum param, ALint *value1, ALint *value2, ALint *value3); 605 | typedef void (AL_APIENTRY *LPALGETLISTENERIV)(ALenum param, ALint *values); 606 | typedef void (AL_APIENTRY *LPALGENSOURCES)(ALsizei n, ALuint *sources); 607 | typedef void (AL_APIENTRY *LPALDELETESOURCES)(ALsizei n, const ALuint *sources); 608 | typedef ALboolean (AL_APIENTRY *LPALISSOURCE)(ALuint source); 609 | typedef void (AL_APIENTRY *LPALSOURCEF)(ALuint source, ALenum param, ALfloat value); 610 | typedef void (AL_APIENTRY *LPALSOURCE3F)(ALuint source, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3); 611 | typedef void (AL_APIENTRY *LPALSOURCEFV)(ALuint source, ALenum param, const ALfloat *values); 612 | typedef void (AL_APIENTRY *LPALSOURCEI)(ALuint source, ALenum param, ALint value); 613 | typedef void (AL_APIENTRY *LPALSOURCE3I)(ALuint source, ALenum param, ALint value1, ALint value2, ALint value3); 614 | typedef void (AL_APIENTRY *LPALSOURCEIV)(ALuint source, ALenum param, const ALint *values); 615 | typedef void (AL_APIENTRY *LPALGETSOURCEF)(ALuint source, ALenum param, ALfloat *value); 616 | typedef void (AL_APIENTRY *LPALGETSOURCE3F)(ALuint source, ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3); 617 | typedef void (AL_APIENTRY *LPALGETSOURCEFV)(ALuint source, ALenum param, ALfloat *values); 618 | typedef void (AL_APIENTRY *LPALGETSOURCEI)(ALuint source, ALenum param, ALint *value); 619 | typedef void (AL_APIENTRY *LPALGETSOURCE3I)(ALuint source, ALenum param, ALint *value1, ALint *value2, ALint *value3); 620 | typedef void (AL_APIENTRY *LPALGETSOURCEIV)(ALuint source, ALenum param, ALint *values); 621 | typedef void (AL_APIENTRY *LPALSOURCEPLAYV)(ALsizei n, const ALuint *sources); 622 | typedef void (AL_APIENTRY *LPALSOURCESTOPV)(ALsizei n, const ALuint *sources); 623 | typedef void (AL_APIENTRY *LPALSOURCEREWINDV)(ALsizei n, const ALuint *sources); 624 | typedef void (AL_APIENTRY *LPALSOURCEPAUSEV)(ALsizei n, const ALuint *sources); 625 | typedef void (AL_APIENTRY *LPALSOURCEPLAY)(ALuint source); 626 | typedef void (AL_APIENTRY *LPALSOURCESTOP)(ALuint source); 627 | typedef void (AL_APIENTRY *LPALSOURCEREWIND)(ALuint source); 628 | typedef void (AL_APIENTRY *LPALSOURCEPAUSE)(ALuint source); 629 | typedef void (AL_APIENTRY *LPALSOURCEQUEUEBUFFERS)(ALuint source, ALsizei nb, const ALuint *buffers); 630 | typedef void (AL_APIENTRY *LPALSOURCEUNQUEUEBUFFERS)(ALuint source, ALsizei nb, ALuint *buffers); 631 | typedef void (AL_APIENTRY *LPALGENBUFFERS)(ALsizei n, ALuint *buffers); 632 | typedef void (AL_APIENTRY *LPALDELETEBUFFERS)(ALsizei n, const ALuint *buffers); 633 | typedef ALboolean (AL_APIENTRY *LPALISBUFFER)(ALuint buffer); 634 | typedef void (AL_APIENTRY *LPALBUFFERDATA)(ALuint buffer, ALenum format, const ALvoid *data, ALsizei size, ALsizei freq); 635 | typedef void (AL_APIENTRY *LPALBUFFERF)(ALuint buffer, ALenum param, ALfloat value); 636 | typedef void (AL_APIENTRY *LPALBUFFER3F)(ALuint buffer, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3); 637 | typedef void (AL_APIENTRY *LPALBUFFERFV)(ALuint buffer, ALenum param, const ALfloat *values); 638 | typedef void (AL_APIENTRY *LPALBUFFERI)(ALuint buffer, ALenum param, ALint value); 639 | typedef void (AL_APIENTRY *LPALBUFFER3I)(ALuint buffer, ALenum param, ALint value1, ALint value2, ALint value3); 640 | typedef void (AL_APIENTRY *LPALBUFFERIV)(ALuint buffer, ALenum param, const ALint *values); 641 | typedef void (AL_APIENTRY *LPALGETBUFFERF)(ALuint buffer, ALenum param, ALfloat *value); 642 | typedef void (AL_APIENTRY *LPALGETBUFFER3F)(ALuint buffer, ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3); 643 | typedef void (AL_APIENTRY *LPALGETBUFFERFV)(ALuint buffer, ALenum param, ALfloat *values); 644 | typedef void (AL_APIENTRY *LPALGETBUFFERI)(ALuint buffer, ALenum param, ALint *value); 645 | typedef void (AL_APIENTRY *LPALGETBUFFER3I)(ALuint buffer, ALenum param, ALint *value1, ALint *value2, ALint *value3); 646 | typedef void (AL_APIENTRY *LPALGETBUFFERIV)(ALuint buffer, ALenum param, ALint *values); 647 | typedef void (AL_APIENTRY *LPALDOPPLERFACTOR)(ALfloat value); 648 | typedef void (AL_APIENTRY *LPALDOPPLERVELOCITY)(ALfloat value); 649 | typedef void (AL_APIENTRY *LPALSPEEDOFSOUND)(ALfloat value); 650 | typedef void (AL_APIENTRY *LPALDISTANCEMODEL)(ALenum distanceModel); 651 | 652 | #define AL_EXT_TRACE_INFO 1 653 | typedef void (AL_APIENTRY *LPALTRACEPUSHSCOPE)(const ALchar *str); 654 | typedef void (AL_APIENTRY *LPALTRACEPOPSCOPE)(void); 655 | typedef void (AL_APIENTRY *LPALTRACEMESSAGE)(const ALchar *str); 656 | typedef void (AL_APIENTRY *LPALTRACEBUFFERLABEL)(ALuint name, const ALchar *str); 657 | typedef void (AL_APIENTRY *LPALTRACESOURCELABEL)(ALuint name, const ALchar *str); 658 | 659 | #if defined(__cplusplus) 660 | } /* extern "C" */ 661 | #endif 662 | 663 | #endif /* AL_AL_H */ 664 | -------------------------------------------------------------------------------- /phamt.h: -------------------------------------------------------------------------------- 1 | /** 2 | * alTrace; a debugging tool for OpenAL. 3 | * 4 | * Please see the file LICENSE.txt in the source's root directory. 5 | * 6 | * This file written by Ryan C. Gordon. 7 | */ 8 | 9 | /** 10 | * \file phamt.h 11 | * \author Ryan C. Gordon. 12 | * \brief Templated Persistent Hash-Array-Mapped Trie 13 | */ 14 | 15 | #ifndef _INCL_PHAMT_H_ 16 | #define _INCL_PHAMT_H_ 17 | 18 | #include 19 | 20 | #define Assert assert 21 | 22 | template 23 | uint32 hashCalculate(const MapFrom &from); 24 | 25 | template 26 | bool hashFromMatch(const MapFrom &obj1, const MapFrom &obj2); 27 | 28 | 29 | 30 | // https://www.youtube.com/watch?v=WT9kmIE3Uis 31 | 32 | template 33 | class PersistentTrie 34 | { 35 | public: 36 | PersistentTrie() 37 | : generation(0) 38 | , root(new BranchNode(0)) 39 | , numbranches(1) 40 | , numleaves(0) 41 | , numbuckets(0) 42 | {} 43 | 44 | ~PersistentTrie() 45 | { 46 | root->unref(); 47 | } 48 | 49 | // Copy construction just does a shallow copy, and increments the root refcount and generation. 50 | // Both the original and copy can then modify the tree without stepping on each other. 51 | PersistentTrie(const PersistentTrie &m) 52 | : generation(m.generation + 1) 53 | , root(m.root) 54 | , numbranches(m.numbranches) 55 | , numleaves(m.numleaves) 56 | , numbuckets(m.numbuckets) 57 | { 58 | root->addref(); 59 | } 60 | 61 | bool isEmpty() const { return numleaves == 0; } 62 | uint32 count() const { return numleaves; } 63 | 64 | // this either inserts or updates 65 | MapTo &put(const MapFrom &from, const MapTo &to) 66 | { 67 | FindLeafData data; 68 | LeafNode *leaf = findLeaf(from, data); 69 | 70 | if (!leaf) // doesn't exist, have to create a new leaf. 71 | { 72 | leaf = new LeafNode(generation, from, to); 73 | addToAncestors(leaf, data); 74 | numleaves++; 75 | } 76 | else // found a leaf for this hash. 77 | { 78 | if (hashFromMatch(from, leaf->from)) // this is the correct leaf; it's an update. 79 | { 80 | // we always replace the leaf here so we don't have one path where we don't use the copy constructor. 81 | leaf = new LeafNode(generation, from, to); 82 | replaceAncestors(leaf, data); 83 | } 84 | else // not the correct leaf! Need to split into a new branch! 85 | { 86 | LeafNode *leaf1; 87 | if (leaf->generation != generation) // from a previous snapshot, so duplicate it. 88 | leaf1 = new LeafNode(generation, leaf->from, leaf->to); 89 | else 90 | { 91 | leaf1 = (LeafNode *) leaf->addref(); // replaceAncestors will unref this in a moment. 92 | } 93 | 94 | LeafNode *leaf2 = new LeafNode(generation, from, to); 95 | numleaves++; 96 | 97 | 98 | const uint32 oldhash = hashCalculate(leaf->from) & 0x3fffffff; // "& 0x3fffffff" == ignore top 2 bits. 99 | 100 | // if both leaves match for more than one extra branch, we might need to build out more tree. 101 | while (1) 102 | { 103 | const uint32 sparseidx1 = (oldhash >> (data.numAncestors * 5)) & 31; 104 | const uint32 sparseidx2 = (data.hash >> (data.numAncestors * 5)) & 31; 105 | if (sparseidx1 != sparseidx2) // okay, no collision, add it all. 106 | { 107 | BranchNode *branch = new BranchNode(generation, (1 << sparseidx1) | (1 << sparseidx2), new Node*[2]); 108 | branch->children[0] = (sparseidx1 < sparseidx2) ? leaf1 : leaf2; 109 | branch->children[1] = (sparseidx1 < sparseidx2) ? leaf2 : leaf1; 110 | replaceAncestors(branch, data); 111 | numbranches++; 112 | leaf = leaf2; 113 | break; 114 | } 115 | 116 | // collision, need another branch! 117 | 118 | // if this is a full hash collision, we need a node to act as a bucket so both leaves 119 | // can live at the same hash. 120 | else if (data.numAncestors >= 6) 121 | { 122 | Assert(oldhash == data.hash); 123 | Node *parent = data.ancestors[data.numAncestors-1]; 124 | if (parent->nodetype == NODETYPE_BRANCH) 125 | { 126 | Assert(data.numAncestors == 6); // we use 30 bits for the hash. 127 | BucketNode *bucket = new BucketNode(generation, new LeafNode*[2], 2); 128 | bucket->leaves[0] = leaf1; 129 | bucket->leaves[1] = leaf2; 130 | replaceAncestors(bucket, data); 131 | Assert(data.numAncestors < (sizeof (data.ancestors) / sizeof (data.ancestors[0]))); 132 | data.ancestors[data.numAncestors++] = bucket; 133 | numbuckets++; 134 | } 135 | else 136 | { 137 | Assert(parent->nodetype == NODETYPE_BUCKET); 138 | Assert(data.numAncestors == 7); // we use 30 bits for the hash, but treat the bucket as an extra ancestor. 139 | 140 | BucketNode *bucket = (BucketNode *) parent; 141 | const uint32 numleaves = bucket->numleaves; 142 | LeafNode **leaves = new LeafNode*[numleaves + 1]; 143 | for (uint32 i = 0; i < numleaves; i++) 144 | leaves[i] = bucket->leaves[i]; 145 | leaves[numleaves] = leaf2; 146 | 147 | if (bucket->generation != generation) 148 | replaceAncestors(new BucketNode(generation, leaves, numleaves+1), data); 149 | else 150 | { 151 | delete[] bucket->leaves; 152 | bucket->leaves = leaves; 153 | bucket->numleaves++; 154 | if (leaf->generation == generation) 155 | leaf->unref(); // we added a ref up there. :/ 156 | } 157 | } 158 | break; 159 | } 160 | else 161 | { 162 | BranchNode *branch = new BranchNode(generation, (1 << sparseidx1), new Node*[1]); 163 | branch->children[0] = NULL; // replaceAncestors will fix this later. 164 | replaceAncestors(branch, data); 165 | Assert(data.numAncestors < (sizeof (data.ancestors) / sizeof (data.ancestors[0]))); 166 | data.ancestors[data.numAncestors++] = branch; 167 | numbranches++; 168 | } 169 | } 170 | } 171 | } 172 | 173 | return leaf->to; 174 | } 175 | 176 | MapTo *get(const MapFrom &from) const 177 | { 178 | FindLeafData data; 179 | LeafNode *leaf = findLeaf(from, data); 180 | if (leaf) // found a leaf for this hash. 181 | { 182 | if (hashFromMatch(from, leaf->from)) // this is the correct leaf; we're done! 183 | return &leaf->to; 184 | } 185 | return NULL; // We don't have this specific thing. 186 | } 187 | 188 | MapTo *get(const MapFrom &from, MapTo &deflt) const 189 | { 190 | MapTo *to = get(from); 191 | return to ? to : &deflt; 192 | } 193 | 194 | void remove(const MapFrom &from) 195 | { 196 | FindLeafData data; 197 | LeafNode *leaf = findLeaf(from, data); 198 | if (leaf && hashFromMatch(from, leaf->from)) // found the correct leaf; nuke it. 199 | { 200 | removeFromAncestors(leaf, data); 201 | numleaves--; 202 | } 203 | } 204 | 205 | void flush() 206 | { 207 | generation++; 208 | root->unref(); 209 | root = new BranchNode(generation); 210 | numbranches = 1; 211 | numleaves = 0; 212 | } 213 | 214 | PersistentTrie *snapshot() 215 | { 216 | generation++; 217 | return new PersistentTrie(*this); 218 | } 219 | 220 | typedef void (*IterFunc)(const MapFrom &from, MapTo &to, void *data); 221 | 222 | void iterate(IterFunc iter, void *userdata=NULL) 223 | { 224 | iterateBranch(root, iter, userdata); 225 | } 226 | 227 | // !!! FIXME: cull() not implemented: can't change the tree while walking it, since it might make new revisions of nodes we're walking. 228 | 229 | private: 230 | enum NodeType { NODETYPE_BRANCH, NODETYPE_LEAF, NODETYPE_BUCKET }; 231 | 232 | struct Node 233 | { 234 | Node *addref() { Assert(refcount > 0); refcount++; return this; } 235 | void unref() { Assert(refcount > 0); if (--refcount == 0) { delete this; } } 236 | 237 | const NodeType nodetype; 238 | const uint32 generation; 239 | uint32 refcount; 240 | 241 | protected: // construct subclasses instead, please. 242 | Node(const NodeType _nodetype, const uint32 _gen) : nodetype(_nodetype), generation(_gen), refcount(1) {} 243 | 244 | // !!! FIXME: lose the vtable 245 | virtual ~Node() {} // use unref() when you are done. Unref everything and this will delete. 246 | }; 247 | 248 | struct LeafNode : public Node 249 | { 250 | LeafNode(const uint32 _gen, const MapFrom &_from, const MapTo &_to) 251 | : Node(NODETYPE_LEAF, _gen), from(_from), to(_to) {} 252 | virtual ~LeafNode() {} 253 | MapFrom from; 254 | MapTo to; 255 | }; 256 | 257 | struct BranchNode : public Node 258 | { 259 | BranchNode(const uint32 _gen, const uint32 _sparsemap=0, Node **_children=NULL) 260 | : Node(NODETYPE_BRANCH, _gen), sparsemap(_sparsemap), children(_children) {} 261 | 262 | virtual ~BranchNode() 263 | { 264 | const int numkids = popcount(sparsemap); 265 | for (int i = 0; i < numkids; i++) { 266 | children[i]->unref(); 267 | } 268 | delete[] children; 269 | } 270 | 271 | uint32 sparsemap; 272 | Node **children; 273 | }; 274 | 275 | struct BucketNode : public Node 276 | { 277 | BucketNode(const uint32 _gen, LeafNode **_leaves, const uint32 _numleaves) 278 | : Node(NODETYPE_BUCKET, _gen), leaves(_leaves), numleaves(_numleaves) {} 279 | 280 | virtual ~BucketNode() 281 | { 282 | for (uint32 i = 0; i < numleaves; i++) { 283 | leaves[i]->unref(); 284 | } 285 | delete[] leaves; 286 | } 287 | 288 | LeafNode **leaves; 289 | uint32 numleaves; 290 | }; 291 | 292 | 293 | struct FindLeafData 294 | { 295 | int numAncestors; 296 | Node *ancestors[8]; 297 | uint32 hash; 298 | }; 299 | 300 | uint32 generation; 301 | BranchNode *root; 302 | uint32 numbranches; 303 | uint32 numleaves; 304 | uint32 numbuckets; 305 | 306 | static inline int popcount(const uint32 x) 307 | { 308 | // !!! FIXME: on Intel targets, MSVC has __popcnt in . This is considered an SSE 4.2 instruction (~2008...the start of the "Core" line of CPUs). 309 | // __builtin_popcount has a software fallback for non-Intel systems and x86 without the opcode. 310 | #if defined(__GNUC__) || defined(__clang__) 311 | return __builtin_popcount((unsigned int) x); 312 | #else 313 | // Hamming Weight in C: https://stackoverflow.com/a/109025 314 | x = x - ((x >> 1) & 0x55555555); 315 | x = (x & 0x33333333) + ((x >> 2) & 0x33333333); 316 | return (int) ((((x + (x >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24); 317 | #endif 318 | } 319 | 320 | static inline int sparseToCompact(const uint32 sparsemap, const int sparseidx) 321 | { 322 | const uint32 mask = (1 << sparseidx) - 1; 323 | const int retval = popcount(sparsemap & mask); 324 | Assert(retval >= 0); 325 | Assert(retval < 32); 326 | return retval; 327 | } 328 | 329 | void replaceAncestors(Node *child, FindLeafData &data) 330 | { 331 | //printf("REPLACE ANCESTORS\n"); 332 | if (data.numAncestors == 0) { 333 | Assert(child->nodetype == NODETYPE_BRANCH); 334 | root->unref(); 335 | root = (BranchNode *) child; 336 | return; 337 | } 338 | 339 | Assert(data.ancestors[0] == root); 340 | Assert(data.numAncestors <= (sizeof (data.ancestors) / sizeof (data.ancestors[0]))); 341 | int start = data.numAncestors-1; 342 | 343 | // might be a bucket right at the start... 344 | if (data.ancestors[start]->nodetype == NODETYPE_BUCKET) 345 | { 346 | Assert(child->nodetype == NODETYPE_LEAF); 347 | BucketNode *bucket = (BucketNode *) data.ancestors[start]; 348 | LeafNode *leaf = (LeafNode *) child; 349 | const uint32 numleaves = bucket->numleaves; 350 | uint32 pos; 351 | for (pos = 0; pos < numleaves; pos++) 352 | { 353 | if (hashFromMatch(bucket->leaves[pos]->from, leaf->from)) 354 | break; 355 | } 356 | 357 | Assert(pos < numleaves); 358 | 359 | bucket->leaves[pos]->unref(); 360 | 361 | if (bucket->generation == generation) 362 | bucket->leaves[pos] = leaf; 363 | else 364 | { 365 | Assert(!"write me"); // bucket = new blah(leaves_array_we_copied, blah); ref and unref whatever. 366 | } 367 | 368 | bucket->addref(); // will unref in a moment. 369 | child = bucket; 370 | start--; 371 | } 372 | 373 | for (int i = start; i >= 0; i--) 374 | { 375 | BranchNode *a = (BranchNode *) data.ancestors[i]; 376 | Assert(a->nodetype == NODETYPE_BRANCH); 377 | const int numkids = popcount(a->sparsemap); 378 | const bool samegen = (a->generation == generation); 379 | 380 | const uint32 sparseidx = (data.hash >> (i * 5)) & 31; 381 | Assert(a->sparsemap & (1 << sparseidx)); // has to be a replacement, not an insertion 382 | 383 | const int compactidx = sparseToCompact(a->sparsemap, sparseidx); 384 | 385 | // this assert is no longer valid because we update data.ancestors as we walk back up the tree. 386 | //Assert((i == start) || (a->children[compactidx] == data.ancestors[i+1])); 387 | 388 | if (samegen) 389 | { 390 | if (a->children[compactidx]) // !!! FIXME: is this ever NULL? 391 | a->children[compactidx]->unref(); 392 | a->children[compactidx] = child; 393 | return; // no need to walk further up the tree. 394 | } 395 | 396 | // part of a snapshot, duplicate it. 397 | BranchNode *b = new BranchNode(generation, a->sparsemap, new Node*[numkids]); 398 | 399 | for (int j = 0; j < compactidx; j++) 400 | b->children[j] = a->children[j]->addref(); 401 | 402 | b->children[compactidx] = child; 403 | 404 | for (int j = compactidx+1; j < numkids; j++) 405 | b->children[j] = a->children[j]->addref(); 406 | 407 | //a->unref(); // don't unref here; we'll kill it when we unref it as its parent's child. 408 | 409 | data.ancestors[i] = child = b; 410 | } 411 | 412 | Assert(child->nodetype == NODETYPE_BRANCH); 413 | root->unref(); 414 | root = (BranchNode *) child; 415 | } 416 | 417 | void addToAncestors(LeafNode *child, FindLeafData &data) 418 | { 419 | Assert(data.numAncestors > 0); 420 | const int ancestoridx = data.numAncestors - 1; 421 | BranchNode *branch = (BranchNode *) data.ancestors[ancestoridx]; 422 | const bool samegen = (branch->generation == generation); 423 | 424 | if (branch->nodetype == NODETYPE_BRANCH) 425 | { 426 | const uint32 sparseidx = (data.hash >> (ancestoridx * 5)) & 31; 427 | 428 | Assert((branch->sparsemap & (1 << sparseidx)) == 0); // has to be an insertion, not a replacement. 429 | const uint32 sparsemap = branch->sparsemap | (1 << sparseidx); 430 | const int numkids = popcount(sparsemap); 431 | Node **origkids = branch->children; 432 | Node **newkids = new Node*[numkids]; 433 | 434 | const int before = sparseidx ? popcount(sparsemap & ((1 << sparseidx) - 1)) : 0; // num kids before insertion point. 435 | 436 | if (samegen) // current generation, just update the node. 437 | { 438 | for (int i = 0; i < before; i++) newkids[i] = origkids[i]; 439 | newkids[before] = child; 440 | for (int i = before+1; i < numkids; i++) newkids[i] = origkids[i-1]; 441 | branch->sparsemap = sparsemap; 442 | branch->children = newkids; 443 | delete[] origkids; 444 | } 445 | else // part of a snapshot, duplicate it. 446 | { 447 | for (int i = 0; i < before; i++) newkids[i] = origkids[i]->addref(); 448 | newkids[before] = child; 449 | for (int i = before+1; i < numkids; i++) newkids[i] = origkids[i-1]->addref(); 450 | data.numAncestors--; 451 | replaceAncestors(new BranchNode(generation, sparsemap, newkids), data); 452 | data.numAncestors++; 453 | } 454 | } 455 | else if (branch->nodetype == NODETYPE_BUCKET) 456 | { 457 | BucketNode *bucket = (BucketNode *) branch; 458 | Assert(child->nodetype == NODETYPE_LEAF); 459 | const uint32 numleaves = bucket->numleaves; 460 | LeafNode **leaves = new LeafNode*[numleaves+1]; 461 | if (samegen) // current generation, just update the node. 462 | { 463 | for (uint32 i = 0; i < numleaves; i++) 464 | { 465 | Assert(bucket->leaves[i] != child); 466 | leaves[i] = bucket->leaves[i]; 467 | } 468 | leaves[numleaves] = child; 469 | delete[] bucket->leaves; 470 | bucket->leaves = leaves; 471 | bucket->numleaves++; 472 | } 473 | else 474 | { 475 | for (uint32 i = 0; i < numleaves; i++) 476 | { 477 | Assert(bucket->leaves[i] != child); 478 | leaves[i] = (LeafNode *) bucket->leaves[i]->addref(); 479 | } 480 | leaves[numleaves] = child; 481 | 482 | data.numAncestors--; 483 | replaceAncestors(new BucketNode(generation, leaves, bucket->numleaves+1), data); 484 | data.numAncestors++; 485 | } 486 | } 487 | else 488 | { 489 | Assert(!"Unexpected node type"); 490 | } 491 | } 492 | 493 | void removeFromAncestors(LeafNode *leaf, const FindLeafData &data) 494 | { 495 | Assert(data.numAncestors > 0); 496 | const int ancestoridx = data.numAncestors - 1; 497 | BranchNode *branch = data.ancestors[ancestoridx]; 498 | const bool samegen = (branch->generation == generation); 499 | 500 | if (branch->nodetype == NODETYPE_BRANCH) 501 | { 502 | const uint32 sparseidx = (data.hash >> (ancestoridx * 5)) & 31; 503 | Assert((branch->sparsemap & (1 << sparseidx)) != 0); // has to be a removal. 504 | const uint32 sparsemap = branch->sparsemap & ~(1 << sparseidx); 505 | const int numkids = popcount(sparsemap); 506 | Node **origkids = branch->children; 507 | Node **newkids = new Node*[numkids]; 508 | 509 | const int before = sparseidx ? popcount(sparsemap & ((1 << sparseidx) - 1)) : 0; // num kids before insertion point. 510 | Assert(origkids[before]->nodetype == NODETYPE_LEAF); 511 | 512 | if (samegen) // current generation, just update the node. 513 | { 514 | for (int i = 0; i < before; i++) newkids[i] = origkids[i]; 515 | for (int i = before; i < numkids; i++) newkids[i] = origkids[i+1]; 516 | branch->sparsemap = sparsemap; 517 | branch->children = newkids; 518 | delete[] origkids; 519 | } 520 | else // part of a snapshot, duplicate it. 521 | { 522 | for (int i = 0; i < before; i++) newkids[i] = origkids[i]->addref(); 523 | for (int i = before; i < numkids; i++) newkids[i] = origkids[i+1]->addref(); 524 | replaceAncestors(new BranchNode(generation, sparsemap, newkids), data); 525 | } 526 | } 527 | else if (branch->nodetype == NODETYPE_BUCKET) 528 | { 529 | BucketNode *bucket = (BucketNode *) branch; 530 | Assert(leaf->nodetype == NODETYPE_LEAF); 531 | const uint32 numleaves = bucket->numleaves; 532 | uint32 pos; 533 | for (pos = 0; pos < numleaves; pos++) 534 | { 535 | if (bucket->leaves[pos] == leaf) 536 | break; 537 | } 538 | 539 | Assert(pos < numleaves); 540 | 541 | if (samegen) // current generation, just update the node. 542 | { 543 | while (pos < numleaves) 544 | { 545 | bucket->leaves[pos] = bucket->leaves[pos+1]; 546 | pos++; 547 | } 548 | bucket->numleaves--; 549 | } 550 | else 551 | { 552 | LeafNode **leaves = new LeafNode*[numleaves-1]; 553 | for (uint32 i = 0; i < pos; i++) leaves[i] = bucket->leaves[i]->addref(); 554 | for (uint32 i = pos; i < numleaves-1; i++) leaves[i] = bucket->leaves[i+1]->addref(); 555 | data.numAncestors--; 556 | replaceAncestors(new BucketNode(generation, leaves, numleaves-1), data); 557 | data.numAncestors++; 558 | } 559 | } 560 | else 561 | { 562 | Assert(!"Unexpected node type"); 563 | } 564 | 565 | leaf->unref(); 566 | } 567 | 568 | LeafNode *findLeaf(const MapFrom &from, FindLeafData &data) const 569 | { 570 | const uint32 hash = hashCalculate(from) & 0x3fffffff; // "& 0x3fffffff" == ignore top 2 bits. 571 | Node *node = root; 572 | 573 | Assert(node != NULL); 574 | 575 | data.numAncestors = 0; 576 | data.hash = hash; 577 | 578 | for (uint32 i = 0; i < 30; i += 5) 579 | { 580 | Assert(node->nodetype == NODETYPE_BRANCH); 581 | BranchNode *branch = (BranchNode *) node; 582 | const uint32 sparseidx = (hash >> i) & 31; 583 | const uint32 bit = 1 << sparseidx; 584 | 585 | Assert(data.numAncestors < (sizeof (data.ancestors) / sizeof (data.ancestors[0]))); 586 | data.ancestors[data.numAncestors++] = branch; 587 | 588 | if ((branch->sparsemap & bit) == 0) // no node here, so this leaf doesn't exist yet. 589 | return NULL; 590 | 591 | else // there's a node here. 592 | { 593 | node = branch->children[sparseToCompact(branch->sparsemap, sparseidx)]; 594 | 595 | // Already a leaf here? Either we found it, or it's a conflict. 596 | switch (node->nodetype) 597 | { 598 | case NODETYPE_BRANCH: 599 | break; // go through the loop again with the deeper branch node. 600 | 601 | case NODETYPE_LEAF: 602 | // Note that this MAY NOT be the leaf you wanted! This is 603 | // just the first leaf that matched the hash. Users of 604 | // this function should call: 605 | // if (hashFromMatch(from, leaf->from)) 606 | // and decide what to do. If writing to the trie, you 607 | // might have a conflict and have to get a new branch 608 | // in there! 609 | return (LeafNode *) node; // This is us; we already exist. 610 | 611 | case NODETYPE_BUCKET: { // total hash collision! 612 | BucketNode *bucket = (BucketNode *) node; 613 | Assert(data.numAncestors < (sizeof (data.ancestors) / sizeof (data.ancestors[0]))); 614 | data.ancestors[data.numAncestors++] = bucket; 615 | for (uint32 j = 0; j < bucket->numleaves; j++) 616 | { 617 | if (hashFromMatch(from, bucket->leaves[j]->from)) 618 | return bucket->leaves[j]; 619 | } 620 | return NULL; // definitely not in the tree. 621 | } 622 | 623 | default: Assert(!"unexpected node type!"); return NULL; 624 | } 625 | } 626 | } 627 | 628 | Assert(!node); // Ran out of hash bits before we ran out of branches?! 629 | return NULL; // really, you should never hit this. 630 | } 631 | 632 | void iterateBranch(BranchNode *branch, IterFunc iter, void *userdata) 633 | { 634 | Node **_node = branch->children; 635 | const int numkids = popcount(branch->sparsemap); 636 | for (int i = 0; i < numkids; i++, _node++) 637 | { 638 | Node *node = *_node; 639 | switch (node->nodetype) 640 | { 641 | case NODETYPE_BRANCH: 642 | iterateBranch((BranchNode *) node, iter, userdata); 643 | break; 644 | case NODETYPE_LEAF: 645 | iter(node->from, node->to, userdata); 646 | break; 647 | case NODETYPE_BUCKET: 648 | for (uint32 j = 0; j < node->numleaves; j++) 649 | iter(node->leaves[j]->from, node->leaves[j]->to, userdata); 650 | break; 651 | } 652 | } 653 | } 654 | 655 | #if 1 656 | void verifyBranch(BranchNode *branch) const 657 | { 658 | Assert(branch->nodetype == NODETYPE_BRANCH); 659 | Node **_node = branch->children; 660 | const int numkids = popcount(branch->sparsemap); 661 | for (int i = 0; i < numkids; i++, _node++) 662 | { 663 | Node *node = *_node; 664 | switch (node->nodetype) 665 | { 666 | case NODETYPE_BRANCH: 667 | verifyBranch((BranchNode *) node); 668 | break; 669 | 670 | case NODETYPE_LEAF: 671 | { 672 | FindLeafData data; 673 | LeafNode *leaf = findLeaf(node->from, data); 674 | Assert(leaf == node); 675 | break; 676 | } 677 | 678 | case NODETYPE_BUCKET: 679 | for (uint32 j = 0; j < node->numleaves; j++) 680 | { 681 | FindLeafData data; 682 | LeafNode *leaf = findLeaf(node->leaves[j]->from, data); 683 | Assert(leaf == node->leaves[j]); 684 | } 685 | break; 686 | } 687 | } 688 | } 689 | public: 690 | void verify() const { verifyBranch(root); printf("VERIFY: %d leaves, %d branches, %d buckets\n", (int) numleaves, (int) numbranches, (int) numbuckets); } 691 | #endif 692 | }; 693 | 694 | #endif 695 | 696 | // end of phamt.h ... 697 | 698 | -------------------------------------------------------------------------------- /altrace_cli.c: -------------------------------------------------------------------------------- 1 | /** 2 | * alTrace; a debugging tool for OpenAL. 3 | * 4 | * Please see the file LICENSE.txt in the source's root directory. 5 | * 6 | * This file written by Ryan C. Gordon. 7 | */ 8 | 9 | #include "altrace_playback.h" 10 | 11 | const char *GAppName = "altrace_cli"; 12 | 13 | static int dump_calls = 1; 14 | static int dump_callers = 0; 15 | static int dump_state_changes = 0; 16 | static int dump_errors = 0; 17 | static int dumping = 1; 18 | static int run_calls = 0; 19 | 20 | void out_of_memory(void) 21 | { 22 | fputs(GAppName, stderr); 23 | fputs(": Out of memory!\n", stderr); 24 | fflush(stderr); 25 | _exit(42); 26 | } 27 | 28 | 29 | static void wait_until(const uint32 ticks) 30 | { 31 | while (now() < ticks) { 32 | usleep(1000); /* keep the pace of the original run */ 33 | } 34 | } 35 | 36 | 37 | // Some metadata visitor things... 38 | 39 | void visit_al_error_event(void *userdata, const ALenum err) 40 | { 41 | if (dump_errors) { 42 | printf("<<< AL ERROR SET HERE: %s >>>\n", alenumString(err)); 43 | } 44 | } 45 | 46 | void visit_alc_error_event(void *userdata, ALCdevice *device, const ALCenum err) 47 | { 48 | if (dump_errors) { 49 | printf("<<< ALC ERROR SET HERE: device=%s %s >>>\n", deviceString(device), alcenumString(err)); 50 | } 51 | } 52 | 53 | void visit_device_state_changed_int(void *userdata, ALCdevice *dev, const ALCenum param, const ALCint newval) 54 | { 55 | if (dump_state_changes) { 56 | printf("<<< DEVICE STATE CHANGE: dev=%s param=%s value=%d >>>\n", deviceString(dev), alcenumString(param), (int) newval); 57 | } 58 | } 59 | 60 | void visit_context_state_changed_enum(void *userdata, ALCcontext *ctx, const ALenum param, const ALenum newval) 61 | { 62 | if (dump_state_changes) { 63 | printf("<<< CONTEXT STATE CHANGE: ctx=%s param=%s value=%s >>>\n", ctxString(ctx), alenumString(param), alenumString(newval)); 64 | } 65 | } 66 | 67 | void visit_context_state_changed_float(void *userdata, ALCcontext *ctx, const ALenum param, const ALfloat newval) 68 | { 69 | if (dump_state_changes) { 70 | printf("<<< CONTEXT STATE CHANGE: ctx=%s param=%s value=%f >>>\n", ctxString(ctx), alenumString(param), newval); 71 | } 72 | } 73 | 74 | void visit_context_state_changed_string(void *userdata, ALCcontext *ctx, const ALenum param, const ALchar *newval) 75 | { 76 | if (dump_state_changes) { 77 | printf("<<< CONTEXT STATE CHANGE: ctx=%s param=%s value=%s >>>\n", ctxString(ctx), alenumString(param), litString(newval)); 78 | } 79 | } 80 | 81 | void visit_listener_state_changed_floatv(void *userdata, ALCcontext *ctx, const ALenum param, const uint32 numfloats, const ALfloat *values) 82 | { 83 | if (dump_state_changes) { 84 | uint32 i; 85 | printf("<<< LISTENER STATE CHANGE: ctx=%s param=%s values={", ctxString(ctx), alenumString(param)); 86 | for (i = 0; i < numfloats; i++) { 87 | printf("%s %f", i > 0 ? "," : "", values[i]); 88 | } 89 | printf("%s} >>>\n", numfloats > 0 ? " " : ""); 90 | } 91 | } 92 | 93 | void visit_source_state_changed_bool(void *userdata, const ALuint name, const ALenum param, const ALboolean newval) 94 | { 95 | if (dump_state_changes) { 96 | printf("<<< SOURCE STATE CHANGE: name=%s param=%s value=%s >>>\n", sourceString(name), alenumString(param), alboolString(newval)); 97 | } 98 | } 99 | 100 | void visit_source_state_changed_enum(void *userdata, const ALuint name, const ALenum param, const ALenum newval) 101 | { 102 | if (dump_state_changes) { 103 | printf("<<< SOURCE STATE CHANGE: name=%s param=%s value=%s >>>\n", sourceString(name), alenumString(param), alenumString(newval)); 104 | } 105 | } 106 | 107 | void visit_source_state_changed_int(void *userdata, const ALuint name, const ALenum param, const ALint newval) 108 | { 109 | if (dump_state_changes) { 110 | printf("<<< SOURCE STATE CHANGE: name=%s param=%s value=%d >>>\n", sourceString(name), alenumString(param), (int) newval); 111 | } 112 | } 113 | 114 | void visit_source_state_changed_uint(void *userdata, const ALuint name, const ALenum param, const ALuint newval) 115 | { 116 | if (dump_state_changes) { 117 | printf("<<< SOURCE STATE CHANGE: name=%s param=%s value=%u >>>\n", sourceString(name), alenumString(param), (uint) newval); 118 | } 119 | } 120 | 121 | void visit_source_state_changed_float(void *userdata, const ALuint name, const ALenum param, const ALfloat newval) 122 | { 123 | if (dump_state_changes) { 124 | printf("<<< SOURCE STATE CHANGE: name=%s param=%s value=%f >>>\n", sourceString(name), alenumString(param), newval); 125 | } 126 | } 127 | 128 | void visit_source_state_changed_float3(void *userdata, const ALuint name, const ALenum param, const ALfloat newval1, const ALfloat newval2, const ALfloat newval3) 129 | { 130 | if (dump_state_changes) { 131 | printf("<<< SOURCE STATE CHANGE: name=%s param=%s value={ %f, %f, %f } >>>\n", sourceString(name), alenumString(param), newval1, newval2, newval3); 132 | } 133 | } 134 | 135 | void visit_buffer_state_changed_int(void *userdata, const ALuint name, const ALenum param, const ALint newval) 136 | { 137 | if (dump_state_changes) { 138 | printf("<<< BUFFER STATE CHANGE: name=%s param=%s value=%d >>>\n", bufferString(name), alenumString(param), (int) newval); 139 | } 140 | } 141 | 142 | void visit_eos(void *userdata, const ALboolean okay, const uint32 ticks) 143 | { 144 | if (run_calls) { 145 | wait_until(ticks); 146 | } 147 | 148 | if (!okay) { 149 | fprintf(stderr, "\n<<< UNEXPECTED LOG ENTRY. BUG? NEW LOG VERSION? CORRUPT FILE? >>>\n"); 150 | fflush(stderr); 151 | } else if (dumping) { 152 | printf("\n<<< END OF TRACE FILE >>>\n"); 153 | fflush(stdout); 154 | } 155 | } 156 | 157 | int visit_progress(void *userdata, const off_t current, const off_t total) 158 | { 159 | return 1; // keep going! 160 | } 161 | 162 | 163 | // Visitors for logging OpenAL calls to stdout... 164 | 165 | static void dump_alcGetCurrentContext(CallerInfo *callerinfo, ALCcontext *retval) 166 | { 167 | printf("() => %s\n", ctxString(retval)); 168 | } 169 | 170 | static void dump_alcGetContextsDevice(CallerInfo *callerinfo, ALCdevice *retval, ALCcontext *context) 171 | { 172 | printf("(%s) => %s\n", ctxString(context), deviceString(retval)); 173 | } 174 | 175 | static void dump_alcIsExtensionPresent(CallerInfo *callerinfo, ALCboolean retval, ALCdevice *device, const ALCchar *extname) 176 | { 177 | printf("(%s, %s) => %s\n", deviceString(device), litString(extname), alcboolString(retval)); 178 | } 179 | 180 | static void dump_alcGetProcAddress(CallerInfo *callerinfo, void *retval, ALCdevice *device, const ALCchar *funcname) 181 | { 182 | printf("(%s, %s) => %s\n", deviceString(device), litString(funcname), ptrString(retval)); 183 | } 184 | 185 | static void dump_alcGetEnumValue(CallerInfo *callerinfo, ALCenum retval, ALCdevice *device, const ALCchar *enumname) 186 | { 187 | printf("(%s, %s) => %s\n", deviceString(device), litString(enumname), alcenumString(retval)); 188 | } 189 | 190 | static void dump_alcGetString(CallerInfo *callerinfo, const ALCchar *retval, ALCdevice *device, ALCenum param) 191 | { 192 | printf("(%s, %s) => %s\n", deviceString(device), alcenumString(param), litString(retval)); 193 | } 194 | 195 | static void dump_alcCaptureOpenDevice(CallerInfo *callerinfo, ALCdevice *retval, const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize, ALint major_version, ALint minor_version, const ALCchar *devspec, const ALCchar *extensions) 196 | { 197 | printf("(%s, %u, %s, %u) => %s\n", litString(devicename), (uint) frequency, alcenumString(format), (uint) buffersize, deviceString(retval)); 198 | if (retval && dump_state_changes) { 199 | printf("<<< CAPTURE DEVICE STATE: alc_version=%d.%d device_specifier=%s extensions=%s >>>\n", (int) major_version, (int) minor_version, litString(devspec), litString(extensions)); 200 | } 201 | } 202 | 203 | static void dump_alcCaptureCloseDevice(CallerInfo *callerinfo, ALCboolean retval, ALCdevice *device) 204 | { 205 | printf("(%s) => %s\n", deviceString(device), alcboolString(retval)); 206 | } 207 | 208 | static void dump_alcOpenDevice(CallerInfo *callerinfo, ALCdevice *retval, const ALCchar *devicename, ALint major_version, ALint minor_version, const ALCchar *devspec, const ALCchar *extensions) 209 | { 210 | printf("(%s) => %s\n", litString(devicename), deviceString(retval)); 211 | if (retval && dump_state_changes) { 212 | printf("<<< PLAYBACK DEVICE STATE: alc_version=%d.%d device_specifier=%s extensions=%s >>>\n", (int) major_version, (int) minor_version, litString(devspec), litString(extensions)); 213 | } 214 | } 215 | 216 | static void dump_alcCloseDevice(CallerInfo *callerinfo, ALCboolean retval, ALCdevice *device) 217 | { 218 | printf("(%s) => %s\n", deviceString(device), alcboolString(retval)); 219 | } 220 | 221 | static void dump_alcCreateContext(CallerInfo *callerinfo, ALCcontext *retval, ALCdevice *device, const ALCint *origattrlist, uint32 attrcount, const ALCint *attrlist) 222 | { 223 | printf("(%s, %s", deviceString(device), ptrString(origattrlist)); 224 | if (origattrlist) { 225 | ALCint i; 226 | printf(" {"); 227 | for (i = 0; i < attrcount; i += 2) { 228 | printf(" %s, %u,", alcenumString(attrlist[i]), (uint) attrlist[i+1]); 229 | } 230 | printf(" 0 }"); 231 | } 232 | printf(") => %s\n", ctxString(retval)); 233 | } 234 | 235 | static void dump_alcMakeContextCurrent(CallerInfo *callerinfo, ALCboolean retval, ALCcontext *ctx) 236 | { 237 | printf("(%s) => %s\n", ctxString(ctx), alcboolString(retval)); 238 | } 239 | 240 | static void dump_alcProcessContext(CallerInfo *callerinfo, ALCcontext *ctx) 241 | { 242 | printf("(%s)\n", ctxString(ctx)); 243 | } 244 | 245 | static void dump_alcSuspendContext(CallerInfo *callerinfo, ALCcontext *ctx) 246 | { 247 | printf("(%s)\n", ctxString(ctx)); 248 | } 249 | 250 | static void dump_alcDestroyContext(CallerInfo *callerinfo, ALCcontext *ctx) 251 | { 252 | printf("(%s)\n", ctxString(ctx)); 253 | } 254 | 255 | static void dump_alcGetError(CallerInfo *callerinfo, ALCenum retval, ALCdevice *device) 256 | { 257 | printf("(%s) => %s\n", deviceString(device), alcboolString(retval)); 258 | } 259 | 260 | static void dump_alcGetIntegerv(CallerInfo *callerinfo, ALCdevice *device, ALCenum param, ALCsizei size, ALCint *origvalues, ALCboolean isbool, ALCint *values) 261 | { 262 | ALCsizei i; 263 | printf("(%s, %s, %u, %s)", deviceString(device), alcenumString(param), (uint) size, ptrString(origvalues)); 264 | if (origvalues) { 265 | printf(" => {"); 266 | for (i = 0; i < size; i++) { 267 | if (isbool) { 268 | printf("%s %s", i > 0 ? "," : "", alcboolString((ALCenum) values[i])); 269 | } else { 270 | printf("%s %d", i > 0 ? "," : "", values[i]); 271 | } 272 | } 273 | printf("%s}", size > 0 ? " " : ""); 274 | } 275 | printf("\n"); 276 | } 277 | 278 | static void dump_alcCaptureStart(CallerInfo *callerinfo, ALCdevice *device) 279 | { 280 | printf("(%s)\n", deviceString(device)); 281 | } 282 | 283 | static void dump_alcCaptureStop(CallerInfo *callerinfo, ALCdevice *device) 284 | { 285 | printf("(%s)\n", deviceString(device)); 286 | } 287 | 288 | static void dump_alcCaptureSamples(CallerInfo *callerinfo, ALCdevice *device, ALCvoid *origbuffer, ALCvoid *buffer, ALCsizei bufferlen, ALCsizei samples) 289 | { 290 | printf("(%s, %s, %u)\n", deviceString(device), ptrString(origbuffer), (uint) samples); 291 | } 292 | 293 | static void dump_alDopplerFactor(CallerInfo *callerinfo, ALfloat value) 294 | { 295 | printf("(%f)\n", value); 296 | } 297 | 298 | static void dump_alDopplerVelocity(CallerInfo *callerinfo, ALfloat value) 299 | { 300 | printf("(%f)\n", value); 301 | } 302 | 303 | static void dump_alSpeedOfSound(CallerInfo *callerinfo, ALfloat value) 304 | { 305 | printf("(%f)\n", value); 306 | } 307 | 308 | static void dump_alDistanceModel(CallerInfo *callerinfo, ALenum model) 309 | { 310 | printf("(%s)\n", alenumString(model)); 311 | } 312 | 313 | static void dump_alEnable(CallerInfo *callerinfo, ALenum capability) 314 | { 315 | printf("(%s)\n", alenumString(capability)); 316 | } 317 | 318 | static void dump_alDisable(CallerInfo *callerinfo, ALenum capability) 319 | { 320 | printf("(%s)\n", alenumString(capability)); 321 | } 322 | 323 | static void dump_alIsEnabled(CallerInfo *callerinfo, ALboolean retval, ALenum capability) 324 | { 325 | printf("(%s) => %s\n", alenumString(capability), alboolString(retval)); 326 | } 327 | 328 | static void dump_alGetString(CallerInfo *callerinfo, const ALchar *retval, const ALenum param) 329 | { 330 | printf("(%s) => %s\n", alenumString(param), litString(retval)); 331 | } 332 | 333 | static void dump_alGetBooleanv(CallerInfo *callerinfo, ALenum param, ALboolean *origvalues, uint32 numvals, ALboolean *values) 334 | { 335 | uint32 i; 336 | printf("(%s, %s) => {", alenumString(param), ptrString(origvalues)); 337 | for (i = 0; i < numvals; i++) { 338 | printf("%s %s", i > 0 ? "," : "", alboolString(values[i])); 339 | } 340 | printf("%s}\n", numvals > 0 ? " " : ""); 341 | } 342 | 343 | static void dump_alGetIntegerv(CallerInfo *callerinfo, ALenum param, ALint *origvalues, uint32 numvals, ALboolean isenum, ALint *values) 344 | { 345 | uint32 i; 346 | printf("(%s, %s) => {", alenumString(param), ptrString(origvalues)); 347 | for (i = 0; i < numvals; i++) { 348 | if (isenum) { 349 | printf("%s %s", i > 0 ? "," : "", alenumString((ALenum) values[i])); 350 | } else { 351 | printf("%s %d", i > 0 ? "," : "", (int) values[i]); 352 | } 353 | } 354 | printf("%s}\n", numvals > 0 ? " " : ""); 355 | } 356 | 357 | static void dump_alGetFloatv(CallerInfo *callerinfo, ALenum param, ALfloat *origvalues, uint32 numvals, ALfloat *values) 358 | { 359 | uint32 i; 360 | printf("(%s, %s) => {", alenumString(param), ptrString(origvalues)); 361 | for (i = 0; i < numvals; i++) { 362 | printf("%s %f", i > 0 ? "," : "", values[i]); 363 | } 364 | printf("%s}\n", numvals > 0 ? " " : ""); 365 | } 366 | 367 | static void dump_alGetDoublev(CallerInfo *callerinfo, ALenum param, ALdouble *origvalues, uint32 numvals, ALdouble *values) 368 | { 369 | uint32 i; 370 | printf("(%s, %s) => {", alenumString(param), ptrString(origvalues)); 371 | for (i = 0; i < numvals; i++) { 372 | printf("%s %f", i > 0 ? "," : "", values[i]); 373 | } 374 | printf("%s}\n", numvals > 0 ? " " : ""); 375 | } 376 | 377 | static void dump_alGetBoolean(CallerInfo *callerinfo, ALboolean retval, ALenum param) 378 | { 379 | printf("(%s) => %s\n", alenumString(param), alboolString(retval)); 380 | } 381 | 382 | static void dump_alGetInteger(CallerInfo *callerinfo, ALint retval, ALenum param) 383 | { 384 | printf("(%s) => %d\n", alenumString(param), (int) retval); 385 | } 386 | 387 | static void dump_alGetFloat(CallerInfo *callerinfo, ALfloat retval, ALenum param) 388 | { 389 | printf("(%s) => %f\n", alenumString(param), retval); 390 | } 391 | 392 | static void dump_alGetDouble(CallerInfo *callerinfo, ALdouble retval, ALenum param) 393 | { 394 | printf("(%s) => %f\n", alenumString(param), retval); 395 | } 396 | 397 | static void dump_alIsExtensionPresent(CallerInfo *callerinfo, ALboolean retval, const ALchar *extname) 398 | { 399 | printf("(%s) => %s\n", litString(extname), alboolString(retval)); 400 | } 401 | 402 | static void dump_alGetError(CallerInfo *callerinfo, ALenum retval) 403 | { 404 | printf("() => %s\n", alenumString(retval)); 405 | } 406 | 407 | static void dump_alGetProcAddress(CallerInfo *callerinfo, void *retval, const ALchar *funcname) 408 | { 409 | printf("(%s) => %s\n", litString(funcname), ptrString(retval)); 410 | } 411 | 412 | static void dump_alGetEnumValue(CallerInfo *callerinfo, ALenum retval, const ALchar *enumname) 413 | { 414 | printf("(%s) => %s\n", litString(enumname), alenumString(retval)); 415 | } 416 | 417 | static void dump_alListenerfv(CallerInfo *callerinfo, ALenum param, const ALfloat *origvalues, uint32 numvals, const ALfloat *values) 418 | { 419 | uint32 i; 420 | printf("(%s, %s", alenumString(param), ptrString(origvalues)); 421 | if (origvalues) { 422 | printf(" {"); 423 | for (i = 0; i < numvals; i++) { 424 | printf("%s %f", i > 0 ? "," : "", values[i]); 425 | } 426 | printf("%s}", numvals > 0 ? " " : ""); 427 | } 428 | printf(")\n"); 429 | } 430 | 431 | static void dump_alListenerf(CallerInfo *callerinfo, ALenum param, ALfloat value) 432 | { 433 | printf("(%s, %f)\n", alenumString(param), value); 434 | } 435 | 436 | static void dump_alListener3f(CallerInfo *callerinfo, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3) 437 | { 438 | printf("(%s, %f, %f, %f)\n", alenumString(param), value1, value2, value3); 439 | } 440 | 441 | static void dump_alListeneriv(CallerInfo *callerinfo, ALenum param, const ALint *origvalues, uint32 numvals, const ALint *values) 442 | { 443 | uint32 i; 444 | printf("(%s, %s", alenumString(param), ptrString(origvalues)); 445 | if (origvalues) { 446 | printf(" {"); 447 | for (i = 0; i < numvals; i++) { 448 | printf("%s %d", i > 0 ? "," : "", (int) values[i]); 449 | } 450 | printf("%s}", numvals > 0 ? " " : ""); 451 | } 452 | printf(")\n"); 453 | } 454 | 455 | static void dump_alListeneri(CallerInfo *callerinfo, ALenum param, ALint value) 456 | { 457 | printf("(%s, %d)\n", alenumString(param), (int) value); 458 | } 459 | 460 | static void dump_alListener3i(CallerInfo *callerinfo, ALenum param, ALint value1, ALint value2, ALint value3) 461 | { 462 | printf("(%s, %d, %d, %d)\n", alenumString(param), (int) value1, (int) value2, (int) value3); 463 | } 464 | 465 | static void dump_alGetListenerfv(CallerInfo *callerinfo, ALenum param, ALfloat *origvalues, uint32 numvals, ALfloat *values) 466 | { 467 | uint32 i; 468 | printf("(%s, %s)", alenumString(param), ptrString(origvalues)); 469 | if (origvalues) { 470 | printf(" => {"); 471 | for (i = 0; i < numvals; i++) { 472 | printf("%s %f", i > 0 ? "," : "", values[i]); 473 | } 474 | printf("%s}", numvals > 0 ? " " : ""); 475 | } 476 | printf("\n"); 477 | } 478 | 479 | static void dump_alGetListenerf(CallerInfo *callerinfo, ALenum param, ALfloat *origvalue, ALfloat value) 480 | { 481 | printf("(%s, %s) => { %f }\n", alenumString(param), ptrString(origvalue), value); 482 | } 483 | 484 | static void dump_alGetListener3f(CallerInfo *callerinfo, ALenum param, ALfloat *origvalue1, ALfloat *origvalue2, ALfloat *origvalue3, ALfloat value1, ALfloat value2, ALfloat value3) 485 | { 486 | printf("(%s, %s, %s, %s) => { %f, %f, %f }\n", alenumString(param), ptrString(origvalue1), ptrString(origvalue2), ptrString(origvalue3), value1, value2, value3); 487 | } 488 | 489 | static void dump_alGetListeneri(CallerInfo *callerinfo, ALenum param, ALint *origvalue, ALint value) 490 | { 491 | printf("(%s, %s) => { %d }\n", alenumString(param), ptrString(origvalue), (int) value); 492 | } 493 | 494 | static void dump_alGetListeneriv(CallerInfo *callerinfo, ALenum param, ALint *origvalues, uint32 numvals, ALint *values) 495 | { 496 | uint32 i; 497 | printf("(%s, %s)", alenumString(param), ptrString(origvalues)); 498 | if (origvalues) { 499 | printf(" => {"); 500 | for (i = 0; i < numvals; i++) { 501 | printf("%s %d", i > 0 ? "," : "", (int) values[i]); 502 | } 503 | printf("%s}", numvals > 0 ? " " : ""); 504 | } 505 | printf("\n"); 506 | } 507 | 508 | static void dump_alGetListener3i(CallerInfo *callerinfo, ALenum param, ALint *origvalue1, ALint *origvalue2, ALint *origvalue3, ALint value1, ALint value2, ALint value3) 509 | { 510 | printf("(%s, %s, %s, %s) => { %d, %d, %d }\n", alenumString(param), ptrString(origvalue1), ptrString(origvalue2), ptrString(origvalue3), (int) value1, (int) value2, (int) value3); 511 | } 512 | 513 | static void dump_alGenSources(CallerInfo *callerinfo, ALsizei n, ALuint *orignames, ALuint *names) 514 | { 515 | ALsizei i; 516 | printf("(%u, %s)", (uint) n, ptrString(orignames)); 517 | if (orignames) { 518 | printf(" => {"); 519 | for (i = 0; i < n; i++) { 520 | #pragma warning can overflow ioblob array 521 | printf("%s %s", i > 0 ? "," : "", sourceString(names[i])); 522 | } 523 | printf("%s}", n > 0 ? " " : ""); 524 | } 525 | printf("\n"); 526 | } 527 | 528 | static void dump_alDeleteSources(CallerInfo *callerinfo, ALsizei n, const ALuint *orignames, const ALuint *names) 529 | { 530 | ALsizei i; 531 | printf("(%u, %s", (uint) n, ptrString(orignames)); 532 | if (orignames) { 533 | printf(" {"); 534 | for (i = 0; i < n; i++) { 535 | #pragma warning can overflow ioblob array 536 | printf("%s %s", i > 0 ? "," : "", sourceString(names[i])); 537 | } 538 | printf("%s}", n > 0 ? " " : ""); 539 | } 540 | printf(")\n"); 541 | } 542 | 543 | static void dump_alIsSource(CallerInfo *callerinfo, ALboolean retval, ALuint name) 544 | { 545 | printf("(%s) => %s\n", sourceString(name), alboolString(retval)); 546 | } 547 | 548 | static void dump_alSourcefv(CallerInfo *callerinfo, ALuint name, ALenum param, const ALfloat *origvalues, uint32 numvals, const ALfloat *values) 549 | { 550 | uint32 i; 551 | printf("(%s, %s, %s", sourceString(name), alenumString(param), ptrString(origvalues)); 552 | if (origvalues) { 553 | printf(" {"); 554 | for (i = 0; i < numvals; i++) { 555 | printf("%s %f", i > 0 ? "," : "", values[i]); 556 | } 557 | printf("%s}", numvals > 0 ? " " : ""); 558 | } 559 | printf(")\n"); 560 | } 561 | 562 | static void dump_alSourcef(CallerInfo *callerinfo, ALuint name, ALenum param, ALfloat value) 563 | { 564 | printf("(%s, %s, %f)\n", sourceString(name), alenumString(param), value); 565 | } 566 | 567 | static void dump_alSource3f(CallerInfo *callerinfo, ALuint name, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3) 568 | { 569 | printf("(%s, %s, %f, %f, %f)\n", sourceString(name), alenumString(param), value1, value2, value3); 570 | } 571 | 572 | static void dump_alSourceiv(CallerInfo *callerinfo, ALuint name, ALenum param, const ALint *origvalues, uint32 numvals, const ALint *values) 573 | { 574 | uint32 i; 575 | printf("(%s, %s, %s", sourceString(name), alenumString(param), ptrString(origvalues)); 576 | if (origvalues) { 577 | printf(" {"); 578 | for (i = 0; i < numvals; i++) { 579 | printf("%s %d", i > 0 ? "," : "", (int) values[i]); 580 | } 581 | printf("%s}", numvals > 0 ? " " : ""); 582 | } 583 | printf(")\n"); 584 | } 585 | 586 | static void dump_alSourcei(CallerInfo *callerinfo, ALuint name, ALenum param, ALint value) 587 | { 588 | if (param == AL_BUFFER) { 589 | printf("(%s, %s, %s)\n", sourceString(name), alenumString(param), bufferString((ALuint) value)); 590 | } else if (param == AL_LOOPING) { 591 | printf("(%s, %s, %s)\n", sourceString(name), alenumString(param), alboolString((ALboolean) value)); 592 | } else if (param == AL_SOURCE_RELATIVE) { 593 | printf("(%s, %s, %s)\n", sourceString(name), alenumString(param), alenumString((ALenum) value)); 594 | } else if (param == AL_SOURCE_TYPE) { 595 | printf("(%s, %s, %s)\n", sourceString(name), alenumString(param), alenumString((ALenum) value)); 596 | } else if (param == AL_SOURCE_STATE) { 597 | printf("(%s, %s, %s)\n", sourceString(name), alenumString(param), alenumString((ALenum) value)); 598 | } else { 599 | printf("(%s, %s, %d)\n", sourceString(name), alenumString(param), (int) value); 600 | } 601 | } 602 | 603 | static void dump_alSource3i(CallerInfo *callerinfo, ALuint name, ALenum param, ALint value1, ALint value2, ALint value3) 604 | { 605 | printf("(%s, %s, %d, %d, %d)\n", sourceString(name), alenumString(param), (int) value1, (int) value2, (int) value3); 606 | } 607 | 608 | static void dump_alGetSourcefv(CallerInfo *callerinfo, ALuint name, ALenum param, ALfloat *origvalues, uint32 numvals, ALfloat *values) 609 | { 610 | uint32 i; 611 | printf("(%s, %s, %s)", sourceString(name), alenumString(param), ptrString(origvalues)); 612 | if (origvalues) { 613 | printf(" => {"); 614 | for (i = 0; i < numvals; i++) { 615 | printf("%s %f", i > 0 ? "," : "", values[i]); 616 | } 617 | printf("%s}", numvals > 0 ? " " : ""); 618 | } 619 | printf("\n"); 620 | } 621 | 622 | static void dump_alGetSourcef(CallerInfo *callerinfo, ALuint name, ALenum param, ALfloat *origvalue, ALfloat value) 623 | { 624 | printf("(%s, %s, %s) => { %f }\n", sourceString(name), alenumString(param), ptrString(origvalue), value); 625 | } 626 | 627 | static void dump_alGetSource3f(CallerInfo *callerinfo, ALuint name, ALenum param, ALfloat *origvalue1, ALfloat *origvalue2, ALfloat *origvalue3, ALfloat value1, ALfloat value2, ALfloat value3) 628 | { 629 | printf("(%s, %s, %s, %s, %s) => { %f, %f, %f }\n", sourceString(name), alenumString(param), ptrString(origvalue1), ptrString(origvalue2), ptrString(origvalue3), value1, value2, value3); 630 | } 631 | 632 | static void dump_alGetSourceiv(CallerInfo *callerinfo, ALuint name, ALenum param, ALboolean isenum, ALint *origvalues, uint32 numvals, ALint *values) 633 | { 634 | uint32 i; 635 | printf("(%s, %s, %s)", sourceString(name), alenumString(param), ptrString(origvalues)); 636 | if (origvalues) { 637 | printf(" => {"); 638 | for (i = 0; i < numvals; i++) { 639 | if (isenum) { 640 | printf("%s %s", i > 0 ? "," : "", alenumString((ALenum) values[i])); 641 | } else { 642 | printf("%s %d", i > 0 ? "," : "", (int) values[i]); 643 | } 644 | } 645 | printf("%s}", numvals > 0 ? " " : ""); 646 | } 647 | printf("\n"); 648 | } 649 | 650 | static void dump_alGetSourcei(CallerInfo *callerinfo, ALuint name, ALenum param, ALboolean isenum, ALint *origvalue, ALint value) 651 | { 652 | if (isenum) { 653 | printf("(%s, %s, %s) => { %s }\n", sourceString(name), alenumString(param), ptrString(origvalue), alenumString((ALenum) value)); 654 | } else { 655 | printf("(%s, %s, %s) => { %d }\n", sourceString(name), alenumString(param), ptrString(origvalue), (int) value); 656 | } 657 | } 658 | 659 | static void dump_alGetSource3i(CallerInfo *callerinfo, ALuint name, ALenum param, ALint *origvalue1, ALint *origvalue2, ALint *origvalue3, ALint value1, ALint value2, ALint value3) 660 | { 661 | printf("(%s, %s, %s, %s, %s) => { %d, %d, %d }\n", sourceString(name), alenumString(param), ptrString(origvalue1), ptrString(origvalue2), ptrString(origvalue3), (int) value1, (int) value2, (int) value3); 662 | } 663 | 664 | static void dump_alSourcePlay(CallerInfo *callerinfo, ALuint name) 665 | { 666 | printf("(%s)\n", sourceString(name)); 667 | } 668 | 669 | static void dump_alSourcePlayv(CallerInfo *callerinfo, ALsizei n, const ALuint *orignames, const ALuint *names) 670 | { 671 | ALsizei i; 672 | printf("(%u, %s", (uint) n, ptrString(orignames)); 673 | if (orignames) { 674 | printf(" {"); 675 | for (i = 0; i < n; i++) { 676 | #pragma warning can overflow ioblob array 677 | printf("%s %s", i > 0 ? "," : "", sourceString(names[i])); 678 | } 679 | printf("%s}", n > 0 ? " " : ""); 680 | } 681 | printf(")\n"); 682 | } 683 | 684 | static void dump_alSourcePause(CallerInfo *callerinfo, ALuint name) 685 | { 686 | printf("(%s)\n", sourceString(name)); 687 | } 688 | 689 | static void dump_alSourcePausev(CallerInfo *callerinfo, ALsizei n, const ALuint *orignames, const ALuint *names) 690 | { 691 | ALsizei i; 692 | printf("(%u, %s", (uint) n, ptrString(orignames)); 693 | if (orignames) { 694 | printf(" {"); 695 | for (i = 0; i < n; i++) { 696 | #pragma warning can overflow ioblob array 697 | printf("%s %s", i > 0 ? "," : "", sourceString(names[i])); 698 | } 699 | printf("%s}", n > 0 ? " " : ""); 700 | } 701 | printf(")\n"); 702 | } 703 | 704 | static void dump_alSourceRewind(CallerInfo *callerinfo, ALuint name) 705 | { 706 | printf("(%s)\n", sourceString(name)); 707 | } 708 | 709 | static void dump_alSourceRewindv(CallerInfo *callerinfo, ALsizei n, const ALuint *orignames, const ALuint *names) 710 | { 711 | ALsizei i; 712 | printf("(%u, %s", (uint) n, ptrString(orignames)); 713 | if (orignames) { 714 | printf(" {"); 715 | for (i = 0; i < n; i++) { 716 | #pragma warning can overflow ioblob array 717 | printf("%s %s", i > 0 ? "," : "", sourceString(names[i])); 718 | } 719 | printf("%s}", n > 0 ? " " : ""); 720 | } 721 | printf(")\n"); 722 | } 723 | 724 | static void dump_alSourceStop(CallerInfo *callerinfo, ALuint name) 725 | { 726 | printf("(%s)\n", sourceString(name)); 727 | } 728 | 729 | static void dump_alSourceStopv(CallerInfo *callerinfo, ALsizei n, const ALuint *orignames, const ALuint *names) 730 | { 731 | ALsizei i; 732 | printf("(%u, %s", (uint) n, ptrString(orignames)); 733 | if (orignames) { 734 | printf(" {"); 735 | for (i = 0; i < n; i++) { 736 | #pragma warning can overflow ioblob array 737 | printf("%s %s", i > 0 ? "," : "", sourceString(names[i])); 738 | } 739 | printf("%s}", n > 0 ? " " : ""); 740 | } 741 | printf(")\n"); 742 | } 743 | 744 | static void dump_alSourceQueueBuffers(CallerInfo *callerinfo, ALuint name, ALsizei nb, const ALuint *origbufnames, const ALuint *bufnames) 745 | { 746 | ALsizei i; 747 | printf("(%s, %u, %s", sourceString(name), (uint) nb, ptrString(origbufnames)); 748 | if (origbufnames) { 749 | printf(" {"); 750 | for (i = 0; i < nb; i++) { 751 | #pragma warning can overflow ioblob array 752 | printf("%s %s", i > 0 ? "," : "", bufferString(bufnames[i])); 753 | } 754 | printf("%s}", nb > 0 ? " " : ""); 755 | } 756 | printf(")\n"); 757 | } 758 | 759 | static void dump_alSourceUnqueueBuffers(CallerInfo *callerinfo, ALuint name, ALsizei nb, ALuint *origbufnames, ALuint *bufnames) 760 | { 761 | ALsizei i; 762 | printf("(%s, %u, %s", sourceString(name), (uint) nb, ptrString(origbufnames)); 763 | if (origbufnames) { 764 | printf(" {"); 765 | for (i = 0; i < nb; i++) { 766 | #pragma warning can overflow ioblob array 767 | printf("%s %s", i > 0 ? "," : "", bufferString(bufnames[i])); 768 | } 769 | printf("%s}", nb > 0 ? " " : ""); 770 | } 771 | printf(")\n"); 772 | } 773 | 774 | static void dump_alGenBuffers(CallerInfo *callerinfo, ALsizei n, ALuint *orignames, ALuint *names) 775 | { 776 | ALsizei i; 777 | printf("(%u, %s)", (uint) n, ptrString(orignames)); 778 | if (orignames) { 779 | printf(" => {"); 780 | for (i = 0; i < n; i++) { 781 | #pragma warning can overflow ioblob array 782 | printf("%s %s", i > 0 ? "," : "", bufferString(names[i])); 783 | } 784 | printf("%s}", n > 0 ? " " : ""); 785 | } 786 | printf("\n"); 787 | } 788 | 789 | static void dump_alDeleteBuffers(CallerInfo *callerinfo, ALsizei n, const ALuint *orignames, const ALuint *names) 790 | { 791 | ALsizei i; 792 | printf("(%u, %s", (uint) n, ptrString(orignames)); 793 | if (orignames) { 794 | printf(" {"); 795 | for (i = 0; i < n; i++) { 796 | #pragma warning can overflow ioblob array 797 | printf("%s %s", i > 0 ? "," : "", bufferString(names[i])); 798 | } 799 | printf("%s}", n > 0 ? " " : ""); 800 | } 801 | printf(")\n"); 802 | } 803 | 804 | static void dump_alIsBuffer(CallerInfo *callerinfo, ALboolean retval, ALuint name) 805 | { 806 | printf("(%s) => %s\n", bufferString(name), alboolString(retval)); 807 | } 808 | 809 | static void dump_alBufferData(CallerInfo *callerinfo, ALuint name, ALenum alfmt, const ALvoid *origdata, const ALvoid *data, ALsizei size, ALsizei freq) 810 | { 811 | printf("(%s, %s, %s, %u, %u)\n", bufferString(name), alenumString(alfmt), ptrString(origdata), (uint) size, (uint) freq); 812 | } 813 | 814 | static void dump_alBufferfv(CallerInfo *callerinfo, ALuint name, ALenum param, const ALfloat *origvalues, uint32 numvals, const ALfloat *values) 815 | { 816 | uint32 i; 817 | printf("(%s, %s, %s", bufferString(name), alenumString(param), ptrString(origvalues)); 818 | if (origvalues) { 819 | printf(" {"); 820 | for (i = 0; i < numvals; i++) { 821 | printf("%s %f", i > 0 ? "," : "", values[i]); 822 | } 823 | printf("%s}", numvals > 0 ? " " : ""); 824 | } 825 | printf(")\n"); 826 | } 827 | 828 | static void dump_alBufferf(CallerInfo *callerinfo, ALuint name, ALenum param, ALfloat value) 829 | { 830 | printf("(%s, %s, %f)\n", bufferString(name), alenumString(param), value); 831 | } 832 | 833 | static void dump_alBuffer3f(CallerInfo *callerinfo, ALuint name, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3) 834 | { 835 | printf("(%s, %s, %f, %f, %f)\n", bufferString(name), alenumString(param), value1, value2, value3); 836 | } 837 | 838 | static void dump_alBufferiv(CallerInfo *callerinfo, ALuint name, ALenum param, const ALint *origvalues, uint32 numvals, const ALint *values) 839 | { 840 | uint32 i; 841 | printf("(%s, %s, %s", bufferString(name), alenumString(param), ptrString(origvalues)); 842 | if (origvalues) { 843 | printf(" {"); 844 | for (i = 0; i < numvals; i++) { 845 | printf("%s %d", i > 0 ? "," : "", (int) values[i]); 846 | } 847 | printf("%s}", numvals > 0 ? " " : ""); 848 | } 849 | printf(")\n"); 850 | } 851 | 852 | static void dump_alBufferi(CallerInfo *callerinfo, ALuint name, ALenum param, ALint value) 853 | { 854 | printf("(%s, %s, %d)\n", bufferString(name), alenumString(param), (int) value); 855 | } 856 | 857 | static void dump_alBuffer3i(CallerInfo *callerinfo, ALuint name, ALenum param, ALint value1, ALint value2, ALint value3) 858 | { 859 | printf("(%s, %s, %d, %d, %d)\n", bufferString(name), alenumString(param), (int) value1, (int) value2, (int) value3); 860 | } 861 | 862 | static void dump_alGetBufferfv(CallerInfo *callerinfo, ALuint name, ALenum param, ALfloat *origvalues, uint32 numvals, ALfloat *values) 863 | { 864 | uint32 i; 865 | printf("(%s, %s, %s)", bufferString(name), alenumString(param), ptrString(origvalues)); 866 | if (origvalues) { 867 | printf(" => {"); 868 | for (i = 0; i < numvals; i++) { 869 | printf("%s %f", i > 0 ? "," : "", values[i]); 870 | } 871 | printf("%s}", numvals > 0 ? " " : ""); 872 | } 873 | printf("\n"); 874 | } 875 | 876 | static void dump_alGetBufferf(CallerInfo *callerinfo, ALuint name, ALenum param, ALfloat *origvalue, ALfloat value) 877 | { 878 | printf("(%s, %s, %s) => { %f }\n", bufferString(name), alenumString(param), ptrString(origvalue), value); 879 | } 880 | 881 | static void dump_alGetBuffer3f(CallerInfo *callerinfo, ALuint name, ALenum param, ALfloat *origvalue1, ALfloat *origvalue2, ALfloat *origvalue3, ALfloat value1, ALfloat value2, ALfloat value3) 882 | { 883 | printf("(%s, %s, %s, %s, %s) => { %f, %f, %f }\n", bufferString(name), alenumString(param), ptrString(origvalue1), ptrString(origvalue2), ptrString(origvalue3), value1, value2, value3); 884 | } 885 | 886 | static void dump_alGetBufferi(CallerInfo *callerinfo, ALuint name, ALenum param, ALint *origvalue, ALint value) 887 | { 888 | printf("(%s, %s, %s) => { %d }\n", bufferString(name), alenumString(param), ptrString(origvalue), (int) value); 889 | } 890 | 891 | static void dump_alGetBuffer3i(CallerInfo *callerinfo, ALuint name, ALenum param, ALint *origvalue1, ALint *origvalue2, ALint *origvalue3, ALint value1, ALint value2, ALint value3) 892 | { 893 | printf("(%s, %s, %s, %s, %s) => { %d, %d, %d }\n", bufferString(name), alenumString(param), ptrString(origvalue1), ptrString(origvalue2), ptrString(origvalue3), (int) value1, (int) value2, (int) value3); 894 | } 895 | 896 | static void dump_alGetBufferiv(CallerInfo *callerinfo, ALuint name, ALenum param, ALint *origvalues, uint32 numvals, ALint *values) 897 | { 898 | uint32 i; 899 | printf("(%s, %s, %s)", bufferString(name), alenumString(param), ptrString(origvalues)); 900 | if (origvalues) { 901 | printf(" => {"); 902 | for (i = 0; i < numvals; i++) { 903 | printf("%s %d", i > 0 ? "," : "", (int) values[i]); 904 | } 905 | printf("%s}", numvals > 0 ? " " : ""); 906 | } 907 | printf("\n"); 908 | } 909 | 910 | static void dump_alTracePushScope(CallerInfo *callerinfo, const ALchar *str) 911 | { 912 | printf("(%s)\n", litString(str)); 913 | } 914 | 915 | static void dump_alTracePopScope(CallerInfo *callerinfo) 916 | { 917 | printf("()\n"); 918 | } 919 | 920 | static void dump_alTraceMessage(CallerInfo *callerinfo, const ALchar *str) 921 | { 922 | printf("(%s)\n", litString(str)); 923 | } 924 | 925 | static void dump_alTraceBufferLabel(CallerInfo *callerinfo, ALuint name, const ALchar *str) 926 | { 927 | printf("(%u, %s)\n", (uint) name, litString(str)); 928 | } 929 | 930 | static void dump_alTraceSourceLabel(CallerInfo *callerinfo, ALuint name, const ALchar *str) 931 | { 932 | printf("(%u, %s)\n", (uint) name, litString(str)); 933 | } 934 | 935 | static void dump_alcTraceDeviceLabel(CallerInfo *callerinfo, ALCdevice *device, const ALCchar *str) 936 | { 937 | printf("(%s, %s)\n", ptrString(device), litString(str)); 938 | } 939 | 940 | static void dump_alcTraceContextLabel(CallerInfo *callerinfo, ALCcontext *ctx, const ALCchar *str) 941 | { 942 | printf("(%s, %s)\n", ptrString(ctx), litString(str)); 943 | } 944 | 945 | 946 | // Visitors for playback on a real OpenAL implementation... 947 | 948 | static void run_alcGetCurrentContext(CallerInfo *callerinfo, ALCcontext *retval) 949 | { 950 | REAL_alcGetCurrentContext(); 951 | } 952 | 953 | static void run_alcGetContextsDevice(CallerInfo *callerinfo, ALCdevice *retval, ALCcontext *ctx) 954 | { 955 | REAL_alcGetContextsDevice(get_mapped_context(ctx)); 956 | } 957 | 958 | static void run_alcIsExtensionPresent(CallerInfo *callerinfo, ALCboolean retval, ALCdevice *device, const ALCchar *extname) 959 | { 960 | REAL_alcIsExtensionPresent(get_mapped_device(device), extname); 961 | } 962 | 963 | static void run_alcGetProcAddress(CallerInfo *callerinfo, void *retval, ALCdevice *device, const ALCchar *funcname) 964 | { 965 | REAL_alcGetProcAddress(get_mapped_device(device), funcname); 966 | } 967 | 968 | static void run_alcGetEnumValue(CallerInfo *callerinfo, ALCenum retval, ALCdevice *device, const ALCchar *enumname) 969 | { 970 | REAL_alcGetEnumValue(get_mapped_device(device), enumname); 971 | } 972 | 973 | static void run_alcGetString(CallerInfo *callerinfo, const ALCchar *retval, ALCdevice *device, ALCenum param) 974 | { 975 | REAL_alcGetString(get_mapped_device(device), param); 976 | } 977 | 978 | static void run_alcCaptureOpenDevice(CallerInfo *callerinfo, ALCdevice *retval, const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize, ALint major_version, ALint minor_version, const ALCchar *devspec, const ALCchar *extensions) 979 | { 980 | ALCdevice *dev = REAL_alcCaptureOpenDevice(devicename, frequency, format, buffersize); 981 | if (!dev && retval) { 982 | fprintf(stderr, "Uhoh, failed to open capture device when original run did!\n"); 983 | if (devicename) { 984 | fprintf(stderr, "Trying NULL device...\n"); 985 | dev = REAL_alcCaptureOpenDevice(NULL, frequency, format, buffersize); 986 | if (!dev) { 987 | fprintf(stderr, "Still no luck. This is probably going to go wrong.\n"); 988 | } else { 989 | fprintf(stderr, "That worked. Carrying on.\n"); 990 | } 991 | } 992 | } 993 | if (dev) { 994 | add_device_to_map(retval, dev); 995 | } 996 | } 997 | 998 | static void run_alcCaptureCloseDevice(CallerInfo *callerinfo, ALCboolean retval, ALCdevice *device) 999 | { 1000 | REAL_alcCaptureCloseDevice(get_mapped_device(device)); 1001 | } 1002 | 1003 | static void run_alcOpenDevice(CallerInfo *callerinfo, ALCdevice *retval, const ALCchar *devicename, ALint major_version, ALint minor_version, const ALCchar *devspec, const ALCchar *extensions) 1004 | { 1005 | ALCdevice *dev = REAL_alcOpenDevice(devicename); 1006 | if (!dev && retval) { 1007 | fprintf(stderr, "Uhoh, failed to open playback device when original run did!\n"); 1008 | if (devicename) { 1009 | fprintf(stderr, "Trying NULL device...\n"); 1010 | dev = REAL_alcOpenDevice(NULL); 1011 | if (!dev) { 1012 | fprintf(stderr, "Still no luck. This is probably going to go wrong.\n"); 1013 | } else { 1014 | fprintf(stderr, "That worked. Carrying on.\n"); 1015 | } 1016 | } 1017 | } 1018 | if (dev) { 1019 | add_device_to_map(retval, dev); 1020 | } 1021 | } 1022 | 1023 | static void run_alcCloseDevice(CallerInfo *callerinfo, ALCboolean retval, ALCdevice *device) 1024 | { 1025 | REAL_alcCloseDevice(get_mapped_device(device)); 1026 | } 1027 | 1028 | static void run_alcCreateContext(CallerInfo *callerinfo, ALCcontext *retval, ALCdevice *device, const ALCint *origattrlist, uint32 attrcount, const ALCint *attrlist) 1029 | { 1030 | ALCcontext *ctx = REAL_alcCreateContext(get_mapped_device(device), attrlist); 1031 | if (!ctx && retval) { 1032 | fprintf(stderr, "Uhoh, failed to create context when original run did!\n"); 1033 | if (attrlist) { 1034 | fprintf(stderr, "Trying default context...\n"); 1035 | ctx = REAL_alcCreateContext(get_mapped_device(device), NULL); 1036 | if (!ctx) { 1037 | fprintf(stderr, "Still no luck. This is probably going to go wrong.\n"); 1038 | } else { 1039 | fprintf(stderr, "That worked. Carrying on.\n"); 1040 | } 1041 | } 1042 | } 1043 | if (ctx) { 1044 | add_context_to_map(retval, ctx); 1045 | } 1046 | } 1047 | 1048 | static void run_alcMakeContextCurrent(CallerInfo *callerinfo, ALCboolean retval, ALCcontext *ctx) 1049 | { 1050 | REAL_alcMakeContextCurrent(get_mapped_context(ctx)); 1051 | } 1052 | 1053 | static void run_alcProcessContext(CallerInfo *callerinfo, ALCcontext *ctx) 1054 | { 1055 | REAL_alcProcessContext(get_mapped_context(ctx)); 1056 | } 1057 | 1058 | static void run_alcSuspendContext(CallerInfo *callerinfo, ALCcontext *ctx) 1059 | { 1060 | REAL_alcSuspendContext(get_mapped_context(ctx)); 1061 | } 1062 | 1063 | static void run_alcDestroyContext(CallerInfo *callerinfo, ALCcontext *ctx) 1064 | { 1065 | REAL_alcDestroyContext(get_mapped_context(ctx)); 1066 | } 1067 | 1068 | static void run_alcGetError(CallerInfo *callerinfo, ALCenum retval, ALCdevice *device) 1069 | { 1070 | REAL_alcGetError(get_mapped_device(device)); 1071 | } 1072 | 1073 | static void run_alcGetIntegerv(CallerInfo *callerinfo, ALCdevice *device, ALCenum param, ALCsizei size, ALCint *origvalues, ALCboolean isbool, ALCint *values) 1074 | { 1075 | REAL_alcGetIntegerv(get_mapped_device(device), param, size, values); 1076 | } 1077 | 1078 | static void run_alcCaptureStart(CallerInfo *callerinfo, ALCdevice *device) 1079 | { 1080 | REAL_alcCaptureStart(get_mapped_device(device)); 1081 | } 1082 | 1083 | static void run_alcCaptureStop(CallerInfo *callerinfo, ALCdevice *device) 1084 | { 1085 | REAL_alcCaptureStop(get_mapped_device(device)); 1086 | } 1087 | 1088 | static void run_alcCaptureSamples(CallerInfo *callerinfo, ALCdevice *device, ALCvoid *origbuffer, ALCvoid *buffer, ALCsizei bufferlen, ALCsizei samples) 1089 | { 1090 | REAL_alcCaptureSamples(get_mapped_device(device), buffer, samples); 1091 | } 1092 | 1093 | static void run_alDopplerFactor(CallerInfo *callerinfo, ALfloat value) 1094 | { 1095 | REAL_alDopplerFactor(value); 1096 | } 1097 | 1098 | static void run_alDopplerVelocity(CallerInfo *callerinfo, ALfloat value) 1099 | { 1100 | REAL_alDopplerVelocity(value); 1101 | } 1102 | 1103 | static void run_alSpeedOfSound(CallerInfo *callerinfo, ALfloat value) 1104 | { 1105 | REAL_alSpeedOfSound(value); 1106 | } 1107 | 1108 | static void run_alDistanceModel(CallerInfo *callerinfo, ALenum model) 1109 | { 1110 | REAL_alDistanceModel(model); 1111 | } 1112 | 1113 | static void run_alEnable(CallerInfo *callerinfo, ALenum capability) 1114 | { 1115 | REAL_alEnable(capability); 1116 | } 1117 | 1118 | static void run_alDisable(CallerInfo *callerinfo, ALenum capability) 1119 | { 1120 | REAL_alDisable(capability); 1121 | } 1122 | 1123 | static void run_alIsEnabled(CallerInfo *callerinfo, ALboolean retval, ALenum capability) 1124 | { 1125 | REAL_alIsEnabled(capability); 1126 | } 1127 | 1128 | static void run_alGetString(CallerInfo *callerinfo, const ALchar *retval, const ALenum param) 1129 | { 1130 | REAL_alGetString(param); 1131 | } 1132 | 1133 | static void run_alGetBooleanv(CallerInfo *callerinfo, ALenum param, ALboolean *origvalues, uint32 numvals, ALboolean *values) 1134 | { 1135 | REAL_alGetBooleanv(param, values); 1136 | } 1137 | 1138 | static void run_alGetIntegerv(CallerInfo *callerinfo, ALenum param, ALint *origvalues, uint32 numvals, ALboolean isenum, ALint *values) 1139 | { 1140 | REAL_alGetIntegerv(param, values); 1141 | } 1142 | 1143 | static void run_alGetFloatv(CallerInfo *callerinfo, ALenum param, ALfloat *origvalues, uint32 numvals, ALfloat *values) 1144 | { 1145 | REAL_alGetFloatv(param, values); 1146 | } 1147 | 1148 | static void run_alGetDoublev(CallerInfo *callerinfo, ALenum param, ALdouble *origvalues, uint32 numvals, ALdouble *values) 1149 | { 1150 | REAL_alGetDoublev(param, values); 1151 | } 1152 | 1153 | static void run_alGetBoolean(CallerInfo *callerinfo, ALboolean retval, ALenum param) 1154 | { 1155 | REAL_alGetBoolean(param); 1156 | } 1157 | 1158 | static void run_alGetInteger(CallerInfo *callerinfo, ALint retval, ALenum param) 1159 | { 1160 | REAL_alGetInteger(param); 1161 | } 1162 | 1163 | static void run_alGetFloat(CallerInfo *callerinfo, ALfloat retval, ALenum param) 1164 | { 1165 | REAL_alGetFloat(param); 1166 | } 1167 | 1168 | static void run_alGetDouble(CallerInfo *callerinfo, ALdouble retval, ALenum param) 1169 | { 1170 | REAL_alGetDouble(param); 1171 | } 1172 | 1173 | static void run_alIsExtensionPresent(CallerInfo *callerinfo, ALboolean retval, const ALchar *extname) 1174 | { 1175 | REAL_alIsExtensionPresent(extname); 1176 | } 1177 | 1178 | static void run_alGetError(CallerInfo *callerinfo, ALenum retval) 1179 | { 1180 | REAL_alGetError(); 1181 | } 1182 | 1183 | static void run_alGetProcAddress(CallerInfo *callerinfo, void *retval, const ALchar *funcname) 1184 | { 1185 | REAL_alGetProcAddress(funcname); 1186 | } 1187 | 1188 | static void run_alGetEnumValue(CallerInfo *callerinfo, ALenum retval, const ALchar *enumname) 1189 | { 1190 | REAL_alGetEnumValue(enumname); 1191 | } 1192 | 1193 | static void run_alListenerfv(CallerInfo *callerinfo, ALenum param, const ALfloat *origvalues, uint32 numvals, const ALfloat *values) 1194 | { 1195 | REAL_alListenerfv(param, values); 1196 | } 1197 | 1198 | static void run_alListenerf(CallerInfo *callerinfo, ALenum param, ALfloat value) 1199 | { 1200 | REAL_alListenerf(param, value); 1201 | } 1202 | 1203 | static void run_alListener3f(CallerInfo *callerinfo, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3) 1204 | { 1205 | REAL_alListener3f(param, value1, value2, value3); 1206 | } 1207 | 1208 | static void run_alListeneriv(CallerInfo *callerinfo, ALenum param, const ALint *origvalues, uint32 numvals, const ALint *values) 1209 | { 1210 | REAL_alListeneriv(param, values); 1211 | } 1212 | 1213 | static void run_alListeneri(CallerInfo *callerinfo, ALenum param, ALint value) 1214 | { 1215 | REAL_alListeneri(param, value); 1216 | } 1217 | 1218 | static void run_alListener3i(CallerInfo *callerinfo, ALenum param, ALint value1, ALint value2, ALint value3) 1219 | { 1220 | REAL_alListener3i(param, value1, value2, value3); 1221 | } 1222 | 1223 | static void run_alGetListenerfv(CallerInfo *callerinfo, ALenum param, ALfloat *origvalues, uint32 numvals, ALfloat *values) 1224 | { 1225 | REAL_alGetListenerfv(param, values); 1226 | } 1227 | 1228 | static void run_alGetListenerf(CallerInfo *callerinfo, ALenum param, ALfloat *origvalue, ALfloat value) 1229 | { 1230 | REAL_alGetListenerf(param, &value); 1231 | } 1232 | 1233 | static void run_alGetListener3f(CallerInfo *callerinfo, ALenum param, ALfloat *origvalue1, ALfloat *origvalue2, ALfloat *origvalue3, ALfloat value1, ALfloat value2, ALfloat value3) 1234 | { 1235 | REAL_alGetListener3f(param, &value1, &value2, &value3); 1236 | } 1237 | 1238 | static void run_alGetListeneri(CallerInfo *callerinfo, ALenum param, ALint *origvalue, ALint value) 1239 | { 1240 | REAL_alGetListeneri(param, &value); 1241 | } 1242 | 1243 | static void run_alGetListeneriv(CallerInfo *callerinfo, ALenum param, ALint *origvalues, uint32 numvals, ALint *values) 1244 | { 1245 | REAL_alGetListeneriv(param, values); 1246 | } 1247 | 1248 | static void run_alGetListener3i(CallerInfo *callerinfo, ALenum param, ALint *origvalue1, ALint *origvalue2, ALint *origvalue3, ALint value1, ALint value2, ALint value3) 1249 | { 1250 | REAL_alGetListener3i(param, &value1, &value2, &value3); 1251 | } 1252 | 1253 | static void run_alGenSources(CallerInfo *callerinfo, ALsizei n, ALuint *orignames, ALuint *names) 1254 | { 1255 | ALsizei i; 1256 | ALuint *realnames = (ALuint *) get_ioblob(sizeof (ALuint) * n); 1257 | memset(realnames, '\0', sizeof (ALuint) * n); 1258 | REAL_alGenSources(n, realnames); 1259 | for (i = 0; i < n; i++) { 1260 | if (!realnames[i] && names[i]) { 1261 | fprintf(stderr, "Uhoh, we didn't generate enough sources!\n"); 1262 | fprintf(stderr, "This is probably going to cause playback problems.\n"); 1263 | } else if (names[i] && realnames[i]) { 1264 | add_source_to_map(names[i], realnames[i]); 1265 | } 1266 | } 1267 | } 1268 | 1269 | static void run_alDeleteSources(CallerInfo *callerinfo, ALsizei n, const ALuint *orignames, const ALuint *names) 1270 | { 1271 | ALsizei i; 1272 | ALuint *realnames = (ALuint *) get_ioblob(sizeof (ALuint) * n); 1273 | for (i = 0; i < n; i++) { 1274 | realnames[i] = get_mapped_source(names[i]); 1275 | } 1276 | REAL_alDeleteSources(n, realnames); 1277 | } 1278 | 1279 | static void run_alIsSource(CallerInfo *callerinfo, ALboolean retval, ALuint name) 1280 | { 1281 | REAL_alIsSource(get_mapped_source(name)); 1282 | } 1283 | 1284 | static void run_alSourcefv(CallerInfo *callerinfo, ALuint name, ALenum param, const ALfloat *origvalues, uint32 numvals, const ALfloat *values) 1285 | { 1286 | REAL_alSourcefv(get_mapped_source(name), param, values); 1287 | } 1288 | 1289 | static void run_alSourcef(CallerInfo *callerinfo, ALuint name, ALenum param, ALfloat value) 1290 | { 1291 | REAL_alSourcef(get_mapped_source(name), param, value); 1292 | } 1293 | 1294 | static void run_alSource3f(CallerInfo *callerinfo, ALuint name, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3) 1295 | { 1296 | REAL_alSource3f(get_mapped_source(name), param, value1, value2, value3); 1297 | } 1298 | 1299 | static void run_alSourceiv(CallerInfo *callerinfo, ALuint name, ALenum param, const ALint *origvalues, uint32 numvals, const ALint *values) 1300 | { 1301 | REAL_alSourceiv(get_mapped_source(name), param, values); 1302 | } 1303 | 1304 | static void run_alSourcei(CallerInfo *callerinfo, ALuint name, ALenum param, ALint value) 1305 | { 1306 | REAL_alSourcei(get_mapped_source(name), param, value); 1307 | } 1308 | 1309 | static void run_alSource3i(CallerInfo *callerinfo, ALuint name, ALenum param, ALint value1, ALint value2, ALint value3) 1310 | { 1311 | REAL_alSource3i(get_mapped_source(name), param, value1, value2, value3); 1312 | } 1313 | 1314 | static void run_alGetSourcefv(CallerInfo *callerinfo, ALuint name, ALenum param, ALfloat *origvalues, uint32 numvals, ALfloat *values) 1315 | { 1316 | REAL_alGetSourcefv(get_mapped_source(name), param, values); 1317 | } 1318 | 1319 | static void run_alGetSourcef(CallerInfo *callerinfo, ALuint name, ALenum param, ALfloat *origvalue, ALfloat value) 1320 | { 1321 | REAL_alGetSourcef(get_mapped_source(name), param, &value); 1322 | } 1323 | 1324 | static void run_alGetSource3f(CallerInfo *callerinfo, ALuint name, ALenum param, ALfloat *origvalue1, ALfloat *origvalue2, ALfloat *origvalue3, ALfloat value1, ALfloat value2, ALfloat value3) 1325 | { 1326 | REAL_alGetSource3f(get_mapped_source(name), param, &value1, &value2, &value3); 1327 | } 1328 | 1329 | static void run_alGetSourceiv(CallerInfo *callerinfo, ALuint name, ALenum param, ALboolean isenum, ALint *origvalues, uint32 numvals, ALint *values) 1330 | { 1331 | const ALuint src = get_mapped_source(name); 1332 | 1333 | // in case we're running a little ahead of the AL, if this is a 1334 | // AL_BUFFERS_PROCESSED query, wait until at least as many as expected 1335 | // are available. 1336 | if (param == AL_BUFFERS_PROCESSED) { 1337 | const ALint expected = *values; 1338 | REAL_alGetSourceiv(src, AL_BUFFERS_PROCESSED, values); 1339 | while (*values < expected) { 1340 | usleep(1000); 1341 | REAL_alGetSourceiv(src, AL_BUFFERS_PROCESSED, values); 1342 | } 1343 | return; 1344 | } 1345 | 1346 | REAL_alGetSourceiv(src, param, values); 1347 | } 1348 | 1349 | static void run_alGetSourcei(CallerInfo *callerinfo, ALuint name, ALenum param, ALboolean isenum, ALint *origvalue, ALint value) 1350 | { 1351 | const ALuint src = get_mapped_source(name); 1352 | 1353 | // in case we're running a little ahead of the AL, if this is a 1354 | // AL_BUFFERS_PROCESSED query, wait until at least as many as expected 1355 | // are available. 1356 | if (param == AL_BUFFERS_PROCESSED) { 1357 | const ALint expected = value; 1358 | REAL_alGetSourcei(src, AL_BUFFERS_PROCESSED, &value); 1359 | while (value < expected) { 1360 | usleep(1000); 1361 | REAL_alGetSourcei(src, AL_BUFFERS_PROCESSED, &value); 1362 | } 1363 | return; 1364 | } 1365 | 1366 | REAL_alGetSourcei(src, param, &value); 1367 | } 1368 | 1369 | static void run_alGetSource3i(CallerInfo *callerinfo, ALuint name, ALenum param, ALint *origvalue1, ALint *origvalue2, ALint *origvalue3, ALint value1, ALint value2, ALint value3) 1370 | { 1371 | REAL_alGetSource3i(get_mapped_source(name), param, &value1, &value2, &value3); 1372 | } 1373 | 1374 | static void run_alSourcePlay(CallerInfo *callerinfo, ALuint name) 1375 | { 1376 | REAL_alSourcePlay(get_mapped_source(name)); 1377 | } 1378 | 1379 | static void run_alSourcePlayv(CallerInfo *callerinfo, ALsizei n, const ALuint *orignames, const ALuint *names) 1380 | { 1381 | ALsizei i; 1382 | ALuint *realnames = (ALuint *) get_ioblob(sizeof (ALuint) * n); 1383 | for (i = 0; i < n; i++) { 1384 | realnames[i] = get_mapped_source(names[i]); 1385 | } 1386 | REAL_alSourcePlayv(n, realnames); 1387 | } 1388 | 1389 | static void run_alSourcePause(CallerInfo *callerinfo, ALuint name) 1390 | { 1391 | REAL_alSourcePause(get_mapped_source(name)); 1392 | } 1393 | 1394 | static void run_alSourcePausev(CallerInfo *callerinfo, ALsizei n, const ALuint *orignames, const ALuint *names) 1395 | { 1396 | ALsizei i; 1397 | ALuint *realnames = (ALuint *) get_ioblob(sizeof (ALuint) * n); 1398 | for (i = 0; i < n; i++) { 1399 | realnames[i] = get_mapped_source(names[i]); 1400 | } 1401 | REAL_alSourcePausev(n, realnames); 1402 | } 1403 | 1404 | static void run_alSourceRewind(CallerInfo *callerinfo, ALuint name) 1405 | { 1406 | REAL_alSourceRewind(get_mapped_source(name)); 1407 | } 1408 | 1409 | static void run_alSourceRewindv(CallerInfo *callerinfo, ALsizei n, const ALuint *orignames, const ALuint *names) 1410 | { 1411 | ALsizei i; 1412 | ALuint *realnames = (ALuint *) get_ioblob(sizeof (ALuint) * n); 1413 | for (i = 0; i < n; i++) { 1414 | realnames[i] = get_mapped_source(names[i]); 1415 | } 1416 | REAL_alSourceRewindv(n, realnames); 1417 | } 1418 | 1419 | static void run_alSourceStop(CallerInfo *callerinfo, ALuint name) 1420 | { 1421 | REAL_alSourceStop(get_mapped_source(name)); 1422 | } 1423 | 1424 | static void run_alSourceStopv(CallerInfo *callerinfo, ALsizei n, const ALuint *orignames, const ALuint *names) 1425 | { 1426 | ALsizei i; 1427 | ALuint *realnames = (ALuint *) get_ioblob(sizeof (ALuint) * n); 1428 | for (i = 0; i < n; i++) { 1429 | realnames[i] = get_mapped_source(names[i]); 1430 | } 1431 | REAL_alSourceStopv(n, realnames); 1432 | } 1433 | 1434 | static void run_alSourceQueueBuffers(CallerInfo *callerinfo, ALuint name, ALsizei nb, const ALuint *origbufnames, const ALuint *bufnames) 1435 | { 1436 | ALsizei i; 1437 | ALuint *realnames = (ALuint *) get_ioblob(sizeof (ALuint) * nb); 1438 | for (i = 0; i < nb; i++) { 1439 | realnames[i] = get_mapped_buffer(bufnames[i]); 1440 | } 1441 | REAL_alSourceQueueBuffers(get_mapped_source(name), nb, realnames); 1442 | } 1443 | 1444 | static void run_alSourceUnqueueBuffers(CallerInfo *callerinfo, ALuint name, ALsizei nb, ALuint *origbufnames, ALuint *bufnames) 1445 | { 1446 | REAL_alSourceUnqueueBuffers(get_mapped_source(name), nb, bufnames); 1447 | } 1448 | 1449 | static void run_alGenBuffers(CallerInfo *callerinfo, ALsizei n, ALuint *orignames, ALuint *names) 1450 | { 1451 | ALsizei i; 1452 | ALuint *realnames = (ALuint *) get_ioblob(sizeof (ALuint) * n); 1453 | memset(realnames, '\0', sizeof (ALuint) * n); 1454 | REAL_alGenBuffers(n, realnames); 1455 | for (i = 0; i < n; i++) { 1456 | if (!realnames[i] && names[i]) { 1457 | fprintf(stderr, "Uhoh, we didn't generate enough buffers!\n"); 1458 | fprintf(stderr, "This is probably going to cause playback problems.\n"); 1459 | } else if (names[i] && realnames[i]) { 1460 | add_buffer_to_map(names[i], realnames[i]); 1461 | } 1462 | } 1463 | } 1464 | 1465 | static void run_alDeleteBuffers(CallerInfo *callerinfo, ALsizei n, const ALuint *orignames, const ALuint *names) 1466 | { 1467 | ALsizei i; 1468 | ALuint *realnames = (ALuint *) get_ioblob(sizeof (ALuint) * n); 1469 | for (i = 0; i < n; i++) { 1470 | realnames[i] = get_mapped_source(names[i]); 1471 | } 1472 | REAL_alDeleteBuffers(n, realnames); 1473 | } 1474 | 1475 | static void run_alIsBuffer(CallerInfo *callerinfo, ALboolean retval, ALuint name) 1476 | { 1477 | REAL_alIsBuffer(get_mapped_buffer(name)); 1478 | } 1479 | 1480 | static void run_alBufferData(CallerInfo *callerinfo, ALuint name, ALenum alfmt, const ALvoid *origdata, const ALvoid *data, ALsizei size, ALsizei freq) 1481 | { 1482 | REAL_alBufferData(get_mapped_buffer(name), alfmt, data, size, freq); 1483 | } 1484 | 1485 | static void run_alBufferfv(CallerInfo *callerinfo, ALuint name, ALenum param, const ALfloat *origvalues, uint32 numvals, const ALfloat *values) 1486 | { 1487 | REAL_alBufferfv(get_mapped_buffer(name), param, values); 1488 | } 1489 | 1490 | static void run_alBufferf(CallerInfo *callerinfo, ALuint name, ALenum param, ALfloat value) 1491 | { 1492 | REAL_alBufferf(get_mapped_buffer(name), param, value); 1493 | } 1494 | 1495 | static void run_alBuffer3f(CallerInfo *callerinfo, ALuint name, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3) 1496 | { 1497 | REAL_alBuffer3f(get_mapped_buffer(name), param, value1, value2, value3); 1498 | } 1499 | 1500 | static void run_alBufferiv(CallerInfo *callerinfo, ALuint name, ALenum param, const ALint *origvalues, uint32 numvals, const ALint *values) 1501 | { 1502 | REAL_alBufferiv(get_mapped_buffer(name), param, values); 1503 | } 1504 | 1505 | static void run_alBufferi(CallerInfo *callerinfo, ALuint name, ALenum param, ALint value) 1506 | { 1507 | REAL_alBufferi(get_mapped_buffer(name), param, value); 1508 | } 1509 | 1510 | static void run_alBuffer3i(CallerInfo *callerinfo, ALuint name, ALenum param, ALint value1, ALint value2, ALint value3) 1511 | { 1512 | REAL_alBuffer3i(get_mapped_buffer(name), param, value1, value2, value3); 1513 | } 1514 | 1515 | static void run_alGetBufferfv(CallerInfo *callerinfo, ALuint name, ALenum param, ALfloat *origvalues, uint32 numvals, ALfloat *values) 1516 | { 1517 | REAL_alGetBufferfv(get_mapped_buffer(name), param, values); 1518 | } 1519 | 1520 | static void run_alGetBufferf(CallerInfo *callerinfo, ALuint name, ALenum param, ALfloat *origvalue, ALfloat value) 1521 | { 1522 | REAL_alGetBufferf(get_mapped_buffer(name), param, &value); 1523 | } 1524 | 1525 | static void run_alGetBuffer3f(CallerInfo *callerinfo, ALuint name, ALenum param, ALfloat *origvalue1, ALfloat *origvalue2, ALfloat *origvalue3, ALfloat value1, ALfloat value2, ALfloat value3) 1526 | { 1527 | REAL_alGetBuffer3f(get_mapped_buffer(name), param, &value1, &value2, &value3); 1528 | } 1529 | 1530 | static void run_alGetBufferi(CallerInfo *callerinfo, ALuint name, ALenum param, ALint *origvalue, ALint value) 1531 | { 1532 | REAL_alGetBufferi(get_mapped_buffer(name), param, &value); 1533 | } 1534 | 1535 | static void run_alGetBuffer3i(CallerInfo *callerinfo, ALuint name, ALenum param, ALint *origvalue1, ALint *origvalue2, ALint *origvalue3, ALint value1, ALint value2, ALint value3) 1536 | { 1537 | REAL_alGetBuffer3i(get_mapped_buffer(name), param, &value1, &value2, &value3); 1538 | } 1539 | 1540 | static void run_alGetBufferiv(CallerInfo *callerinfo, ALuint name, ALenum param, ALint *origvalues, uint32 numvals, ALint *values) 1541 | { 1542 | REAL_alGetBufferiv(get_mapped_buffer(name), param, values); 1543 | } 1544 | 1545 | static void run_alTracePushScope(CallerInfo *callerinfo, const ALchar *str) 1546 | { 1547 | if (REAL_alTracePushScope) { REAL_alTracePushScope(str); } 1548 | } 1549 | 1550 | static void run_alTracePopScope(CallerInfo *callerinfo) 1551 | { 1552 | if (REAL_alTracePopScope) { REAL_alTracePopScope(); } 1553 | } 1554 | 1555 | static void run_alTraceMessage(CallerInfo *callerinfo, const ALchar *str) 1556 | { 1557 | if (REAL_alTraceMessage) { REAL_alTraceMessage(str); } 1558 | } 1559 | 1560 | static void run_alTraceBufferLabel(CallerInfo *callerinfo, ALuint name, const ALchar *str) 1561 | { 1562 | if (REAL_alTraceBufferLabel) { REAL_alTraceBufferLabel(get_mapped_buffer(name), str); } 1563 | } 1564 | 1565 | static void run_alTraceSourceLabel(CallerInfo *callerinfo, ALuint name, const ALchar *str) 1566 | { 1567 | if (REAL_alTraceSourceLabel) { REAL_alTraceSourceLabel(get_mapped_source(name), str); } 1568 | } 1569 | 1570 | static void run_alcTraceDeviceLabel(CallerInfo *callerinfo, ALCdevice *device, const ALCchar *str) 1571 | { 1572 | if (REAL_alcTraceDeviceLabel) { REAL_alcTraceDeviceLabel(get_mapped_device(device), str); } 1573 | } 1574 | 1575 | static void run_alcTraceContextLabel(CallerInfo *callerinfo, ALCcontext *ctx, const ALCchar *str) 1576 | { 1577 | if (REAL_alcTraceContextLabel) { REAL_alcTraceContextLabel(get_mapped_context(ctx), str); } 1578 | } 1579 | 1580 | 1581 | 1582 | static void dump_callerinfo(const CallerInfo *callerinfo, const char *fn) 1583 | { 1584 | int i; 1585 | 1586 | if (dump_callers) { 1587 | const int frames = callerinfo->num_callstack_frames; 1588 | int framei; 1589 | for (i = 0; i < callerinfo->trace_scope; i++) { 1590 | printf(" "); 1591 | } 1592 | 1593 | printf("Call from threadid = %u, stack = {\n", (uint) callerinfo->threadid); 1594 | 1595 | for (framei = 0; framei < frames; framei++) { 1596 | void *ptr = callerinfo->callstack[framei].frame; 1597 | const char *str = callerinfo->callstack[framei].sym; 1598 | for (i = 0; i < callerinfo->trace_scope; i++) { 1599 | printf(" "); 1600 | } 1601 | printf(" %s\n", str ? str : ptrString(ptr)); 1602 | } 1603 | 1604 | for (i = 0; i < callerinfo->trace_scope; i++) { 1605 | printf(" "); 1606 | } 1607 | printf("}\n"); 1608 | } 1609 | 1610 | if (dump_calls) { 1611 | for (i = 0; i < callerinfo->trace_scope; i++) { 1612 | printf(" "); 1613 | } 1614 | printf("%s", fn); 1615 | } 1616 | } 1617 | 1618 | #define ENTRYPOINT(ret,name,params,args,numargs,visitparams,visitargs) \ 1619 | void visit_##name visitparams { \ 1620 | dump_callerinfo(callerinfo, #name); \ 1621 | if (dump_calls) { dump_##name visitargs; } \ 1622 | if (run_calls) { \ 1623 | wait_until(callerinfo->wait_until); \ 1624 | run_##name visitargs; \ 1625 | } \ 1626 | if (dumping) { fflush(stdout); } \ 1627 | } 1628 | 1629 | #include "altrace_entrypoints.h" 1630 | 1631 | 1632 | int main(int argc, char **argv) 1633 | { 1634 | const char *fname = NULL; 1635 | int retval = 0; 1636 | int usage = 0; 1637 | int i; 1638 | 1639 | for (i = 1; i < argc; i++) { 1640 | const char *arg = argv[i]; 1641 | if (strcmp(arg, "--dump-calls") == 0) { 1642 | dump_calls = 1; 1643 | } else if (strcmp(arg, "--no-dump-calls") == 0) { 1644 | dump_calls = 0; 1645 | } else if (strcmp(arg, "--dump-callers") == 0) { 1646 | dump_callers = 1; 1647 | } else if (strcmp(arg, "--no-dump-callers") == 0) { 1648 | dump_callers = 0; 1649 | } else if (strcmp(arg, "--dump-errors") == 0) { 1650 | dump_errors = 1; 1651 | } else if (strcmp(arg, "--no-dump-errors") == 0) { 1652 | dump_errors = 0; 1653 | } else if (strcmp(arg, "--dump-state-changes") == 0) { 1654 | dump_state_changes = 1; 1655 | } else if (strcmp(arg, "--no-dump-state-changes") == 0) { 1656 | dump_state_changes = 0; 1657 | } else if (strcmp(arg, "--dump-all") == 0) { 1658 | dump_calls = dump_callers = dump_errors = dump_state_changes = 1; 1659 | } else if (strcmp(arg, "--no-dump-all") == 0) { 1660 | dump_calls = dump_callers = dump_errors = dump_state_changes = 0; 1661 | } else if (strcmp(arg, "--run") == 0) { 1662 | run_calls = 1; 1663 | } else if (strcmp(arg, "--no-run") == 0) { 1664 | run_calls = 0; 1665 | } else if (strcmp(arg, "--help") == 0) { 1666 | usage = 1; 1667 | } else if (fname == NULL) { 1668 | fname = arg; 1669 | } else { 1670 | usage = 1; 1671 | } 1672 | } 1673 | 1674 | if (fname == NULL) { 1675 | usage = 1; 1676 | } 1677 | 1678 | if (usage) { 1679 | fprintf(stderr, "USAGE: %s [args] \n", argv[0]); 1680 | fprintf(stderr, " args:\n"); 1681 | fprintf(stderr, " --[no-]dump-calls\n"); 1682 | fprintf(stderr, " --[no-]dump-callers\n"); 1683 | fprintf(stderr, " --[no-]dump-errors\n"); 1684 | fprintf(stderr, " --[no-]dump-state-changes\n"); 1685 | fprintf(stderr, " --[no-]dump-all\n"); 1686 | fprintf(stderr, " --[no-]run\n"); 1687 | fprintf(stderr, "\n"); 1688 | return 1; 1689 | } 1690 | 1691 | dumping = dump_calls || dump_callers || dump_errors || dump_state_changes; 1692 | 1693 | if (run_calls) { 1694 | if (!init_clock()) { 1695 | return 1; 1696 | } 1697 | 1698 | if (!load_real_openal()) { 1699 | return 1; 1700 | } 1701 | } 1702 | 1703 | fprintf(stderr, "\n\n\n%s: Playback OpenAL session from log file '%s'\n\n\n", GAppName, fname); 1704 | 1705 | if (!process_tracelog(fname, NULL)) { 1706 | retval = 1; 1707 | } 1708 | 1709 | if (run_calls) { 1710 | close_real_openal(); 1711 | } 1712 | 1713 | return retval; 1714 | } 1715 | 1716 | // end of altrace_cli.c ... 1717 | 1718 | --------------------------------------------------------------------------------